diff --git a/rustplus/__init__.py b/rustplus/__init__.py index b7f76bb..9096e35 100644 --- a/rustplus/__init__.py +++ b/rustplus/__init__.py @@ -4,11 +4,12 @@ from .api import RustSocket from .api.structures import EntityEvent, TeamEvent, ChatEvent +from .api.remote.fcm_listener import FCMListener from .commands import CommandOptions, Command from .exceptions import * from .utils import entity_type_to_string, convert_xy_to_grid __name__ = "rustplus" __author__ = "olijeffers0n" -__version__ = "5.3.7" +__version__ = "5.3.8" __support__ = "Discord: https://discord.gg/nQqJe8qvP8" diff --git a/rustplus/api/remote/fcm_listener.py b/rustplus/api/remote/fcm_listener.py new file mode 100644 index 0000000..8b0a405 --- /dev/null +++ b/rustplus/api/remote/fcm_listener.py @@ -0,0 +1,22 @@ +from push_receiver import listen +from threading import Thread + + +class FCMListener: + + def __init__(self, data: dict = None): + self.thread = None + self.data = data + + def on_notification(self, obj, notification, data_message): + pass + + def start(self): + self.thread = Thread(target=self.__fcm_listen, daemon=True).start() + + def __fcm_listen(self): + + if self.data is None: + raise ValueError("Data is None") + + listen(credentials=self.data["fcm_credentials"], callback=self.on_notification) diff --git a/setup.py b/setup.py index 851f57e..1a7cd45 100644 --- a/setup.py +++ b/setup.py @@ -29,7 +29,9 @@ "websocket_client", "Pillow", "protobuf>=3.18.1", - "asyncio" + "asyncio", + "push_receiver", + "http-ece" ], python_requires='>=3.7.0', )