Example #1
0
def menu():
        print("\033c")
        print('*************************************')
        print('* * *       1 List items        * * *')
        print('* *         2 Add new item        * *')
        print('*           3 Remove item           *')
        print('* *         4 Complete Item       * *')
        print('* * *       Q Exit Program      * * *')
        print('*************************************')


        choosen = input("Choose an option: ")
        if choosen == "1":
            print()
            print("\033c")
            commands.open_list()
            input("For menu hit enter ")
            menu()
        elif choosen == "2":
            commands.add_new_item()
            menu()
        elif choosen == "3":
            commands.remove()
            print()
            commands.open_list()
            menu()
        elif choosen == "4":
            menu()
        elif choosen == "Q":
            pass
Example #2
0
def main():
    arguments = docopt(command_line)
    if arguments['run']:
        commands.run()
    elif arguments['rm']:
        commands.remove()
    elif arguments['rst']:
        commands.restart_solr()
    else:
        print "Error: No instruction passed"
Example #3
0
def doComm(c, args):
    #we already know c is a valid command!
    if c == "new" and len(args) <= 1:
        return commands.newCheckList(*args)
    elif c == "load" and len(args) == 1:
        return commands.loadCheckList(args[0])
    elif c == "save" and len(args) == 0:
        return commands.saveCheckList()
    elif c == "add" and len(args) in range(1,4): #if 1 <= len(args) <= 3
        return commands.addItem(*args)
    elif c == "remove" and len(args) <= 2:
        return commands.remove(*args)
    elif c == "clean" and len(args) <= 2:
        return commands.clean(*args)
    elif c == "list" and len(args) <= 1:
        return commands.listItems(*args)
    elif c == "info" and len(args) <= 2:
        return commands.getInfo(*args)
    elif c == "edit" and len(args) == 1:
        return commands.getInfo(args[0])
    elif c == "next" and len(args) <= 1:
        return commands.nextDue(*args)
    elif c == "help" and len(args) <= 1:
        return commands.showHelp(*args)
    elif c == 'version':
        return "CheckList v%s" % VERSION
    else:
        return (("Invalid syntax of command '%s'" % c)
                + "\nwith args "+repr(args))
Example #4
0
def doComm(c, args):
    #we already know c is a valid command!
    if c == "new" and len(args) <= 1:
        return commands.newCheckList(*args)
    elif c == "load" and len(args) == 1:
        return commands.loadCheckList(args[0])
    elif c == "save" and len(args) == 0:
        return commands.saveCheckList()
    elif c == "add" and len(args) in range(1, 4):  #if 1 <= len(args) <= 3
        return commands.addItem(*args)
    elif c == "remove" and len(args) <= 2:
        return commands.remove(*args)
    elif c == "clean" and len(args) <= 2:
        return commands.clean(*args)
    elif c == "list" and len(args) <= 1:
        return commands.listItems(*args)
    elif c == "info" and len(args) <= 2:
        return commands.getInfo(*args)
    elif c == "edit" and len(args) == 1:
        return commands.getInfo(args[0])
    elif c == "next" and len(args) <= 1:
        return commands.nextDue(*args)
    elif c == "help" and len(args) <= 1:
        return commands.showHelp(*args)
    elif c == 'version':
        return "CheckList v%s" % VERSION
    else:
        return (("Invalid syntax of command '%s'" % c) + "\nwith args " +
                repr(args))
while run:
    command = input(
        'What would you like to do? Type help for options. ').lower()

    if command == 'help':
        commands.help()

    elif command == 'give':
        hotbar = commands.give(hotbar)

    elif command == 'quit':
        run = commands.quit()

    elif command == 'remove':
        hotbar = commands.remove(hotbar)

    elif command == 'see':
        for s in hotbar:
            print(s)

    elif command == 'add':
        hotbar = commands.add(hotbar)

    elif command == 'creeper':
        aww = 'AWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW'
        man = 'MANNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN'
        print(f'{aww}\n{man}!!!!!!!!')

    elif command == 'random item':
        hotbar = commands.random_item(hotbar)
Example #6
0
# System imports
import sys

# Commands imports
from commands import add, list, remove, edit

try:
    command = sys.argv[1]
except IndexError:
    command = 'list'

if command == 'add': add(' '.join(sys.argv[2:]))
if command == 'remove': remove()
if command == 'list': list()
if command == 'edit':
    edit()
async def on_message(message):
    """looks at every message sent in the server.
    If it is a function command, it is executed.
    Also logs PMs.
    """
    global state
    global channels
    global day
    global setupchannel
    global admin_role
    global stupid_role
    global player_role
    global players
    global stupid
    global admins
    global playMsg
    global pmChannels
    global stChannels
    global pmInit
    global pmCount
    global adv  # asynchronous functions are hard

    msg = message.content
    msgch = message.channel
    msggd = message.guild
    to_send = {}

    if message.author == client.user:
        return
        # Makes the bot ignore its own messages

    if msg.startswith('!setup'):
        setupchannel, to_send = cmd.setup(setupchannel, msgch)

    elif msg.startswith('!add'):
        channels, to_send = cmd.add(msgch, channels)

    elif msg.startswith('!catadd'):
        channels, to_send = cmd.catadd(msgch, channels)

    elif msg.startswith('!servadd'):
        channels, to_send = cmd.servadd(msggd, channels)

    elif msg.startswith('!remove'):
        channels, to_send = cmd.remove(msgch, channels)

    elif msg.startswith('!catrm'):
        channels, to_send = cmd.catrm(msgch, channels)

    elif msg.startswith('!servrm'):
        channels, to_send = cmd.servrm(msgch)

    elif msg.startswith('!pmadd'):
        pmChannels, to_send = cmd.pmadd(message, pmChannels)

    elif msg.startswith('!pmcatadd'):
        pmChannels, to_send = cmd.pmcatadd(admins, msgch, pmChannels)

    elif msg.startswith('!stadd'):
        stChannels, to_send = cmd.pmadd(message, stChannels)

    elif msg.startswith('!stcatadd'):
        stChannels, to_send = cmd.stcatadd(admins, msgch, stChannels)

    elif msg.startswith('!admin'):
        admin_role, admins, to_send = cmd.admin(message, setupchannel,
                                                admin_role, admins)

    elif msg.startswith('!player'):
        player_role, to_send = cmd.player(message, setupchannel, player_role)

    elif msg.startswith('!stupid'):
        stupid_role, to_send = cmd.stupid(message, setupchannel, stupid_role)

    elif msg.startswith('!pladd'):
        players = cmd.pladd(players, message)

    elif msg.startswith('!divide'):
        day, consent, to_send = cmd.divide(message, setupchannel, day,
                                           channels, adv, consent)
        for sinner in stupid:   # reset stupid roles
            updated = sinner.roles
            updated.remove(stupid_role)
            await player.edit(roles=updated, reason=
                              'A new day dawns, and all is forgiven')
        stuipd = []

    elif msg.startswith('!reset'):
        day, to_send = cmd.reset(day, message)

    elif msg.startswith('!tick'):
        day = cmd.tick(day)

    elif msg.startswith('!newgame'):
        if playMsg:
            players = []
            for emj in playMsg.reactions:
                players.append(await reaction.users().flatten())
            players = set(players)
            for user in players:
                await user.add_roles(playerRole, reason = 'Assigned player')
        (day, playMsg, admins,
         preconsent, consent,
         adv, to_send) = cmd.newgame(playMsg, admin_role, players, message)

    elif msg.startswith('!ping'):
        to_send = cmd.ping(msgch, day, channels, players, admins)

    if 'react here to play' in msg.lower():
        playMsg = message
        await setupchannel.send('Advanced newgame available '
                                'once players have reacted')

    if adv and pmChannels:
        if msgch in pmChannels:#what the actual f**k was this supposed to be
            init = msg.author
            allow = discord.PermissionsOverwrite
            deny = discord.PermissionsOverwrite
            allow.send_messages = True
            deny.send_messages = False
            if pmChannels[msgch][0] == init:
                reci = pmChannels[msgch][1]
            elif pmChannels[msgch][1] == init:
                reci = pmChannels[msgch][0]
            else:
                return
            if consent[msgch][0] == 'init':
                if (' ' in msg
                        or len(message.mentions !=1
                        or message.mentions[0] != reci)):
                    await msg.delete()
                    warning = await msgch.send('{}, please only mention '
                                               'the other player.'
                                               .format(init.mention))
                    await warning.delete(delay=5)
                else:
                    pmInit[msgch] = msg
                    consent[msgch] = ['wait', reci]
                    await msgch.set_permissions(init, overwrite=deny)
                    await msgch.set_permissions(reci, overwrite=deny)
            if consent[msgch][0] == 'wait':
                if preconsent[reci][1] == 'given':
                    consent[msgch] = ['given']
                    await msgch.set_permissions(init, overwrite=allow)
                    await msgch.set_permissions(reci, overwrite=allow)
                    await pmInit[msgch].delete()
                    pmInit[msgch] = None
                    consent[msgch] = ['given']

    banned = ['uwu', 'uωu', 'uшu']
    delim = [' ','.',',','-','_','+','|','/']
    clean_msg = msg.lower()
    for char in delim:
        clean_msg = clean_msg.replace(char,'')
    for word in banned:
        if word in clean_msg:
            if not to_send[msgch]:
                to_send[msgch] = []
            to_send[msgch].append('***NO UWU***')
            if stupid_role:
                sinner = message.author
                if sinner not in stupid:
                    await sinner.add_roles(stupid_role, reason='Filthy UWUer')
                    stupid.append(sinner)


    for ch in to_send:
        for ms in to_send[ch]:
            await ch.send(ms)