예제 #1
0
    def __call__(self, parser, namespace, values, option_string = None):
        bot_data = BotData.from_context(self._context)
        bot = Dispatcher.get_instance().bot

        text = []
        for var_id in bot_data.pending_forms:
            user_data = UserData.by_id(var_id)
            text.append(f'{var_id} ({user_data.mention()})')
        text = 'Список анкет: ' + ', '.join(text)
        bot.sendMessage(self._update.effective_chat.id, text)
예제 #2
0
    def __call__(self, parser, namespace, values, option_string = None):
        user_data = UserData.by_id(int(vars(namespace)['id'][0]))
        bot_data = BotData.from_context(self._context)

        logger.debug('Trying to reject form..')
        user_data.status = FormStatus.RETURNED
        bot_data.pending_forms.remove(user_data.id)
        user_data.note = ' '.join(values)

        new_conv_status(user_data.id)
        logger.info(f'Form was rejected: {str(user_data)}')
예제 #3
0
    def __call__(self, parser, namespace, values, option_string = None):
        user_data = UserData.by_id(int(values[0]))
        bot_data = BotData.from_context(self._context)
        bot = Dispatcher.get_instance().bot

        if not bot_data.dating_channel:
            raise CommandError('Не указан канал для публикации!')

        logger.debug('Trying to post form..')
        try:
            channel = ChatData.by_id(bot_data.dating_channel)
        except MissingDataError:
            channel = ChatData(bot.getChat(bot_data.dating_channel))
        finally:
            channel.send_form(user_data)

        bot_data.pending_forms.remove(user_data.id)
        user_data.status = FormStatus.PUBLISHED

        new_conv_status(user_data.id)
        logger.info(f'Form was posted: {str(user_data)}')
예제 #4
0
    def __call__(self, parser, namespace, values, option_string = None):
        bot_data = BotData.from_context(self._context)

        text = [list(), list()]
        for admin in bot_data.admins:
            try:
                if admin > 0:
                    data = UserData.by_id(admin)
                else:
                    data = ChatData.by_id(admin)
            except MissingDataError:
                logger.warning(f'Unknown ID: {admin}')
                bot_data.admins.remove(admin)
                continue

            item = f'{admin} ({data.mention()})'
            if admin > 0:
                text[0].append(item)
            else:
                text[1].append(item)

        text[0] = 'Список админов: ' + ', '.join(text[0])
        text[1] = 'Список админских чатов: ' + ', '.join(text[1])
        bot_data._bot.send_message(self._update.effective_chat.id, '\n'.join(text))
예제 #5
0
    def __call__(self, parser, namespace, values, option_string = None):
        user_data = UserData.by_id(int(vars(namespace)['id'][0]))

        bot = Dispatcher.get_instance().bot
        bot.send_message(self._update.effective_chat.id, \
                         f"Edit {user_data.mention()}: {' '.join(values)}")
예제 #6
0
    def __call__(self, parser, namespace, values, option_string = None):
        user_data = UserData.by_id(int(values[0]))
        chat_data = ChatData.from_context(self._context)

        chat_data.send_form(user_data, callback_data=f'{str(REMOVE)}{user_data.id}')