Esempio n. 1
0
 def startLoop(self):
     self.setup()
     thread.start_new_thread(self.conn.loop, ())
     self.running = True
     self.conn.write({'action':'INFO'})
     while True:
         time.sleep(.03)
         self._specloop()
         inp.retrieve()
         new = Location(loc=self.player.pos)
         if inp.value != ([], []):
             if 'q' in inp.value[0]: self.quit()
             if 'w' in inp.value[0]: new.y -= 1         
             if 'a' in inp.value[0]: new.x -= 1
             if 's' in inp.value[0]: new.y += 1
             if 'd' in inp.value[0]: new.x += 1
             if 't' in inp.value[0]:
                 txt = self.win.input("Talk: ", 0, self.disp.offset, fgcolor=BLUE, callbackfn=self._specloop)
                 if txt: self.conn.write({'action':'ACTION', 'type':'MSG', 'data':txt})
                 self.update = True
             if 'c' in inp.value[0]:
                 txt = self.win.input("Console: ", 0, self.disp.offset, fgcolor=BLUE, callbackfn=self._specloop)
                 if txt:
                     txt = txt.split(' ')
                     if commands.get(txt[0]): 
                         commands.get(txt[0])(txt, self)
                     else: self.conn.write({'action':'ACTION', 'type':'CMD', 'data':' '.join(txt)})
             if new != self.player.pos: self.move(new)
         if self.checkChat():
             self.update = True
         if self.update:
             self.disp.updaterender = True
             self.update = False
Esempio n. 2
0
async def on_message(message):
    parsed_message = message.content.split(" ", 2)
    if parsed_message[0] == bot_trigger:
        if len(parsed_message) > 1:
            await client.send_message(
                message.channel,
                commands.get(parsed_message[1])(
                    parsed_message[2] if len(parsed_message) > 2 else None),
            )
def handle_message(update, context):
    text = update.message.text
    command = commands.get(text)
    if command:
        command(update, context)
    try:
        weights = json.loads(text)
    except JSONDecodeError:
        return
    weighted_sum(update, context, weights)
Esempio n. 4
0
def main(factory: PropertiesProviderFactory, argv: List[str] = sys.argv[1:]):
    args = get_args(argv)
    provider = factory.create(args.toml)
    logger = provider.get_logger()
    logger.info("Py4LO (C) Julien Férard 2016-2022")
    logger.debug("Log Level is: %s", logger.getEffectiveLevel())
    logger.debug("Command line arguments are: %s", args)

    command = commands.get(args.command, args.parameter,
                           provider)
    logger.debug("Command is %s", command)

    command.execute()
Esempio n. 5
0
    async def on_message(self, message):
        if message.author == self.user:
            return

        if message.author.bot:
            return  # Don't respond to bots to prevent potential spam.

        if message.content.startswith('eb!'):
            args = message.content[3:].split(' ')
            from commands import commands
            cmd = commands.get(args[0])
            if cmd is not None:
                await cmd(self, args, message)
Esempio n. 6
0
 def test_non_existing(self):
     executor = commands.get("foo", ["arg1", "arg2"], self.provider)
Esempio n. 7
0
 def test(self):
     executor = commands.get("run", ["arg1", "arg2"], self.provider)