|
|
@ -31,6 +31,20 @@ QUOTE_REMOVED_PATTERN = re.compile(r'''^
|
|
|
|
Successfully\s+deleted\s+Quote\s+
|
|
|
|
Successfully\s+deleted\s+Quote\s+
|
|
|
|
\#(?P<id>\d+)\.$''', re.VERBOSE)
|
|
|
|
\#(?P<id>\d+)\.$''', re.VERBOSE)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# $user has joined the Cheese Horde! CHEESE HYPE!!! ♥♥
|
|
|
|
|
|
|
|
SUB_PATTERN = re.compile(r'''^
|
|
|
|
|
|
|
|
(?P<user>.+)\s+
|
|
|
|
|
|
|
|
has\s+joined\s+the\s+Cheese\s+Horde!\s+
|
|
|
|
|
|
|
|
CHEESE\s+HYPE!!!\s+♥♥$''', re.VERBOSE)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# $user, Thank you for the $rank months of cheesy support! ♥♥♥♥ CHEESE HYPE!!!
|
|
|
|
|
|
|
|
RESUB_PATTERN = re.compile(r'''^
|
|
|
|
|
|
|
|
(?P<user>.+),\s+
|
|
|
|
|
|
|
|
Thank\s+you\s+for\s+the\s+
|
|
|
|
|
|
|
|
(?P<rank>\d+)\s+
|
|
|
|
|
|
|
|
months\s+of\s+cheesy\s+support!\s+
|
|
|
|
|
|
|
|
♥♥♥♥\s+CHEESE\s+HYPE!!!$''', re.VERBOSE)
|
|
|
|
|
|
|
|
|
|
|
|
# $giver, Thank you for gifting a sub to $receiver! So kind <3 !
|
|
|
|
# $giver, Thank you for gifting a sub to $receiver! So kind <3 !
|
|
|
|
SUB_GIFTED_PATTERN = re.compile(r'''^
|
|
|
|
SUB_GIFTED_PATTERN = re.compile(r'''^
|
|
|
|
(?P<giver>.+),\s+
|
|
|
|
(?P<giver>.+),\s+
|
|
|
@ -49,6 +63,8 @@ class TwitchClient(irc.bot.SingleServerIRCBot):
|
|
|
|
(QUOTE_ADDED_PATTERN, self._add_quote),
|
|
|
|
(QUOTE_ADDED_PATTERN, self._add_quote),
|
|
|
|
(QUOTE_EDITED_PATTERN, self._edit_quote),
|
|
|
|
(QUOTE_EDITED_PATTERN, self._edit_quote),
|
|
|
|
(QUOTE_REMOVED_PATTERN, self._remove_quote),
|
|
|
|
(QUOTE_REMOVED_PATTERN, self._remove_quote),
|
|
|
|
|
|
|
|
(SUB_PATTERN, self._record_sub),
|
|
|
|
|
|
|
|
(RESUB_PATTERN, self._record_resub),
|
|
|
|
(SUB_GIFTED_PATTERN, self._record_gifted_sub),
|
|
|
|
(SUB_GIFTED_PATTERN, self._record_gifted_sub),
|
|
|
|
]
|
|
|
|
]
|
|
|
|
self.supported_commands = [
|
|
|
|
self.supported_commands = [
|
|
|
@ -95,6 +111,8 @@ class TwitchClient(irc.bot.SingleServerIRCBot):
|
|
|
|
self._process_message(connection, event)
|
|
|
|
self._process_message(connection, event)
|
|
|
|
|
|
|
|
|
|
|
|
def _is_mod(self, tags):
|
|
|
|
def _is_mod(self, tags):
|
|
|
|
|
|
|
|
if not tags['badges']:
|
|
|
|
|
|
|
|
return False
|
|
|
|
badges = [b.split('/')[0] for b in tags['badges'].split(',')]
|
|
|
|
badges = [b.split('/')[0] for b in tags['badges'].split(',')]
|
|
|
|
return bool(set(badges).intersection(['admin', 'broadcaster', 'moderator']))
|
|
|
|
return bool(set(badges).intersection(['admin', 'broadcaster', 'moderator']))
|
|
|
|
|
|
|
|
|
|
|
@ -147,6 +165,20 @@ class TwitchClient(irc.bot.SingleServerIRCBot):
|
|
|
|
except CommandError as e:
|
|
|
|
except CommandError as e:
|
|
|
|
self.logger.error('Failed to remove quote: %s', e)
|
|
|
|
self.logger.error('Failed to remove quote: %s', e)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _record_sub(self, tags, send_response, user, **kwargs):
|
|
|
|
|
|
|
|
self.logger.info('Recording new sub of %s', user)
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
self.commands.record_regular_sub(user, 1, kwargs.get('time'))
|
|
|
|
|
|
|
|
except CommandError as e:
|
|
|
|
|
|
|
|
self.logger.error('Failed to record new sub: %s', e)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _record_resub(self, tags, send_response, user, rank, **kwargs):
|
|
|
|
|
|
|
|
self.logger.info('Recording %sx resub of %s', rank, user)
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
self.commands.record_regular_sub(user, int(rank), kwargs.get('time'))
|
|
|
|
|
|
|
|
except CommandError as e:
|
|
|
|
|
|
|
|
self.logger.error('Failed to record resub: %s', e)
|
|
|
|
|
|
|
|
|
|
|
|
def _record_gifted_sub(self, tags, send_response, giver, receiver, **kwargs):
|
|
|
|
def _record_gifted_sub(self, tags, send_response, giver, receiver, **kwargs):
|
|
|
|
self.logger.info('Recording gifted sub %s -> %s', giver, receiver)
|
|
|
|
self.logger.info('Recording gifted sub %s -> %s', giver, receiver)
|
|
|
|
try:
|
|
|
|
try:
|
|
|
@ -197,9 +229,9 @@ class TwitchClient(irc.bot.SingleServerIRCBot):
|
|
|
|
send_response('Sorry @{0}, you are not allowed to do this'.format(tags['display-name']))
|
|
|
|
send_response('Sorry @{0}, you are not allowed to do this'.format(tags['display-name']))
|
|
|
|
return
|
|
|
|
return
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
messages = self.commands.get_gifted_sub_messages()
|
|
|
|
messages = self.commands.get_sub_messages()
|
|
|
|
except CommandError as e:
|
|
|
|
except CommandError as e:
|
|
|
|
self.logger.error('Failed to get gifted sub messages: %s', e)
|
|
|
|
self.logger.error('Failed to get sub messages: %s', e)
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
for message, time in messages:
|
|
|
|
for message, time in messages:
|
|
|
|
for pattern, action in self.patterns:
|
|
|
|
for pattern, action in self.patterns:
|
|
|
|