.BANCHO. Add redis notifications pubsub handler

This commit is contained in:
Nyo 2016-12-20 21:22:25 +01:00
parent f4c099c809
commit 2ae3c5f701
2 changed files with 21 additions and 0 deletions

2
pep.py
View File

@ -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

View 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"]))