diff --git a/src/services/twitch_handler.ts b/src/services/twitch_handler.ts index f79f5f6..e3ccaf0 100644 --- a/src/services/twitch_handler.ts +++ b/src/services/twitch_handler.ts @@ -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(/\((?[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({