allow moderators to use !so and !wideoidea

This commit is contained in:
Anthony Sottile 2020-07-06 15:37:49 -07:00
parent 24091e302b
commit 940a270f67
1 changed files with 8 additions and 2 deletions

10
bot.py
View File

@ -96,6 +96,12 @@ def _badges(badges: str) -> str:
return ret return ret
def _is_moderator(match: Match[str]) -> bool:
info = _parse_badge_info(match['info'])
badges = info['badges'].split(',')
return any(badge.startswith('moderator/') for badge in badges)
def _gen_color(name: str) -> Tuple[int, int, int]: def _gen_color(name: str) -> Tuple[int, int, int]:
h = hashlib.sha256(name.encode()) h = hashlib.sha256(name.encode())
n, = struct.unpack('Q', h.digest()[:8]) n, = struct.unpack('Q', h.digest()[:8])
@ -376,7 +382,7 @@ class VideoIdeaResponse(MessageResponse):
@handle_message('![wv]ideoidea') @handle_message('![wv]ideoidea')
def cmd_videoidea(match: Match[str]) -> Response: def cmd_videoidea(match: Match[str]) -> Response:
if match['user'] != match['channel']: if not _is_moderator(match) and match['user'] != match['channel']:
return MessageResponse( return MessageResponse(
match, 'https://www.youtube.com/watch?v=RfiQYRn7fBg', match, 'https://www.youtube.com/watch?v=RfiQYRn7fBg',
) )
@ -548,7 +554,7 @@ def cmd_joke(match: Match[str]) -> Response:
@handle_message('!so (?P<user_channel>.+)') @handle_message('!so (?P<user_channel>.+)')
def cmd_shoutout(match: Match[str]) -> Response: def cmd_shoutout(match: Match[str]) -> Response:
if match['user'] != match['channel']: if not _is_moderator(match) and match['user'] != match['channel']:
return MessageResponse( return MessageResponse(
match, 'https://www.youtube.com/watch?v=RfiQYRn7fBg', match, 'https://www.youtube.com/watch?v=RfiQYRn7fBg',
) )