Пример #1
0
 def add_btn_url(self, ch_id=''):
     if ch_id:
         ch_id = '&ch_id=' + ch_id
     db.set_user_param(self.user_id, 'mode_write',
                       f'open add_btn_name ?type_btn=url' + ch_id)
     bts = [[Button('Отмена', callback_data='remove_yourself None')]]
     return 'Пришли мне ссилку', bts
Пример #2
0
 def write_answer(self, comment_id):
     db.set_user_param(self.user_id, 'mode_write',
                       'open write_answer ?comment_id=' + str(comment_id))
     bts = [[Button('Отмена', callback_data='remove_yourself')]]
     bot.send_message(self.user_id,
                      'Отправь мне текст ответа на етот коментарий:',
                      reply_markup=Markup(bts))
     return False, None
Пример #3
0
    def write_comment(self, post_id):
        db.set_user_param(self.user_id, 'mode_write',
                          'open write_comment ?post_id=' + str(post_id))
        bts = [[Button('Отмена', callback_data='remove_yourself')]]
        bot.send_message(self.user_id,
                         'Отправь мне текст комментария:',
                         reply_markup=Markup(bts))

        return False, None
Пример #4
0
    def bild_post(self, type_post=None):
        db.set_user_param(self.user_id, 'mode_write', 'open add_addition')

        bild_post = buffer.get_bildpost(self.user_id)

        if type_post is None:
            type_post = bild_post.type
        if type_post == 'text':
            set_type = 'photo'
        elif type_post == 'photo':
            set_type = 'text'

        post_btn = []
        for btn in bild_post.buttons:
            if btn['type'] == 'url':
                post_btn.append(Button(btn['text'], url=btn['url']))
            elif btn['type'] == 'reaction':
                post_btn.append(Button(btn['text'], callback_data=btn['data']))
            elif btn['type'] == 'comments':
                post_btn.append(Button(btn['text'], url='google.com'))

        print('===========================================')
        print(post_btn)

        if type_post == 'text':
            bot.send_message(self.user_id,
                             bild_post.photo_url + bild_post.text,
                             reply_markup=Markup([post_btn]),
                             parse_mode='html')
        elif type_post == 'photo':
            bot.send_photo(self.user_id,
                           photo=bild_post.photo.file_id,
                           caption=bild_post.text,
                           reply_markup=Markup([post_btn]),
                           parse_mode='html')

        bts = [[Button('Готово', callback_data='open complete_post')],
               [
                   Button('Добавить кнопку',
                          callback_data='open select_type_btn')
               ]]
        if bild_post.text and bild_post.photo:
            bts.append([
                Button('revers',
                       callback_data='reopen bild_post ?type_post=' + set_type)
            ])

        bot.send_message(self.user_id,
                         '=================',
                         reply_markup=Markup(bts))

        return False, None
Пример #5
0
    def add_ch_final(self, result, ch_id):
        if result == 'NotFound':
            text = 'Такого канала не существует :/\nПовтори еще раз'
        elif result == 'NoAdmin':
            text = 'Я не администратор канала :/\nВидай мне права и повтори еще раз'
        elif result == 'ChannelExists':
            text = 'Этот канал уже добавлен'
        elif result == 'Added':
            db.set_user_param(self.user_id, 'mode_write', 'off')
            bot.send_message(self.user_id, 'Добавляю канал...')
            time.sleep(2)
            self.config_btn(self.msg, ch_id)

        return text, [[Button('Назад', callback_data='open ch_list')]]
Пример #6
0
    def config_btn(self, ch_id):
        buttons, comments_on = db.get_buttons_channel(ch_id=ch_id)
        db.set_user_param(self.user_id, 'mode_write',
                          f'open sort_buttons ?ch_id={ch_id}')

        bts = buttons.get_tg_bts(markup=False, config=True, ch_id=ch_id)

        bts.append([
            Button('Назад', callback_data=f'open ch_setting ?ch_id={ch_id}'),
            Button('Добавить',
                   callback_data=f'open select_type_btn ?ch_id={ch_id}')
        ])
        print(bts)
        return 'Config buttons', bts
Пример #7
0
    def ch_list(self):
        db.set_user_param(self.user_id, 'mode_write', 'off')

        channels = db.get_all_ch(self.user_id)
        bts = [[Button(' Назад', callback_data='open main_menu')]]

        if channels:
            bts[0].append(Button(' Добавить', callback_data='open add_ch'))
            for ch in channels:
                try:
                    ch_name = bot.get_chat(ch).title
                except:
                    ch_name = ' | No admin'
                bts.append([
                    Button(ch_name,
                           callback_data='open ch_setting ?ch_id=' + str(ch)),
                ])
        else:
            bts.append([Button(' Добавить', callback_data='open add_ch')])
        return 'List channel: ', bts
Пример #8
0
    def add_btn_name(self, type_btn, ch_id=''):
        if ch_id:
            ch_id = '&ch_id=' + ch_id

        if type_btn == 'url':
            text = 'Пришли мне натпись на кнопке'
            url = f'&url={self.msg.text}'
        elif type_btn == 'reaction':
            text = 'Пришли мне натпись на кнопке с {count} где будет количество'
            url = ''
        elif type_btn == 'comments':
            text = 'Пришли мне натпись на кнопке с {count} где будет количество комментариев'
            url = ''

        db.set_user_param(
            self.user_id, 'mode_write',
            f'open create_button ?type_btn={type_btn}' + url + ch_id)
        bts = [[Button('Отмена', callback_data='remove_yourself None')]]

        return text, bts
Пример #9
0
 def add_ch(self):
     db.set_user_param(self.user_id, 'mode_write', 'open add_channel')
     return 'Видай мне права администратора и пришли силку или username канала', [
         [Button('Назад', callback_data='open ch_list')]
     ]
Пример #10
0
 def add_post(self):
     db.set_user_param(self.user_id, 'mode_write', 'open add_post ')
     btn = [[Button('Отмена', callback_data='open main_menu')]]
     return 'ОТправь мне текст или изображение', btn