示例#1
0
def usage():
    """
    Calls `p2p.help.usage()` method to print out how to run DHN software from command line.
    """
    try:
        import help
        return help.usage()
    except:
        return ''
示例#2
0
文件: main.py 项目: crazymaik/pyimc
def main():
	config = Config()
	bus = dbus.SessionBus()

	pidgin = PidginWrapper(bus) if config.pidgin == 'True' else None
	skype = SkypeWrapper(bus) if config.skype == 'True' else None

	if len(sys.argv) <= 1:
		usage()
		return -1

	action = sys.argv[1]
	args = sys.argv[2:]

	mod = modutils.load_command_module(action)
	if mod == None:
		print "ERROR: Unknown command '%s'" % action
		usage()
		return -1

	mod.execute(config, pidgin, skype, args)

	return 0
示例#3
0
            set_scroll(10)
        if key == curses.KEY_NPAGE:
            set_scroll(-10)
        if key == curses.KEY_HOME:
            # size of the window
            goto.scroll_to_top()
        KEY_ENTER = 10
        if key == KEY_ENTER or key == curses.KEY_END:
            goto.scroll_to_bottom()

    globvar.quitting = True


if __name__ == "__main__":
    if len(sys.argv) < 2:
        help.usage()
        sys.exit(1)

    profile = sys.argv[2:] or []
    if len(profile) == 2 and profile[0] == '-f':
        profile.load_profile_from_file(profile[1])

    curses.initscr()
    curses.start_color()

    curses.cbreak()
    curses.noecho()
    curses.curs_set(0)

    colors.set_colors()
示例#4
0
async def on_message(message):
    
    #Do not parse our own messages
    if message.author == client.user:
        return

    #Command switch, parse the message and send the parameters
    #parse message into tokens
    tokens = message.content.split(' ')


    #Command Switch
    ###########################################################
    #Handle Public commands
    ###########################################################

    #Usage message
    if tokens[0] == '!help':
        await message.channel.send(embed=help.usage())

    #List/Search builds
    elif tokens[0] == '!builds':
        embed = builds.builds(tokens[1:])
        await message.channel.send(embed=embed)

    ###########################################################
    #Handle Private commands
    ###########################################################

    #User is DMing the bot
    elif(isinstance(message.channel, discord.DMChannel)):

        if(tokens[0] == '!register'):
            sessions.update_item(
                Key = {
                    'id' : message.author.id
                },
                UpdateExpression = 'SET command = :val1',
                ExpressionAttributeValues = {
                    ':val1' : 'register'
                } 
            )

        response = sessions.get_item(
            Key = {
                'id' : message.author.id
            }
        )
        
        if('Item' in response):
            if(response['Item']['command'] == 'register'):
                embed = await registration.registrationSwitch(message)
                await message.channel.send(embed = embed)
        else:
            #Unknow command, why are you whispering the bot?
            embed = discord.Embed(title='Unexpect Input', \
                description="\'%s\' was unexpected." % (message.content), color=0xFF0000)
            #echo command
            await message.channel.send(embed = embed)
            #send usage
            await message.channel.send(embed = help.usage())

    ###########################################################
    #Handle Error Messages
    ###########################################################

    #Functionally required with an added bonus of anit-spam, command must be DMed
    elif tokens[0] == '!register':
        embed = discord.Embed(title='Private Command', description="To prevent spam, the \'%s\' command can only be used through a direct message to the bot." % (tokens[0]), color=0xFF0000)
        await message.channel.send(embed = embed)