def settings(callback, **kwargs): callback(text=_('settings_text').format( _('enabled') if kwargs['print_raw'] else _('disabled')), reply_markup=InlineKeyboardMarkup([[ InlineKeyboardButton(_('print_raw'), callback_data='print_raw') ], [InlineKeyboardButton(_('back'), callback_data='back')]]))
def paste(self, bot, update): bot_user = self.get_user(update) bot.send_chat_action(chat_id=update.message.chat_id, action=ChatAction.TYPING) _source = Source(source_source=update.message.text, source_name='Untitled', source_lang='auto', source_bot_user=bot_user, source_bot=True) try: _source.save() _source.source_alias = hashlib.md5(str( _source.id).encode()).hexdigest()[:8] _source.save() text = _('paste_message').format( prepare_source_link(_source.source_alias)) update.message.reply_text(text) except Error: update.message.reply_text(_('something_went_wrong'))
def start(callback, **kwargs): callback(text=_('start_message'), reply_markup=InlineKeyboardMarkup( [[InlineKeyboardButton(_('list'), callback_data='list')], [ InlineKeyboardButton(_('settings'), callback_data='settings') ]]))
def list(self, bot, update): bot_user = self.get_user(update) bot_user.bot_user_state = Dialog.LIST.name bot_user.save() query = update.callback_query query.answer() text = _('paste_list') sources = Source.objects.all().filter(source_bot_user=bot_user) text = text.format('\n'.join( [prepare_source_link(source.source_alias) for source in sources])) Dialog.LIST.execute(query.edit_message_text, text=text)
def list(callback, **kwargs): callback(text=kwargs['text'], reply_markup=InlineKeyboardMarkup( [[InlineKeyboardButton(_('back'), callback_data='back')]]))