def __onBroadcast(self, chatAction): wrapper = ChatActionWrapper(**dict(chatAction)) text = self.__filtersChain.chainIn(wrapper.originator, wrapper.data) if not text: return wrapper.data = text channel = self.channelsStorage.getChannel(entities.BWChannelLightEntity(wrapper.channel)) g_messengerEvents.channels.onMessageReceived(wrapper, channel)
def __onBroadcast(self, chatAction): if not self.__isMessageEnabled: self.__messagesQueue.append(dict(chatAction)) return wrapper = ChatActionWrapper(**dict(chatAction)) senderDBID = wrapper.originator user = self.usersStorage.getUser(senderDBID) if user and user.isIgnored(): return text = self.__filtersChain.chainIn(senderDBID, wrapper.data) if not text: return wrapper.data = text channel = self.channelsStorage.getChannel(entities.BWChannelLightEntity(wrapper.channel)) g_messengerEvents.channels.onMessageReceived(wrapper, channel)
def __onBroadcast(self, chatAction): if not self.__isMessageEnabled: self.__messagesQueue.append(dict(chatAction)) return wrapper = ChatActionWrapper(**dict(chatAction)) senderDBID = wrapper.originator user = self.usersStorage.getUser(senderDBID) if user and user.isIgnored(): return text = self.__filtersChain.chainIn(senderDBID, wrapper.data) if not text: return wrapper.data = text channel = self.channelsStorage.getChannel(entities.BWChannelLightEntity(wrapper.channel)) g_messengerEvents.channels.onMessageReceived(wrapper, channel)
def __onSelfEnterChat(self, chatAction): wrapper = ChatActionWrapper(**dict(chatAction)) channelID = wrapper.channel channel = self.channelsStorage.getChannel( entities.BWChannelLightEntity(channelID)) isJoinAction = False if not channel and channelID in self.__channels: channel = self.__channels[channelID] if self.channelsStorage.addChannel(channel): g_messengerEvents.channels.onChannelInited(channel) g_messengerEvents.channels.onPlayerEnterChannelByAction( channel) isJoinAction = True if not channel: raise ChannelNotFound(channelID) name = channel.getName() if not isJoinAction and name in self.__creationInfo and channel.getProtoData( ).owner == getPlayerDatabaseID(): self.__creationInfo.pop(name) g_messengerEvents.channels.onPlayerEnterChannelByAction(channel) if not channel.isJoined(): channel.setJoined(True) g_messengerEvents.channels.onConnectStateChanged(channel) self.requestChannelMembers(channelID) else: channel.clearHistory()
def __onMemberStatusUpdate(self, chatAction): wrapper = ChatActionWrapper(**dict(chatAction)) channel = self.channelsStorage.getChannel(entities.BWChannelLightEntity(wrapper.channel)) if channel: member = channel.getMember(wrapper.originator) if member: member.setStatus(int(wrapper.data))
def __onChannelDestroyed(self, chatAction): LOG_DEBUG('onChannelDestroyed : %s' % (dict(chatAction), )) wrapper = ChatActionWrapper(**dict(chatAction)) channel = self.channelsStorage.getChannel( entities.BWChannelLightEntity(wrapper.channel)) if channel and self.channelsStorage.removeChannel(channel): g_messengerEvents.channels.onChannelDestroyed(channel)
def __onSelfLeaveChat(self, chatAction): LOG_DEBUG('onSelfLeaveChat:%s' % (dict(chatAction), )) wrapper = ChatActionWrapper(**dict(chatAction)) channel = self.channelsStorage.getChannel( entities.BWChannelLightEntity(wrapper.channel)) if channel: channel.setJoined(False) g_messengerEvents.channels.onConnectStateChanged(channel)
def __onBroadcast(self, chatAction): wrapper = ChatActionWrapper(**dict(chatAction)) self._filtersChain.chainIn(wrapper) if len(wrapper.data) == 0: return channel = self.channelsStorage.getChannel( entities.BWChannelLightEntity(wrapper.channel)) g_messengerEvents.channels.onMessageReceived(wrapper, channel)
def __onEnterChat(self, chatAction): wrapper = ChatActionWrapper(**dict(chatAction)) channel = self.channelsStorage.getChannel( entities.BWChannelLightEntity(wrapper.channel)) if channel: channel.addMembers([ entities.BWMemberEntity(wrapper.originator, nickName=wrapper.originatorNickName) ])
def __onRequestChannelMembers(self, chatAction): wrapper = ChatActionWrapper(**dict(chatAction)) channel = self.channelsStorage.getChannel( entities.BWChannelLightEntity(wrapper.channel)) if channel is not None: channel.addMembers( map( lambda memberData: self.__makeMemberFromDict( dict(memberData)), wrapper.data))
def __onChannelDestroyed(self, chatAction): LOG_DEBUG('onChannelDestroyed : %s' % (dict(chatAction),)) wrapper = ChatActionWrapper(**dict(chatAction)) channel = self.channelsStorage.getChannel(entities.BWChannelLightEntity(wrapper.channel)) if channel and self.channelsStorage.removeChannel(channel, clear=False): g_messengerEvents.channels.onChannelDestroyed(channel) if channel.getID() in self.__channels: self.__channels.pop(channel.getID()) self.onChannelExcludeFromSearch(channel) channel.clear()
def __onSelfLeaveChat(self, chatAction): """ Event handler. When current player exit from channel, remove page for this channel """ LOG_DEBUG('onSelfLeaveChat:%s' % (dict(chatAction),)) wrapper = ChatActionWrapper(**dict(chatAction)) channel = self.channelsStorage.getChannel(entities.BWChannelLightEntity(wrapper.channel)) if channel: channel.setJoined(False) g_messengerEvents.channels.onConnectStateChanged(channel)
def __onReceiveMembersDelta(self, chatAction): wrapper = ChatActionWrapper(**dict(chatAction)) channel = self.channelsStorage.getChannel(entities.BWChannelLightEntity(wrapper.channel)) if channel is None: return else: added = [] removed = [] for dbID, data in wrapper.data: if data[0] == 1: added.append(entities.BWMemberEntity(dbID, nickName=data[1], status=data[2])) elif data[0] == 0: removed.append(dbID) if len(added): channel.addMembers(added) if len(removed): channel.removeMembers(removed) return
def __onSelfEnterChat(self, chatAction): wrapper = ChatActionWrapper(**dict(chatAction)) channelID = wrapper.channel channel = self.channelsStorage.getChannel( entities.BWChannelLightEntity(channelID)) if not channel and channelID in self.__channels: channel = self.__channels[channelID] if self.channelsStorage.addChannel(channel): g_messengerEvents.channels.onChannelInited(channel) g_messengerEvents.channels.onPlayerEnterChannelByAction( channel) if not channel: raise ChannelNotFound(channelID) if not channel.isJoined(): channel.setJoined(True) g_messengerEvents.channels.onConnectStateChanged(channel) self.requestChannelMembers(channelID) else: channel.clearHistory()
def __onLeaveChat(self, chatAction): wrapper = ChatActionWrapper(**dict(chatAction)) channel = self.channelsStorage.getChannel( entities.BWChannelLightEntity(wrapper.channel)) if channel: channel.removeMembers([wrapper.originator])
def __init__(self, commandData, playerVehID): super(ChatCommandDecorator, self).__init__() self._chatAction = ChatActionWrapper(**dict(commandData)) self._playerVehID = playerVehID self._cmdArgs = ()