forked from osuripple/pep.py
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Selective update main menu icon redis handler
- Loading branch information
Showing
3 changed files
with
37 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
from common.log import logUtils as log | ||
from common.redis import generalPubSubHandler | ||
from objects import glob | ||
from constants import serverPackets | ||
|
||
|
||
class handler(generalPubSubHandler.generalPubSubHandler): | ||
def __init__(self): | ||
super().__init__() | ||
self.structure = { | ||
"userID": 0, | ||
"mainMenuIconID": 0 | ||
} | ||
|
||
def handle(self, data): | ||
data = super().parseData(data) | ||
if data is None: | ||
return | ||
targetTokens = glob.tokens.getTokenFromUserID(data["userID"], ignoreIRC=True, _all=True) | ||
if targetTokens: | ||
icon = glob.db.fetch( | ||
"SELECT file_id, url FROM main_menu_icons WHERE id = %s LIMIT 1", | ||
(data["mainMenuIconID"],) | ||
) | ||
if icon is None: | ||
log.warning("Tried to test an unknown main menu icon") | ||
return | ||
for x in targetTokens: | ||
x.enqueue( | ||
serverPackets.mainMenuIcon("{}|{}".format( | ||
"https://i.ppy.sh/{}.png".format(icon["file_id"]), | ||
icon["url"] | ||
)) | ||
) |