def pre_set_caption_alpha(self): member = self.bot.get_chat_member( chat_id=self.user_settings.current_channel.channel_id, user_id=self.user.id) if not member.can_change_info and not member.status == member.CREATOR: self.message.reply_text( 'You must have change channel info permissions ' 'to change the default image caption.') return self.user_settings.state = UserSettings.SET_IMAGE_CAPTION_ALPHA if self.update.callback_query: self.update.callback_query.answer() self.message.delete() message = get_template( 'commands/auto_image_caption/opacity.html').render({ 'channel_link': self.user_settings.current_channel.link, 'current_alpha': self.user_settings.current_channel.image_caption_alpha, }) self.message.reply_html(message, reply_markup=ReplyKeyboardMarkup( build_menu('100', '75', '50', '25', 'Back', 'Cancel', cols=4), one_time_keyboard=True))
def pre_set_caption(self): member = self.bot.get_chat_member( chat_id=self.user_settings.current_channel.channel_id, user_id=self.user.id) if not member.can_change_info and not member.status == member.CREATOR: self.message.reply_text( 'You must have change channel info permissions ' 'to change the default image caption.') return self.user_settings.state = UserSettings.SET_IMAGE_CAPTION self.update.callback_query.answer() self.message.delete() message = get_template('commands/auto_caption/new.html').render({ 'channel_name': self.user_settings.current_channel.name, 'current_caption': self.user_settings.current_channel.image_caption, }) self.message.reply_html(message, reply_markup=ReplyKeyboardMarkup( build_menu('Clear', 'Back', 'Cancel'), one_time_keyboard=True))
def pre_set_caption(self): channel_id = int(self.update.callback_query.data.split(':')[1]) member = self.bot.get_chat_member(chat_id=channel_id, user_id=self.user.id) if not member.can_change_info and not member.status == member.CREATOR: self.message.reply_text( 'You must have change channel info permissions to change the default caption.' ) return self.user_settings.current_channel = ChannelSettings.objects.get( channel_id=channel_id, bot_token=self.bot.token) self.user_settings.state = UserSettings.SET_CAPTION self.update.callback_query.answer() self.message.delete() message = get_template('commands/auto_caption/new.html').render({ 'channel_name': self.user_settings.current_channel.name, 'current_caption': mark_safe(self.user_settings.current_channel.caption), }) self.message.reply_html(message, reply_markup=ReplyKeyboardMarkup( build_menu('Clear', 'Cancel')))
def channel_settings_menu(self): channel_id = int(self.update.callback_query.data.split(':')[1]) self.message.delete() self.user_settings.current_channel_id = channel_id self.user_settings.state = UserSettings.CHANNEL_SETTINGS_MENU buttons = ReplyKeyboardMarkup( build_menu('Remove', 'Remove Forwarders', footer_buttons=['Back', 'Cancel'])) self.message.reply_text( f'Settings for {self.user_settings.current_channel.name}', reply_markup=buttons)
def remove_channel_confirm_dialog(self): self.user_settings.state = UserSettings.PRE_REMOVE_CHANNEL channel = self.user_settings.current_channel link = channel.chat.link if channel.chat else channel.channel_title self.message.reply_text( f'Are you sure you want to remove {link}?\n' f'<b>Attention:</b>\n' f'In case this channel is not managed by an another admin via this bot, the not will:\n' f'- Stop adding captions\n' f'- Stop adding image captions\n' f'- Stop adding reactions\n' f'- Still be updating reactions as long as the bot is in the channel\n', reply_markup=ReplyKeyboardMarkup(build_menu('Yes', 'No')), parse_mode=ParseMode.HTML, disable_web_page_preview=True)
def start(self): if self.update.callback_query: self.update.callback_query.answer() self.message.delete() elif 'start' in self.message.text: self.message.reply_html(get_template('commands/manager/start.html').render()) if self.message.text.lower() in ['cancel', 'home', 'reset'] and self.user_settings.state != UserSettings.IDLE: self.message.reply_text('Current action was cancelled') self.user_settings.current_channel = None self.user_settings.state = UserSettings.IDLE header, middle, footer = BaseCommand._start_buttons buttons = build_menu(*middle, header_buttons=header, footer_buttons=footer) self.message.reply_text('What do you want to do?', reply_markup=ReplyKeyboardMarkup(buttons))
def pre_image_caption_font(self): current_font = self.user_settings.current_channel.image_caption_font if current_font == 'default': current_font = Fonts.get_font().id buttons = [] for font_id, font in Fonts.available_fonts.items(): txt = font.name if font_id == current_font: txt = f'[{txt}]' buttons.append( InlineKeyboardButton( txt, callback_data=f'set_image_caption_font:{font_id}')) menu = build_menu(*buttons, cols=2, footer_buttons=[ InlineKeyboardButton( 'Back', callback_data='next_action:') ]) self.message.edit_text('Which font do you want?', reply_markup=InlineKeyboardMarkup(menu))