Beispiel #1
0
    def start(self):
        if 'cancel' in self.message.text 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
        buttons = build_menu('Captions',
                             'Settings',
                             footer_buttons=['Cancel current action'])
        self.message.reply_text('What do you want to do?',
                                reply_markup=ReplyKeyboardMarkup(buttons))
Beispiel #2
0
    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', 'Cancel'))

        self.message.reply_text(
            f'Settings for {self.user_settings.current_channel.name}',
            reply_markup=buttons)
Beispiel #3
0
 def channel_selector_menu(
     self,
     user: UserSettings,
     prefix: str,
     header_buttons: List[InlineKeyboardButton] = None,
     footer_buttons: List[InlineKeyboardButton] = None
 ) -> InlineKeyboardMarkup or None:
     if not user.channels:
         return
     buttons = []
     for channel in user.channels:
         buttons.append(
             InlineKeyboardButton(
                 channel.name,
                 callback_data=f'{prefix}:{channel.channel_id}'))
     return InlineKeyboardMarkup(
         build_menu(*buttons,
                    header_buttons=header_buttons,
                    footer_buttons=footer_buttons))
Beispiel #4
0
    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_id = channel_id
        self.user_settings.state = UserSettings.SET_CAPTION

        self.update.callback_query.answer()
        self.message.delete()

        self.message.reply_text(
            f'Now send me the caption you want to have for your channel - '
            f'{self.user_settings.current_channel.name}. \n\nCurrent Caption:\n'
            f'{self.user_settings.current_channel.caption}',
            reply_markup=ReplyKeyboardMarkup(build_menu('Clear', 'Cancel')),
            parse_mode=ParseMode.MARKDOWN)
Beispiel #5
0
 def remove_channel_confirm_dialog(self):
     self.user_settings.state = UserSettings.PRE_REMVOE_CHANNEL
     self.message.reply_text(
         f'Are you sure you want to remove: {self.user_settings.current_channel.name}?',
         reply_markup=ReplyKeyboardMarkup(build_menu('Yes', 'No')))