示例#1
0
async def running(Demobot, msg, reg):
    if nested_get(msg.server.id, "roles", 'citizen') in msg.author.roles:
        aliases = {
            'rep': 'representative',
            'representative': 'representative',
            'ld': 'leader',
            'pres': 'leader',
            'president': 'leader',
            'leader': 'leader'
        }
        if reg.group('pos') not in aliases:
            return
        dmm = await Demobot.send_message(
            msg.author,
            "DM me a description for " + aliases[reg.group('pos')] + ".")
        m = await Demobot.wait_for_message(timeout=600,
                                           author=msg.author,
                                           channel=dmm.channel)
        if not m:
            m = "*No description given*"
        else:
            m = m.content
        nested_pop(msg.server.id, 'elections', aliases[reg.group('pos')],
                   msg.author.id)
        nested_set(Candidate(m, msg.author.id), msg.server.id, 'elections',
                   aliases[reg.group('pos')], msg.author.id)
        await Demobot.send_message(msg.author, "You are now running.")
        await save(None, None, None, overrideperms=True)
    else:
        await Demobot.send_message(msg.channel, "You must be a citizen!")
示例#2
0
async def global_delete_data(Demobot, msg, reg):
    if msg.author.id == (await get_owner(Demobot)).id:
        keys = reg.group('path').split()
        if isinstance(nested_get(*keys[:-1]), dict):
            nested_pop(*keys)
        elif isinstance(nested_get(*keys[:-1]), list):
            nested_remove(keys[-1], *keys[:-1])
        await save(None, None, None, overrideperms=True)
示例#3
0
async def delete_data(Demobot, msg, reg):
    if (await is_mod(Demobot, msg.author)):
        keys = [msg.server.id] + reg.group('path').split()
        if isinstance(nested_get(*keys[:-1]), dict):
            nested_pop(*keys)
        elif isinstance(nested_get(*keys[:-1]), list):
            nested_remove(keys[-1], *keys[:-1])
        await save(None, None, None, overrideperms=True)
示例#4
0
async def cancel(Demobot, msg, reg):
    if reg.group('num') in nested_get(msg.server.id, 'messages',
                                      'proposals').keys():
        prop = nested_get(msg.server.id, 'messages', 'proposals',
                          reg.group('num'))
        if not prop.author == msg.author:
            await Demobot.send_message(msg.channel,
                                       'You didn\'t create that prop!')
            return
        em = Embed(title=prop.tt.title() + ' Proposal',
                   description='%s\n\n%s\n\n*(Canceled)*' %
                   (prop.msg.id,
                    '~~' + '~~\n~~'.join(prop.content.splitlines()) + '~~'),
                   colour=nested_get(msg.server.id, "roles",
                                     "representative").colour)
        await Demobot.edit_message(prop.msg,
                                   nested_get(msg.server.id, "roles",
                                              "representative").mention,
                                   embed=em)
        await Demobot.clear_reactions(prop.msg)
        nested_pop(msg.server.id, 'messages', 'proposals', reg.group('num'))