Update the Twitch handler to make the system look for answers in the messages
This commit is contained in:
parent
7412fa7862
commit
034a2a3dd1
1 changed files with 14 additions and 2 deletions
|
|
@ -1,7 +1,7 @@
|
||||||
//
|
//
|
||||||
// twitch_handler.ts
|
// twitch_handler.ts
|
||||||
//
|
//
|
||||||
// Written by: Oliver Akins (2019/12/10 - 2020/07/21)
|
// Written by: Oliver Akins (2019/12/10 - 2021/12/02)
|
||||||
//
|
//
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -9,12 +9,13 @@ tmi.js DOCS: https://github.com/tmijs/docs/blob/gh-pages/_posts/v1.4.2/2019-03-0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
import { log_error, log, push } from "../utils/webhook";
|
import { log_error, log } from "../utils/webhook";
|
||||||
import { HANDLE_MESSAGE } from "../cmd_handler";
|
import { HANDLE_MESSAGE } from "../cmd_handler";
|
||||||
import { LOAD_CONFIG } from "../utils/Config";
|
import { LOAD_CONFIG } from "../utils/Config";
|
||||||
import { PERM } from "../constants";
|
import { PERM } from "../constants";
|
||||||
import * as tmi from "tmi.js";
|
import * as tmi from "tmi.js";
|
||||||
|
|
||||||
|
import { users } from "../main";
|
||||||
|
|
||||||
|
|
||||||
export const run_twitch = (): void => {
|
export const run_twitch = (): void => {
|
||||||
|
|
@ -70,6 +71,17 @@ export const run_twitch = (): void => {
|
||||||
if (is_admin) { level = PERM.ADMIN; };
|
if (is_admin) { level = PERM.ADMIN; };
|
||||||
// !SECTION: Context parsing
|
// !SECTION: Context parsing
|
||||||
|
|
||||||
|
// Check if the user is voting
|
||||||
|
let match = message.match(/\((?<choice>[A-F])\i)/)
|
||||||
|
if (match) {
|
||||||
|
let choice: string = (match as any).choice;
|
||||||
|
|
||||||
|
// Update the user's answer
|
||||||
|
users[context.username] = choice;
|
||||||
|
|
||||||
|
console.log(`Answer ${choice} recorded for ${context.username}`);
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
|
||||||
// NOTE: Get response
|
// NOTE: Get response
|
||||||
let response: string = HANDLE_MESSAGE({
|
let response: string = HANDLE_MESSAGE({
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue