diff --git a/pep.py b/pep.py index 9e44058..2d3d32a 100644 --- a/pep.py +++ b/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 diff --git a/pubSubHandlers/notificationHandler.py b/pubSubHandlers/notificationHandler.py new file mode 100644 index 0000000..b6ab450 --- /dev/null +++ b/pubSubHandlers/notificationHandler.py @@ -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"])) \ No newline at end of file