Update the Twitch handler to make the system look for answers in the messages

This commit is contained in:
Oliver-Akins 2021-12-02 15:38:28 -06:00
parent 7412fa7862
commit 034a2a3dd1

View file

@ -1,7 +1,7 @@
//
// 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 { LOAD_CONFIG } from "../utils/Config";
import { PERM } from "../constants";
import * as tmi from "tmi.js";
import { users } from "../main";
export const run_twitch = (): void => {
@ -70,6 +71,17 @@ export const run_twitch = (): void => {
if (is_admin) { level = PERM.ADMIN; };
// !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
let response: string = HANDLE_MESSAGE({