Example #1
0
    def stat_start_menu():
        kb = [[
            Button("{} Статистика по вечерам".format(em("")), callback_data="")
        ], [Button("{} Статистика по играм".format(em("")), callback_data="")],
              [Button("{} Поменять город".format(em("")), callback_data="")]]

        return Markup(kb)
Example #2
0
 def main_menu(self):
     bts = [[
         Button('Создать пост', callback_data='open add_post'),
     ], [
         Button("Список каналов", callback_data='open ch_list'),
     ]]
     return 'Main menu', bts
Example #3
0
def pelis():
    buttons = [[
        Button("🎟️ IMDB", callback_data="get_movie_imdb"),
        Button("🎬️ Trailer", callback_data="get_movie_youtube"),
        Button("🍿 Torrent", callback_data="get_movie_torrent"),
    ]]
    return InlineKeyboardMarkup(buttons)
Example #4
0
def repeat_interval_keyboard():
    buttons = [[
        Button('Semanalmente', callback_data=MEETING_PERIOD.format("Weekly")),
        Button('Bisemanalmente',
               callback_data=MEETING_PERIOD.format("Biweekly")),
        Button('Mensualmente', callback_data=MEETING_PERIOD.format("Monthly")),
    ], [Button('🚫 Cancel', callback_data=CANCEL)]]
    return InlineKeyboardMarkup(buttons)
Example #5
0
    def confirm_del(self, comment_id):
        data_yes = f'comment delete ?comment_id={comment_id}'

        bts = [[
            Button('Yes', callback_data=data_yes),
            Button('No',
                   callback_data="open comment ?comment_id=" + comment_id)
        ]]
        return 'Delete this comment?', bts
Example #6
0
def serie_main_keyboard(imdb_id):
    buttons = [
        [
            Button('Latest episodes', callback_data=LATEST_EPISODES),
            Button('Load all episodes', callback_data=LOAD_EPISODES),
        ],
        [Button('🎟️ IMDB', url=IMDB_TT_LINK.format(imdb_id))],
    ]
    return InlineKeyboardMarkup(buttons)
Example #7
0
 def del_btn(self, btn_id, ch_id):
     print(btn_id, ch_id)
     bts = [[
         Button(
             'del',
             callback_data=f'delete button ?btn_id={btn_id}&ch_id={ch_id}'),
         Button('cancel', callback_data='remove_yourself')
     ]]
     return 'Delete button?', bts
Example #8
0
def see_details_or_aproximate_by_other():
    buttons = [
        [
            Button('🔍 Detalle', callback_data=DETALLE),
            Button('🖇 Exportar', callback_data=EXPORT_CSV),
        ],
        [Button('🔁 Cambiar Método ', callback_data=OTHER_METHOD)],
        [Button('🚪 Salir', callback_data=SALIR)],
    ]
    return InlineKeyboardMarkup(buttons)
Example #9
0
 def start_user():
     return Markup([[
         Button("{0} Открыть статистику".format(em(":open_file_folder:")),
                callback_data="UserOpenStatistic")
     ],
                    [
                        Button("{0} Запросить доступ".format(
                            em(":question:")),
                               callback_data="GetPermissions")
                    ]])
Example #10
0
 def statistic_reply(cls):
     kb = [[
         Button("{} Игры".format(em(":memo:")),
                callback_data="OpenGameStat")
     ],
           [
               Button("{} Вечера".format(em(":last_quarter_moon:")),
                      callback_data="OpenEveningStat")
           ]]
     return Markup(kb)
Example #11
0
def build_line_stop_keyboard(stop_code: Union[int, str],
                             is_fav: bool) -> InlineKeyboardMarkup:
    refresh = Button("🔃 Refresh", callback_data=f"#{stop_code}")

    if is_fav:
        fav = Button("💔 Remove from favs", callback_data=f"-{stop_code}")
    else:
        fav = Button("❤ Add to favs", callback_data=f"+{stop_code}")

    return InlineKeyboardMarkup([[fav, refresh]])
Example #12
0
 def ch_setting(self, ch_id):
     bts = [[
         Button('Назад', callback_data='open ch_list'),
     ], [
         Button('Водяной знак', callback_data='f f ff '),
     ],
            [
                Button('Set buttons',
                       callback_data=f'open config_btn ?ch_id={ch_id}')
            ]]
     return 'Setting', bts
Example #13
0
def hoypido_keyboard(comidas):
    weekday_buttons = [
        [
            Button(day_names[day_int], callback_data=day_int)
            for day_int in sorted(comidas)
        ],
        [
            Button('🥕 Ir a Hoypido',
                   url='https://www.hoypido.com/menu/onapsis.saludable')
        ],
    ]
    return InlineKeyboardMarkup(weekday_buttons)
Example #14
0
 def main():
     return Markup([[
         Button("{} Начать вечер".format(em(":hourglass:")),
                callback_data='start_evening')
     ],
                    [
                        Button("{} Меню рейтинга".format(em(":bar_chart:")),
                               callback_data='statistic_menu')
                    ],
                    [
                        Button("{} Меню игроков".format(em(":paperclip:")),
                               callback_data='players_menu')
                    ]])
Example #15
0
def yts_navigator_keyboard(imdb_id=None, yt_trailer=None, show_next=True):
    buttons = [
        [Button('📖 Read more', callback_data=YTS_FULL_DESC)],
        [
            Button('🍿 Torrent', callback_data=YTS_TORRENT),
            Button('🎟️ IMDB', url=IMDB_LINK.format(imdb_id)),
            Button('🎬️ Trailer', url=YT_LINK.format(
                yt_trailer)),  # Todo: only add if yt_trailer is not None
        ],
    ]  # Implement Back too
    if show_next:
        buttons[0].append(Button('Next »', callback_data=NEXT_YTS))

    return InlineKeyboardMarkup(buttons)
Example #16
0
def open_comment(bot, comment_id):

    comnt = db.get_comment(comment_id)

    bts = []
    if self.user_id == comnt.user_creator_id:  # btn for creator
        bts.append(
            Button(f'❤️ {comnt.liked_count}', callback_data='THIS YOUR like'))
        bts.append(
            Button('edit',
                   callback_data='open edit_comment ?comment_id=' +
                   str(comnt.id)))
        bts.append(
            Button('🗑',
                   callback_data='open confirm_del ?comment_id=' +
                   str(comnt.id)))
        bts.append(
            Button('Answer',
                   callback_data='open write_answer ?comment_id=' +
                   str(comnt.id)))

        return f'<b>{comnt.user_name}</b>     {comnt.date_add}\n<i>{comnt.text_main}</i>', [
            bts
        ]

    # if not none
    if comnt.users_liked and self.user_id in comnt.users_liked:
        is_liked = '💖'
        call_data = 'comment dislike ?comment_id=' + str(comnt.id)
    else:
        is_liked = '❤️'
        call_data = 'comment like ?comment_id=' + str(comnt.id)

    if comnt.channel_id in db.get_all_ch(
            self.user_id):  # btn for admin channel
        bts.append(Button(is_liked, callback_data=call_data))
        bts.append(
            Button('Answer',
                   callback_data='open write_answer ?comment_id=' +
                   str(comnt.id)))
        bts.append(
            Button('🗑',
                   callback_data='open confirm_del ?comment_id=' +
                   str(comnt.id)))

    else:  # for normal user

        bts.append(Button(is_liked, callback_data=call_data))
        bts.append(
            Button('Answer',
                   callback_data='open write_answer ?comment_id=' +
                   str(comnt.id)))

    text = f'<b>{comnt.user_name}</b>     {comnt.date_add}\n<i>{comnt.text_main}</i>'
    return text, [bts]
Example #17
0
def banco_keyboard(cotizaciones):
    COLUMNS = 3
    buttons = [
        Button(f'{banco}', callback_data=banco)
        for banco in cotizaciones
        if banco in POPULAR_TRADE_HOUSES
    ]
    columned_keyboard = [
        buttons[i: i + COLUMNS] for i in range(0, len(buttons), COLUMNS)
    ]
    columned_keyboard.append([
        Button('💰 Todos', callback_data='Todos')
    ])
    return InlineKeyboardMarkup(columned_keyboard)
Example #18
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
Example #19
0
    def button(self, data: Any, callback: (Optional[Callable], str), args: Tuple[int]=None):
        if self._inline_count is None:
            self._inline_count = 1

        if not isinstance(callback, str):
            current_button = Button(text=data, callback_data=self._serialize(callback, args))
        else:
            current_button = Button(text=data, callback_data=callback)

        line = self._buttons[-1]
        if len(line) >= self._inline_count:
            self._buttons.append([current_button])
        else:
            self._buttons[-1].append(current_button)
        return self
Example #20
0
def pelis_keyboard(include_desc=False):
    buttons = [
        [
            Button('🎟️ IMDB', callback_data=IMDB),
            Button('🎬️ Trailer', callback_data=YOUTUBE),
        ],
        [
            Button('🍿 Download', callback_data=TORRENT),
        ],
    ]
    if include_desc:
        sinospsis_row = [Button('📖️ Plot', callback_data=SINOPSIS)]
        buttons.insert(0, sinospsis_row)

    return InlineKeyboardMarkup(buttons)
Example #21
0
    def get_tg(self, config, ch_id):
        if config:
            return Button(
                str(self.id + 1) + ') ' + self.text,
                callback_data=f'open del_btn ?btn_id={self.id}&ch_id={ch_id}')

        if self.type == 'url':
            return Button(self.text, url=self.url)
        elif self.type == 'reaction':
            return Button(self.text.format(count=self.count),
                          callback_data=self.data)
        elif self.type == 'comments':
            return Button(self.text.format(count=self.count), url=self.url)
        else:
            raise Exception('Invalid type \'' + self.type + '\'of btn')
Example #22
0
    def new_post(self, bot, msg):
        post = msg.channel_post

        post_id = db.new_post(chennel_id=post.chat.id,
                              msg_id=post.message_id,
                              telegraph_path_new=page_new['path'],
                              telegraph_path_top=page_top['path'])

        standart_bts = [[
            Button('Написать коментарий',
                   url='t.me/KomentsBot?start=0' + str(post_id)),
        ]]

        if post.photo:
            type_msg = 'photo'
            text_msg = post.caption
        else:
            type_msg = 'text'
            text_msg = post.text

        text_post = add_entities(text_msg, post.entities)

        page_url = page_top['url']
        new_text = f'{text_post}\n<a href="">&#65524;</a>'

        self.edit_msg(bot, post.chat.id, post.message_id, new_text,
                      standart_bts)
Example #23
0
def pelis_keyboard(include_desc=False):
    buttons = [
        [
            Button('🎟️ IMDB', callback_data=IMDB),
            Button('🎬️ Trailer', callback_data=YOUTUBE),
        ],
        [
            Button('🍿 Torrent', callback_data=TORRENT),
            Button('💬 Subs', callback_data=SUBTITLES),
        ],
    ]
    if include_desc:
        sinospsis_row = [Button('📖️ Synopsis', callback_data=SYNOPSIS)]
        buttons.insert(0, sinospsis_row)

    return InlineKeyboardMarkup(buttons)
Example #24
0
 def edit_comment(self, comment_id):
     comment = db.get_comment(comment_id)
     btn = [[Button('Cancel', callback_data="remove_yourself")]]
     bot.send_message(self.user_id,
                      'ok send me new text for',
                      reply_markup=btn)
     return False, None
Example #25
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
Example #26
0
 def button(self,
            text: str,
            callback: Callable,
            data: Iterable[Any] = None) -> 'KeyboardBuilder':
     data = self._serializer.serialize(callback, data or [])
     self._buttons[-1].append(Button(text=text, callback_data=data))
     return self
Example #27
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
Example #28
0
 def game_menu(cls, players, postfix=""):
     kb = []
     actions = {}
     for player in players:
         tmp = []
         tmp.append(
             Button(player.number,
                    callback_data="{}{}".format(postfix, player.id)))
def torrent_keyboard(torrent):
    buttons = [Button(torrent["filename"])]

    if torrent["status"] == "downloaded":
        butt = [
            Button("Status: Ready"),
            Button("Unrestrict", callback_data=UNRESTRICT_TORRENT)
        ]
    else:
        butt = [
            Button("Status: {}".format(torrent["status"])),
            Button("Progress: {}".format(torrent["progress"]))
        ]

    buttons.append(butt)

    return InlineKeyboardMarkup(buttons)
Example #30
0
def days_selector_keyboard():
    # Show days and recurrence. Every week, every two weeks, once?
    buttons = [[
        Button(dia, callback_data=DAY_T.format(dia))
        for dia in ('Lunes', 'Martes', 'Miercoles', 'Jueves', 'Viernes')
    ]]
    # Add second keyboard with weekly, biweekly and monthly.
    return InlineKeyboardMarkup(buttons)