async def wrapped_issue_command(self): res = await issue_command(self) if isinstance(res, Command): return CommandList(res) elif isinstance(res, (list, tuple)): return CommandList(*res) elif isinstance(res, CommandList): return res # If no command has been sent, propagate it elif res is None: return None # TODO: stop execution nicely if return value is # incompatible with server else: name = type(self).__name__ print(f'Return value from {name}.issue_command() ' 'is incompatible with server. ' 'Expected Command, tuple or list of Commands, ' 'or a CommandList.') self.loop.stop()
def send_command(self, command): if self.output is None: return command_list = CommandList(command) self.output.write(command_list.to_json().encode('utf-8'))
def __init__(self): logging.basicConfig( format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', level=logging.INFO) self.config = Config() self.updater = Updater(token=self.config.get_config(TOKEN)) self.dispatcher = self.updater.dispatcher self.filter_users = Filters.user(username=Users().get_list_users()) self.rso = ReportSO() self.command_list = CommandList()
def __init__(self, loop=None): self.transport = None self.loop = loop if loop else asyncio.get_event_loop() # asynchronous queue self.queue = asyncio.Queue() # asynchronous methods asyncio.ensure_future(self._send_from_queue()) asyncio.ensure_future(self.join_game()) asyncio.ensure_future(self.start_game()) # asynchronous events self._on_join = asyncio.Event() self._on_start = asyncio.Event() # Billionaire bot variables self.received_cmds = CommandList() self.id = '' self.hand = CardLocation()
def __init__(self): self.command_list = CommandList()
is_admin = database.is_admin(message.from_user.id) help_str = "" for command in commands: if not command.is_admin_command or (command.is_admin_command and is_admin): help_str += "/{} - {}\n".format(command.command, command.short_description) bot.send_message(message.chat.id, help_str) help_command = Command("help", "Список доступных команд", do=do_help) commands = CommandList(start_command, help_command, users_command, set_admin_command, check_photos_command, # Command("get_image_info", "Получить информацию об изображении", do=do_get_image_info, # need_answer=True, # echo=answer_get_image_info), # Command("publish", "Опубликовать контент немедленно", do=do_publish, is_admin_command=True), # Command("words", "Список слов", is_admin_command=True, do=do_words), # Command("addword", "Добавить слово вида 'окнО'", do=do_addword, is_admin_command=True, # need_answer=True, echo=answer_addword), # Command("addwordsfromfile", "Добавить слова из файла", do=do_addwordsfromfile, # is_admin_command=True, need_answer=True, echo=answer_addwordsfromfile), publish_command, execute_command, remove_keyboard_command # Command("exercise", "Начать тест на ударения", do=do_exercise, need_answer=True, # echo=answer_exercise) )