def create_resumed_payload(): return GatewayEvent.from_dispatch(None, { 't': 'RESUMED', 'd': { '_trace': ['test', '1', '2', '3'], } })
def handle_dispatch(self, packet): obj = GatewayEvent.from_dispatch(self.client, packet) self.log.debug('GatewayClient.handle_dispatch %s', obj.__class__.__name__) self.client.events.emit(obj.__class__.__name__, obj) if self.replaying: self.replayed_events += 1
def _on_dispatch(self, packet_type, packet_data): log.info('Dispatch: %s', packet_type) event = GatewayEvent.from_dispatch(self.client, { 't': packet_type, 'd': packet_data, }) self.client.events.emit(event.__class__.__name__, event)
def main_loop(self): discolet = self.start_disco() while True: #self.run_command(1, 'message injected?') while not self.main_process_send.empty(): evt = self.main_process_send.get() # {'ipc': ...} indicates a command for DiscordBotManager and not disco :) if not ('ipc' in evt.keys()): self.run_command( GatewayEvent.from_dispatch(self.bot.client, evt)) gevent.sleep(10) discolet.kill()
def test_guild_role_update_guild_id_attach(): event = GatewayEvent.from_dispatch( None, { 't': 'GUILD_ROLE_UPDATE', 'd': { 'role': { 'id': 1, 'name': 'test', 'color': 1, 'hoist': True, 'position': 0, 'permissions': 0, 'managed': False, 'mentionable': False, }, 'guild_id': 2, } }) assert event.guild_id == 2 assert event.role.guild_id == 2
def handle_dispatch(self, packet): obj = GatewayEvent.from_dispatch(self.client, packet) self.log.debug('Dispatching %s', obj.__class__.__name__) self.client.events.emit(obj.__class__.__name__, obj)
def handle_dispatch(self, packet): if packet['t'] in ['READY', 'RESUMED']: obj = GatewayEvent.from_dispatch(None, packet) self.events.emit(obj.__class__.__name__, obj) self.on_packet(packet)