From dde08459e9fbe4dc09ab106dbf96df5a235b1871 Mon Sep 17 00:00:00 2001 From: Ben Date: Thu, 2 Apr 2020 23:08:22 +0100 Subject: [PATCH] Temporary solution for "matching" packet data to handlers --- houdini/handlers/__init__.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/houdini/handlers/__init__.py b/houdini/handlers/__init__.py index 9b12ffe..f87d836 100644 --- a/houdini/handlers/__init__.py +++ b/houdini/handlers/__init__.py @@ -66,12 +66,13 @@ class _Listener(_ArgumentDeserializer): class _XTListener(_Listener): - __slots__ = ['pre_login'] + __slots__ = ['pre_login', 'match'] def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.pre_login = kwargs.get('pre_login') + self.match = kwargs.get('match') async def __call__(self, p, packet_data): try: @@ -79,10 +80,11 @@ class _XTListener(_Listener): await p.close() raise AuthorityError(f'{p} tried sending XT packet before authentication!') - await super()._check_cooldown(p) - super()._check_list(p) + if self.match is None or packet_data[:len(self.match)] == self.match: + await super()._check_cooldown(p) + super()._check_list(p) - await super().__call__(p, packet_data) + await super().__call__(p, packet_data) except CooldownError: p.logger.debug(f'{p} tried to send a packet during a cooldown') except ChecklistError: