예제 #1
0
 def _dump_state(self, db_session):
     song = (SongrequestQueue._from_id(
         db_session,
         manager_ext.bot.songrequest_manager.current_song_id)
             if manager_ext.bot.songrequest_manager.current_song_id
             else None)
     data = {
         "volume":
         manager_ext.bot.songrequest_manager.volume_val,
         "current_song":
         song.webjsonify() if song else {},
         "module_state":
         manager_ext.bot.songrequest_manager.module_state,
         "playlist":
         SongrequestQueue._get_playlist(db_session, limit=30),
         "backup_playlist":
         SongrequestQueue._get_backup_playlist(db_session,
                                               limit=30),
         "history_list":
         SongrequestHistory._get_history(db_session, limit=30),
         "banned_list":
         SongRequestSongInfo._get_banned_list(db_session),
         "favourite_list":
         SongRequestSongInfo._get_favourite_list(db_session),
         "current_timestamp":
         str(utils.now().timestamp()),
     }
     payload = {"event": "initialize", "data": data}
     self.sendMessage(json.dumps(payload).encode("utf8"), False)
예제 #2
0
 def _dump_state(self, db_session):
     current_song = SongrequestQueue._from_id(
         db_session,
         manager_ext.bot.songrequest_manager.current_song_id)
     data = {
         "event": "initialize",
         "data": {
             "currentSong":
             current_song.webjsonify() if current_song else None,
             "playlist":
             SongrequestQueue._get_playlist(db_session, 15),
             "history":
             SongrequestHistory._get_history(db_session, 15),
             "paused":
             manager_ext.bot.songrequest_manager.paused,
             "open":
             manager_ext.bot.songrequest_manager.module_opened,
             "volume":
             manager_ext.bot.songrequest_manager.volume_val(),
         },
     }
     payload = json.dumps(data).encode("utf8")
     self.sendMessage(payload, False)
예제 #3
0
 def _playlist(self):
     with DBManager.create_session_scope() as db_session:
         playlist = SongrequestQueue._get_playlist(db_session, 30)
         self.bot.songrequest_websocket_manager.emit(
             "playlist", {"playlist": playlist})