|
|
|
@ -31,6 +31,20 @@ QUOTE_REMOVED_PATTERN = re.compile(r'''^
|
|
|
|
|
Successfully\s+deleted\s+Quote\s+
|
|
|
|
|
\#(?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 !
|
|
|
|
|
SUB_GIFTED_PATTERN = re.compile(r'''^
|
|
|
|
|
(?P<giver>.+),\s+
|
|
|
|
@ -49,6 +63,8 @@ class TwitchClient(irc.bot.SingleServerIRCBot):
|
|
|
|
|
(QUOTE_ADDED_PATTERN, self._add_quote),
|
|
|
|
|
(QUOTE_EDITED_PATTERN, self._edit_quote),
|
|
|
|
|
(QUOTE_REMOVED_PATTERN, self._remove_quote),
|
|
|
|
|
(SUB_PATTERN, self._record_sub),
|
|
|
|
|
(RESUB_PATTERN, self._record_resub),
|
|
|
|
|
(SUB_GIFTED_PATTERN, self._record_gifted_sub),
|
|
|
|
|
]
|
|
|
|
|
self.supported_commands = [
|
|
|
|
@ -95,6 +111,8 @@ class TwitchClient(irc.bot.SingleServerIRCBot):
|
|
|
|
|
self._process_message(connection, event)
|
|
|
|
|
|
|
|
|
|
def _is_mod(self, tags):
|
|
|
|
|
if not tags['badges']:
|
|
|
|
|
return False
|
|
|
|
|
badges = [b.split('/')[0] for b in tags['badges'].split(',')]
|
|
|
|
|
return bool(set(badges).intersection(['admin', 'broadcaster', 'moderator']))
|
|
|
|
|
|
|
|
|
@ -147,6 +165,20 @@ class TwitchClient(irc.bot.SingleServerIRCBot):
|
|
|
|
|
except CommandError as 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):
|
|
|
|
|
self.logger.info('Recording gifted sub %s -> %s', giver, receiver)
|
|
|
|
|
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']))
|
|
|
|
|
return
|
|
|
|
|
try:
|
|
|
|
|
messages = self.commands.get_gifted_sub_messages()
|
|
|
|
|
messages = self.commands.get_sub_messages()
|
|
|
|
|
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:
|
|
|
|
|
for message, time in messages:
|
|
|
|
|
for pattern, action in self.patterns:
|
|
|
|
|