def health():
    ret = {}
    for key, server in servers.items():
        ret[key] = check_alive(server)
    all_healthy = all(ret.values())
    if not all_healthy:
        return ret, 503
    return ret
Beispiel #2
0
async def on_ready():
    print("Connected to Discord as " + discord_bot.user.name)
    print("Number of servers: {0}".format(len(servers)))

    for _, v in servers.items():
        print(v['channels']['dev'])
        if (v['channels']['dev']):
            await discord_bot.send_message(
                discord_bot.get_channel(v['channels']['dev']),
                "FangliBot started!")
Beispiel #3
0
 def mset(self, mapping):
     """
     Sets each key in the ``mapping`` dict to its corresponding value
     """
     servers = {}
     for key, value in mapping.items():
         server_name = self.get_server_name(key)
         servers.setdefault(server_name, [])
         servers[server_name].append((key, value))
     for name, items in servers.items():
         self.connections[name].mset(dict(items))
     return True
Beispiel #4
0
 def mset(self, mapping):
     """
     Sets each key in the ``mapping`` dict to its corresponding value
     """
     servers = {}
     for key, value in mapping.items():
         server_name = self.get_server_name(key)
         servers.setdefault(server_name, [])
         servers[server_name].append((key, value))
     for name, items in servers.items():
         self.connections[name].mset(dict(items))
     return True
Beispiel #5
0
def is_pug_channel(channel):
    for _, v in servers.items():
        if channel.id == v['channels']['pug']:
            return True
    return False
Beispiel #6
0
                    ply.mention if should_mention else ply.display_name))

        # Red
        msg.append("\n__Team Red__(**{0}**):  ".format(
            self.captain_red.display_name))
        for ply in self.players_red:
            if ply != self.captain_red:
                msg.append("*{0}*  ".format(
                    ply.mention if should_mention else ply.display_name))

        return ''.join(msg)


# Setup pugs
pugs = {}
for _, server in servers.items():
    for k, v in server['pugs'].items():
        pug_id = server['id'] + '-' + k
        pugs[pug_id] = Pug(server['id'], k, v['players_needed'])


def is_pug_channel(channel):
    for _, v in servers.items():
        if channel.id == v['channels']['pug']:
            return True
    return False


@discord_bot.group(pass_context=True)
async def pug(ctx):
    """Category for pug-related commands"""