Esempio n. 1
0
    def send_menu_my_tracks(self, user):
        user_info_minimal = self.core.get_user_info_minimal(user.core_id)

        message_text = env.get_template("my_tracks_text.tmpl").render(user_info_minimal.__dict__)
        kb_text = env.get_template("my_tracks_keyboard.tmpl").render(user_info_minimal.__dict__)
        kb = self.build_markup(kb_text)

        self.remove_old_menu(user)
        self._send_text_message(user, message_text, reply_markup=kb)
Esempio n. 2
0
    def send_menu_main(self, user):
        state = self.core.get_state(user.core_id)

        message_text = env.get_template("main_menu_text.tmpl").render(**state)
        kb_text = env.get_template("main_menu_keyboard.tmpl").render(**state)
        kb = self.build_markup(kb_text)

        self.remove_old_menu(user)
        self._send_text_message(user, message_text, reply_markup=kb)
Esempio n. 3
0
    def send_menu_admin_user(self, user, handled_user_id):
        user_info = TgFrontend.ExtendedUserInfo(self.core.get_user_info(user.core_id, handled_user_id))
        user_info.frontend_user_infos = self.core.get_user_infos(handled_user_id)

        message_text = env.get_template("user_info_text.tmpl").render(user_info.__dict__)
        kb_text = env.get_template("user_info_keyboard.tmpl").render(user_info.__dict__)
        kb = self.build_markup(kb_text)

        self.remove_old_menu(user)
        self._send_text_message(user, message_text, reply_markup=kb)
Esempio n. 4
0
    def send_menu_queue(self, user, offset):
        data = self.core.get_queue(user.core_id, offset, self.songs_per_page)
        data["offset"] = offset
        data["page"] = math.ceil(offset / self.songs_per_page) + 1
        data["next_offset"] = offset + self.songs_per_page
        data["prev_offset"] = max(offset - self.songs_per_page, 0)
        data["user"] = user

        message_text = env.get_template("queue_text.tmpl").render(**data)
        kb_text = env.get_template("queue_keyboard.tmpl").render(**data)
        kb = self.build_markup(kb_text)

        self.remove_old_menu(user)
        self._send_text_message(user, message_text, reply_markup=kb)
Esempio n. 5
0
    def send_menu_song(self, user, song_id):
        data = self.core.get_song_info(user.core_id, song_id)
        data["user"] = user
        if data["song"] is not None:
            data["author"] = self.core.get_user_info_minimal(data["song"].user_id).info
            data["list_offset"] = ((data["global_position"] - 1) // self.songs_per_page) * self.songs_per_page
        else:
            data["list_offset"] = 0

        message_text = env.get_template("song_info_text.tmpl").render(**data)
        kb_text = env.get_template("song_info_keyboard.tmpl").render(**data)
        kb = self.build_markup(kb_text)

        self.remove_old_menu(user)
        self._send_text_message(user, message_text, reply_markup=kb)
Esempio n. 6
0
    def _send_song_added_message(self, user: TgUser, reply: telebot.types.Message, position: int, track):
        data = {
            "position": position,
            "track": track,
            "tracks_list": self.core.get_user_info_minimal(user.core_id).songs_in_queue,
        }

        message_text = env.get_template("song_added_msg_text.tmpl").render(**data)
        self._update_or_send_text_message(user, reply, message_text)
Esempio n. 7
0
    def send_menu_admin_list_users(self, user, offset):
        data = self.core.get_users(user.core_id, offset, self.users_per_page)
        data["offset"] = offset
        data["page"] = math.ceil(offset / self.users_per_page) + 1
        data["next_offset"] = offset + self.users_per_page
        data["prev_offset"] = max(offset - self.users_per_page, 0)

        users_cnt = data["cnt"]

        message_text = "Нет ни одного пользователя" if users_cnt == 0 else "Количество пользователей: %d" % users_cnt
        kb_text = env.get_template("users_list_keyboard.tmpl").render(**data)
        kb = self.build_markup(kb_text)

        self.remove_old_menu(user)
        self._send_text_message(user, message_text, reply_markup=kb)
Esempio n. 8
0
 def send_lyrics(self, user):
     state = self.core.get_state(user.core_id)
     message_text = env.get_template("track_lyrics_text.tmpl").render(**state)
     self._send_text_message(user, message_text)