Ejemplo n.º 1
0
async def nominate(Demobot, msg, reg):
    if nested_get(msg.server.id, "roles", 'leader') in msg.author.roles:
        aliases = {'judge': 'judge', 'j': 'judge', 'jd': 'judge'}
        if reg.group('pos') not in aliases:
            return
        else:
            role = nested_get(msg.server.id, "roles",
                              aliases[reg.group('pos')])

        type = "nomination"
        propchan = nested_get(msg.server.id, "channels", 'proposals')
        newm = await Demobot.send_message(propchan, '\u200D')
        content = "make " + reg.group("user") + " a " + role.mention + "."
        em = Embed(title=type.title() + ' Proposal',
                   description=('ID: %s\n\n%s' % (newm.id, content)),
                   colour=nested_get(msg.server.id, "roles",
                                     "representative").colour)
        newm = await Demobot.edit_message(newm,
                                          nested_get(msg.server.id, "roles",
                                                     "representative").mention,
                                          embed=em)

        propobj = Nomination(newm, type, content, msg.author, msg.mentions[0],
                             role)
        nested_set(propobj, msg.server.id, 'messages', 'proposals', newm.id)
        await Demobot.add_reaction(newm, "­ЪЉЇ")
        await Demobot.add_reaction(newm, "­ЪЉј")
        await Demobot.add_reaction(newm, "­Ъци")
        await save(None, None, None, overrideperms=True)
    else:
        await Demobot.send_message(msg.channel, "You are not leader!")
Ejemplo n.º 2
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!")
Ejemplo n.º 3
0
async def role(Demobot, msg, reg):
    perms = msg.channel.permissions_for(msg.author)
    if perms.manage_server:
        aliases = {
            'rep': 'representative',
            'representative': 'representative',
            'leader': 'leader',
            'president': 'leader',
            'pres': 'leader',
            'judge': 'judge',
            'enforcer': 'enforcer',
            'enf': 'enforcer',
            'prisoner': 'prisoner',
            'criminal': 'prisoner',
            'default': 'citizen',
            'citizen': 'citizen'
        }
        if reg.group('name') not in aliases:
            return
        if reg.group('role') is not '@everyone':
            nested_set(
                msg.role_mentions[msg.raw_role_mentions.index(
                    reg.group('roleid'))], msg.server.id, "roles",
                aliases[reg.group('name').lower()])
        else:
            nested_set(msg.server.default_role, msg.server.id, "roles",
                       aliases[reg.group('name').lower()])
        await Demobot.send_message(
            msg.channel, 'The ' + aliases[reg.group('name').lower()] +
            ' role for this server is now set to ' +
            nested_get(msg.server.id, "roles",
                       aliases[reg.group('name').lower()]).mention + '.')
        await save(None, None, None, overrideperms=True)
Ejemplo n.º 4
0
async def propose(Demobot, msg, reg):
    if msg.channel == nested_get(msg.server.id, "channels", "politics"):
        aliases = {
            "rule": "rule",
            "law": "rule",
            "mod": "moderation",
            "moderation": "moderation",
            "amend": "amendment",
            "amendment": "amendment",
            "override": "override",
            "rewrite": "override"
        }
        if reg.group("type"):
            if reg.group("type") not in aliases:
                return
            type = aliases[reg.group("type").lower()]
        else:
            type = "rule"
        propchan = nested_get(msg.server.id, "channels", 'proposals')
        newm = await Demobot.send_message(propchan, '\u200D')
        em = Embed(
            title=type.title() + ' Proposal',
            description=('ID: %s\n\n%s' % (newm.id, reg.group("content"))),
            colour=nested_get(msg.server.id, "roles", "representative").colour)
        newm = await Demobot.edit_message(newm,
                                          nested_get(msg.server.id, "roles",
                                                     "representative").mention,
                                          embed=em)

        propobj = Proposal(newm, type, reg.group('content'), msg.author)
        nested_set(propobj, msg.server.id, 'messages', 'proposals', newm.id)
        await Demobot.add_reaction(newm, "­ЪЉЇ")
        await Demobot.add_reaction(newm, "­ЪЉј")
        await Demobot.add_reaction(newm, "­Ъци")
        await save(None, None, None, overrideperms=True)
Ejemplo n.º 5
0
async def imprison(Demobot, user, reason):
    await Demobot.add_roles(user, nested_get(user.server.id, "roles", "prisoner"))
    gotten = nested_get(user.server.id, "prisoners", user.id)
    if not gotten:
        gotten = 12
    gotten = min(gotten*5, 86400)
    nested_set(gotten, user.server.id, "prisoners", user.id)
    duration = timedelta(seconds=gotten)
    await Demobot.send_message(user, "You have been imprisoned "+reason+"\nYou should be released in "+str(duration)+'.')
    await asyncio.sleep(gotten)
    await unimprison(Demobot, user)
Ejemplo n.º 6
0
async def makeAdmin(Demobot, msg, reg):
    if (await is_mod(Demobot, msg.author)):
        r = nested_get(msg.server.id, "roles", "admin")
        if not r:
            r = await Demobot.create_role(
                msg.server,
                name="admin",
                permissions=msg.server.get_member(
                    Demobot.user.id).server_permissions)
            nested_set(r, msg.server.id, "roles", "admin")
        await Demobot.move_role(
            msg.server, r,
            msg.server.get_member(Demobot.user.id).top_role.position - 1)
        await Demobot.add_roles(msg.mentions[0], r)
        await save(None, None, None, overrideperms=True)
Ejemplo n.º 7
0
async def channel(Demobot, msg, reg):
    perms = msg.channel.permissions_for(msg.author)
    if perms.manage_server:
        aliases = {
            'announcements': 'announcements',
            'announcement': 'announcements',
            'elections': 'elections',
            'proposals': 'proposals',
            'prop': 'proposals',
            'amendments': 'amendments',
            'amendment': 'amendments',
            'amend': 'amendments',
            'complaint': 'complaints',
            'complaints': 'complaints',
            'politics-discussion': 'politics',
            'politics discussion': 'politics',
            'political discussion': 'politics',
            'politics': 'politics',
            'rules': 'rules',
            'rule': 'rules',
            'law': 'rules',
            'laws': 'rules',
            'passed proposals': 'rules',
            'enforcer todo': 'enf-todo',
            'todo': 'enf-todo',
            'election': 'elections'
        }
        if reg.group('name') not in aliases:
            return
        nested_set(Demobot.get_channel(reg.group('channelid')), msg.server.id,
                   "channels", aliases[reg.group('name').lower()])
        await Demobot.send_message(
            msg.channel, 'The ' + aliases[reg.group('name').lower()] +
            ' channel for this server is now set to ' +
            nested_get(msg.server.id, "channels",
                       aliases[reg.group('name').lower()]).mention + '.')
        await save(None, None, None, overrideperms=True)