def __init__(self, settings: dict): """ """ # Set outside access to constants self.COMMANDS: COMMANDS = COMMANDS self.SERVEREVENTS: SERVEREVENTS = SERVEREVENTS self.MESSAGEIDS: MESSAGEIDS = MESSAGEIDS self.on: On = self.On() # Register System Event functions _EVENT.onError(self._ERROR) _EVENT.on(SERVEREVENTS.ERROR, self._ERROR) _EVENT.on(SERVEREVENTS.CONNECTED, self._CONNECTED) _EVENT.on(SERVEREVENTS.RECEIVED, self._RECEIVED) _EVENT.on(COMMANDS.PING, self._onPING) _EVENT.on(COMMANDS.PONG, self._onPONG) # Populate settings values self._server: str = settings['server'] self._port: int = settings['port'] self._user: str = settings['user'] self._password: str = settings['password'] self._chatrooms: list = settings['chatrooms'] self._pingWait: int = 5 * 60 # Set helper Varibles self._disconnect: bool = False self._lastPing: time = time.time() self._sendMessageQ: queue = queue.SimpleQueue() self._socket: socket = socket.socket() # IRC Command constants self._CAPREQUEST: str = "CAP REQ: twitch.tv/tags twitch.tv/commands twitch.tv/membership" self._PASS: str = f"PASS {self._password}" self._NICK: str = f"NICK {self._user}" self._JOIN: str = "JOIN #{}" self._PONG: str = f"PONG: {SERVEREVENTS.TMI_TWITCH_TV}" self._PING: str = f"PING: {SERVEREVENTS.TMI_TWITCH_TV}"
def TOS_BAN(self, func) -> None: _EVENT.on(MESSAGEIDS.TOS_BAN, func)
def WHISPER_INVALID_ARGS(self, func) -> None: _EVENT.on(MESSAGEIDS.WHISPER_INVALID_ARGS, func)
def WHISPER_BANNED(self, func) -> None: _EVENT.on(MESSAGEIDS.WHISPER_BANNED, func)
def USAGE_UNRAID(self, func) -> None: _EVENT.on(MESSAGEIDS.USAGE_UNRAID, func)
def USAGE_UNBAN(self, func) -> None: _EVENT.on(MESSAGEIDS.USAGE_UNBAN, func)
def USAGE_SLOW_OFF(self, func) -> None: _EVENT.on(MESSAGEIDS.USAGE_SLOW_OFF, func)
def USAGE_ME(self, func) -> None: _EVENT.on(MESSAGEIDS.USAGE_ME, func)
def UNTIMEOUT_BANNED(self, func) -> None: _EVENT.on(MESSAGEIDS.UNTIMEOUT_BANNED, func)
def UNSUPPORTED_CHATROOMS_CMD(self, func) -> None: _EVENT.on(MESSAGEIDS.UNSUPPORTED_CHATROOMS_CMD, func)
def UNRECOGNIZED_CMD(self, func) -> None: _EVENT.on(MESSAGEIDS.UNRECOGNIZED_CMD, func)
def UNRAID_SUCCESS(self, func) -> None: _EVENT.on(MESSAGEIDS.UNRAID_SUCCESS, func)
def UNRAID_ERROR_UNEXPECTED(self, func) -> None: _EVENT.on(MESSAGEIDS.UNRAID_ERROR_UNEXPECTED, func)
def UNRAID_ERROR_NO_ACTIVE_RAID(self, func) -> None: _EVENT.on(MESSAGEIDS.UNRAID_ERROR_NO_ACTIVE_RAID, func)
def TURBO_ONLY_COLOR(self, func) -> None: _EVENT.on(MESSAGEIDS.TURBO_ONLY_COLOR, func)
def USAGE_HELP(self, func) -> None: _EVENT.on(MESSAGEIDS.USAGE_HELP, func)
def USAGE_MARKER(self, func) -> None: _EVENT.on(MESSAGEIDS.USAGE_MARKER, func)
def UNTIMEOUT_SUCCESS(self, func) -> None: _EVENT.on(MESSAGEIDS.UNTIMEOUT_SUCCESS, func)
def USAGE_MODS(self, func) -> None: _EVENT.on(MESSAGEIDS.USAGE_MODS, func)
def USAGE_CLEAR(self, func) -> None: _EVENT.on(MESSAGEIDS.USAGE_CLEAR, func)
def USAGE_SUBS_ON(self, func) -> None: _EVENT.on(MESSAGEIDS.USAGE_SUBS_ON, func)
def USAGE_COLOR(self, func) -> None: _EVENT.on(MESSAGEIDS.USAGE_COLOR, func)
def USAGE_UNHOST(self, func) -> None: _EVENT.on(MESSAGEIDS.USAGE_UNHOST, func)
def USAGE_COMMERCIAL(self, func) -> None: _EVENT.on(MESSAGEIDS.USAGE_COMMERCIAL, func)
def USAGE_UNTIMEOUT(self, func) -> None: _EVENT.on(MESSAGEIDS.USAGE_UNTIMEOUT, func)
def USAGE_DISCONNECT(self, func) -> None: _EVENT.on(MESSAGEIDS.USAGE_DISCONNECT, func)
def WHISPER_BANNED_RECIPIENT(self, func) -> None: _EVENT.on(MESSAGEIDS.WHISPER_BANNED_RECIPIENT, func)
def USAGE_EMOTE_ONLY_ON(self, func) -> None: _EVENT.on(MESSAGEIDS.USAGE_EMOTE_ONLY_ON, func)
def WHISPER_INVALID_LOGIN(self, func) -> None: _EVENT.on(MESSAGEIDS.WHISPER_INVALID_LOGIN, func)
def USAGE_FOLLOWERS_ON(self, func) -> None: _EVENT.on(MESSAGEIDS.USAGE_FOLLOWERS_ON, func)