.BANCHO. Add redis notifications pubsub handler
This commit is contained in:
parent
f4c099c809
commit
2ae3c5f701
2
pep.py
2
pep.py
|
@ -36,6 +36,7 @@ from pubSubHandlers import changeUsernameHandler
|
|||
|
||||
from pubSubHandlers import disconnectHandler
|
||||
from pubSubHandlers import banHandler
|
||||
from pubSubHandlers import notificationHandler
|
||||
from pubSubHandlers import updateSilenceHandler
|
||||
from pubSubHandlers import updateStatsHandler
|
||||
|
||||
|
@ -275,6 +276,7 @@ if __name__ == "__main__":
|
|||
"peppy:update_cached_stats": updateStatsHandler.handler(),
|
||||
"peppy:silence": updateSilenceHandler.handler(),
|
||||
"peppy:ban": banHandler.handler(),
|
||||
"peppy:notification": notificationHandler.handler(),
|
||||
}).start()
|
||||
|
||||
# Start tornado
|
||||
|
|
19
pubSubHandlers/notificationHandler.py
Normal file
19
pubSubHandlers/notificationHandler.py
Normal file
|
@ -0,0 +1,19 @@
|
|||
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,
|
||||
"message": ""
|
||||
}
|
||||
|
||||
def handle(self, data):
|
||||
data = super().parseData(data)
|
||||
if data is None:
|
||||
return
|
||||
targetToken = glob.tokens.getTokenFromUserID(data["userID"])
|
||||
if targetToken is not None:
|
||||
targetToken.enqueue(serverPackets.notification(data["message"]))
|
Loading…
Reference in New Issue
Block a user