Exemplo n.º 1
0
 def join_command(self, event, game):
     """Adds a user to a game"""
     game = game.replace('_', ' ')
     game = Game.get_game_by_name(game)
     if not game:
         return event.msg.reply(
             'Game not found, check your spelling and try again')
     event.member.add_role(game.join_role)
     return game.execute(event)
Exemplo n.º 2
0
 def clear_game_command(self, event, game):
     """Clears attendees for game"""
     game = game.replace('_', ' ')
     game = Game.get_game_by_name(game)  # type: Game
     if not game:
         event.msg.reply(
             'Game not found, check your spelling and try again')
         return
     query = Game.update(attendees=[])
     query.where(Game.name == game.name).execute()
     event.msg.reply('Okay! Cleared attendee list for {}'.format(game.name))
Exemplo n.º 3
0
 def code_get_command(self, event, src_type, game):
     """Gets join or start code for a game"""
     game = game.replace('_', ' ')
     game = Game.get_game_by_name(game)  # type: Game
     if not game:
         event.msg.reply(
             'Game not found, check your spelling and try again')
         return
     if src_type == 'join':
         event.msg.reply('```{}```'.format(game.join_src))
     elif src_type == 'start':
         event.msg.reply('```{}```'.format(game.play_src))
     else:
         event.msg.reply('Either `!code set join` or `!code set start`')
Exemplo n.º 4
0
 def on_reaction_add(self, event):
     if event.user_id == self.bot.client.state.me.id:
         return
     if 'team' in event.emoji.name.lower():
         team = event.emoji.name.lower().replace('mmteam', '')
         reply = self.join_team(team,
                                event.guild.members[event.user_id].user)
     else:
         game_name = EMOJIS[event.emoji.id].replace('MM', '')
         game = Game.get_game_by_name(game_name)  # type: Game
         if not game:
             reply = 'Game {} not found, check your spelling and try again'.format(
                 game_name)
         else:
             reply = game.execute(event, mode=ExecMode.reaction)
     event.guild.members[event.user_id].user.open_dm().send_message(reply)
     event.delete()
Exemplo n.º 5
0
 def code_set_command(self, event, src_type, game):
     """Sets join or start source for a game"""
     game = game.replace('_', ' ')
     game = Game.get_game_by_name(game)  # type: Game
     if not game:
         event.msg.reply(
             'Game not found, check your spelling and try again')
         return
     src = event.codeblock
     if src_type == 'join':
         game.set_exec_code(src)
         event.msg.reply('Okay! Set ```{}``` as join code for {}'.format(
             src, game.name))
     elif src_type == 'start':
         game.set_exec_code(src, exec_type=ExecType.start)
         event.msg.reply('Okay! Set ```{}``` as start code for {}'.format(
             src, game.name))
     else:
         event.msg.reply('Either `!code set join` or `!code set start`')
Exemplo n.º 6
0
 def schedule_command(self, event, game, interval):
     """Sets schedule for a game"""
     game = Game.get_game_by_name(game)
     if not game:
         event.msg.reply(
             'Game not found, check your spelling and try again')
         return
     if interval == 'clear':
         game.clear_interval()
         event.msg.reply('Cleared interval for {}'.format(game.name))
         self.queue_announcements()
         return
     if not game.a_channel or not game.a_message:
         event.msg.reply(
             'Please be sure to set an announcement message and channel first!'
         )
         return
     game.set_interval(interval)
     event.msg.reply('Okay! Set interval {} for {}'.format(
         interval, game.name))
     self.queue_announcements()