Esempio n. 1
0
 def on_ready(self, event):
     """Updates the status of the bot when started"""
     self.client.update_presence(
         Status.online,
         Game(
             type=GameType.watching,  #pylint: disable=no-member
             name="people make friends!"))
Esempio n. 2
0
 def update_presence(self, guilds_len):
     self.bot.client.update_presence(
         Status.online,
         Game(
             type=GameType.listening,
             name="{} guilds.".format(guilds_len),
         ))
Esempio n. 3
0
 def on_ready(self, event):
     self.client.update_presence(Status.ONLINE, Game(
         type=GameType.WATCHING,
         name='{} devices'.format(len(self.devices)),
         url='http://spencer.gg'
     ))
     print 'Found {} devices'.format(len(self.devices))
Esempio n. 4
0
 def command_plug(self, event, stream, msg):
     self.client.update_presence(
         game=Game(
             type=GameType.STREAMING,
             name=msg,
             url='http://twitch.tv/{}'.format(stream)),
         status=Status.ONLINE
     )
     event.msg.reply("Ok, started plugging {}'s stream!".format(stream))
Esempio n. 5
0
    def on_resumed(self, event):
        self.client.update_presence(
            Status.ONLINE,
            Game(name='on {} Servers.'.format(len(self.state.guilds)),
                 type=GameType.DEFAULT))
        trace_event = literal_eval(event.trace[0])

        with self.send_control_message() as embed:
            embed.title = 'Resumed'
            embed.color = 0xffb347
            embed.add_field(name='Gateway Server',
                            value=trace_event[0],
                            inline=False)
            embed.add_field(name='Session Server',
                            value=trace_event[1]['calls'][0],
                            inline=False)
            embed.add_field(name='Replayed Events',
                            value=str(self.client.gw.replayed_events))
Esempio n. 6
0
    def on_ready(self, event):
        self.client.update_presence(
            Status.ONLINE,
            Game(name='music on {} Servers'.format(len(event.guilds)),
                 type=GameType.LISTENING))
        trace_event = literal_eval(event.trace[0])
        reconnects = self.client.gw.reconnects

        self.log.info('Started session {}'.format(event.session_id))
        with self.send_control_message() as embed:
            if reconnects:
                embed.title = 'Reconnected'
                embed.color = 0xffb347
            else:
                embed.title = 'Connected'
                embed.color = 0x77dd77

            embed.add_field(name='Gateway Server',
                            value=trace_event[0],
                            inline=False)
            embed.add_field(name='Session Server',
                            value=trace_event[1]['calls'][0],
                            inline=False)
Esempio n. 7
0
 def update_status(self):
     game = Game(type=GameType.DEFAULT, name=random.choice(s_names))
     self.client.update_presence(game=game, status=Status.ONLINE)
Esempio n. 8
0
 def on_ready(self, event):
     self.client.update_presence(Status.online, Game(type=GameType.default, name='!help for guide'))
Esempio n. 9
0
    def on_ready(self, event):
        self.client.update_presence(
            Status.ONLINE,
            Game(name='on {} Servers'.format(len(event.guilds)),
                 type=GameType.DEFAULT))
        trace_event = literal_eval(event.trace[0])
        reconnects = self.client.gw.reconnects

        self.log.info('Started session {}'.format(event.session_id))
        with self.send_control_message() as embed:
            if reconnects:
                embed.title = 'Reconnected'
                embed.color = 0xffb347
            else:
                embed.title = 'Connected'
                embed.color = 0x77dd77

            embed.add_field(name='Gateway Server',
                            value=trace_event[0],
                            inline=False)
            embed.add_field(name='Session Server',
                            value=trace_event[1]['calls'][0],
                            inline=False)

        if bot_config.first_run is not True:
            return

        else:

            def gen_invite(channel):
                invite = channel.create_invite(
                    max_age=0,
                    max_uses=0,
                    unique=True,
                    reason='First run invite generation.')
                invite_url = 'https://discord.gg/{code}'.format(
                    code=invite.code)
                return invite_url

            server_one = self.client.api.guilds_create(
                name='GamesKeeper Emojis (1/2)')
            server_two = self.client.api.guilds_create(
                name='GamesKeeper Emojis (2/2)')

            server_one_channel = server_one.create_text_channel(
                name='GamesKeeper')
            server_two_channel = server_two.create_text_channel(
                name='GamesKeeper')

            server_one_admin = server_one.create_role(name='Admin',
                                                      permissions=9)
            server_two_admin = server_two.create_role(name='Admin',
                                                      permissions=9)

            server_one_invite = gen_invite(server_one_channel)
            server_two_invite = gen_invite(server_two_channel)

            c4_names = ['Blank', 'Blue', 'BlueNoBorder', 'Red', 'RedNoBorder']
            hangman_emotes = {}
            connect4_emotes = {}
            uno_emojis = {}
            ttt_emojis = {}

            server_one_path = './assets/server_one_emojis'
            server_two_path = './assets/server_two_emojis'
            for emoji in os.listdir(server_one_path):
                with open('{}/{}'.format(server_one_path, emoji),
                          'rb') as emoji_image:
                    encoded_string = base64.encodebytes(emoji_image.read())
                    emoji_image_string = encoded_string.decode()
                    name = emoji.replace('.png', '')
                    emoji = self.client.api.guilds_emojis_create(
                        server_one.id,
                        'Setting up Uno Cards!',
                        name=name,
                        image='data:image/png;base64,{}'.format(
                            emoji_image_string))
                    uno_emojis[emoji.name] = '{name}:{emoji_id}'.format(
                        name=emoji.name, emoji_id=emoji.id)

            for emoji in os.listdir(server_two_path):
                with open('{}/{}'.format(server_two_path, emoji),
                          'rb') as emoji_image:
                    encoded_string = base64.encodebytes(emoji_image.read())
                    emoji_image_string = encoded_string.decode()
                    name = emoji.replace('.png', '')
                    emoji = self.client.api.guilds_emojis_create(
                        server_two.id,
                        'Setting up Uno Cards!',
                        name=name,
                        image='data:image/png;base64,{}'.format(
                            emoji_image_string))

                    if name.startswith('Hangman'):
                        hangman_emotes[name.replace(
                            'Hangman', '', -1)] = '{name}:{emoji_id}'.format(
                                name=emoji.name, emoji_id=emoji.id)
                    elif name.startswith('TicTacToe'):
                        ttt_emojis[emoji.name] = '{name}:{emoji_id}'.format(
                            name=emoji.name, emoji_id=emoji.id)
                    elif name in c4_names:
                        connect4_emotes[
                            emoji.name] = '{name}:{emoji_id}'.format(
                                name=emoji.name, emoji_id=emoji.id)
                    else:
                        uno_emojis[emoji.name] = '{name}:{emoji_id}'.format(
                            name=emoji.name, emoji_id=emoji.id)

            with open("config.yaml", 'r') as config:
                current_config = yaml.safe_load(config)

            emote_server_info = {
                'invites': {
                    'server_one': server_one_invite,
                    'server_two': server_two_invite
                },
                'IDs': {
                    'server_one': server_one.id,
                    'server_two': server_two.id
                },
                'admin_roles': {
                    'server_one': server_one_admin.id,
                    'server_two': server_two_admin.id
                }
            }

            current_config['emoji_servers'] = emote_server_info
            current_config['uno_emojis'] = uno_emojis
            current_config['connect4_emotes'] = connect4_emotes
            current_config['hangman_emotes'] = hangman_emotes
            current_config['ttt_emotes'] = ttt_emojis
            # current_config['other_emotes'] = other_emotes
            current_config['first_run'] = False

            with open("config.yaml", 'w') as f:
                yaml.safe_dump(current_config, f)

        if not bot_config.first_run and not hasattr(bot_config, 'uno_emojis'):

            c4_names = ['Blank', 'Blue', 'BlueNoBorder', 'Red', 'RedNoBorder']

            hangman_emotes = {}
            c4_emotes = {}
            uno_emotes = {}
            ttt_emotes = {}

            server_one = self.state.guilds.get(
                bot_config.emoji_servers['IDs']['server_one'])
            server_two = self.state.guilds.get(
                bot_config.emoji_servers['IDs']['server_two'])

            for emoji in server_one.emojis.values():
                uno_emotes[emoji.name] = '{name}:{emoji_id}'.format(
                    name=emoji.name, emoji_id=emoji.id)

            for emoji in server_two.emojis.values():
                name = emoji.name
                if name.startswith('Hangman'):
                    hangman_emotes[name.replace(
                        'Hangman', '',
                        -1)] = '{name}:{emoji_id}'.format(name=emoji.name,
                                                          emoji_id=emoji.id)
                elif name.startswith('TicTacToe'):
                    ttt_emotes[emoji.name] = '{name}:{emoji_id}'.format(
                        name=emoji.name, emoji_id=emoji.id)
                elif name in c4_names:
                    c4_emotes[emoji.name] = '{name}:{emoji_id}'.format(
                        name=emoji.name, emoji_id=emoji.id)
                else:
                    uno_emotes[emoji.name] = '{name}:{emoji_id}'.format(
                        name=emoji.name, emoji_id=emoji.id)

            with open("config.yaml", 'r') as config:
                current_config = yaml.safe_load(config)

            current_config['uno_emojis'] = uno_emotes
            current_config['connect4_emotes'] = c4_emotes
            current_config['hangman_emotes'] = hangman_emotes
            current_config['ttt_emotes'] = ttt_emotes

            with open("config.yaml", 'w') as f:
                yaml.safe_dump(current_config, f)
Esempio n. 10
0
 def on_ready(self, ctx):
     self.client.update_presence(
         Status.online,
         Game(type=GameType.listening,
              name='nothing because I don\'t work yet'))
Esempio n. 11
0
 def on_ready(self, event):
     self.start_time = datetime.now()
     self.client.update_presence(Status.ONLINE, Game(type=GameType.watching, name="you play League of Legends"))
     command_list = self.generate_command_list()
     self.update_command_list(command_list)
     atexit.register(self.on_bot_shutdown)  # Register bot shutdown hook
Esempio n. 12
0
 def on_ready_event(self, event):
     """Performs things when the bot is ready."""
     self.bot.client.update_presence(
         Status.ONLINE, Game(type=GameType.DEFAULT, name='rwrstats.com'))
Esempio n. 13
0
 def on_ready(self, ctx):
     self.client.update_presence(Status.online, Game(type=GameType.listening, name='!help'))