def _333(server, raw_string, code, server_url, target, data): #topicinfo data = data.split() channel = server.getChannel(data[0]) channel_name = None user_data = user_functions.splitUserData(data[1]) if channel: channel_name = channel.getName() user_data_full = channel.getUser(user_data[0]) if user_data_full: user_data = user_data_full else: channel_name = data[0].lower() user_data = user_functions.generateUserData(user_data) channel_data = server.getStash().getChannel(channel_name) if channel_data: channel_data['topicwho'] = user_data channel_data['topictime'] = int(data[2]) else: server.addEvent(outboundDictionaries.IRC_Channel_Topic_Information(server.getContextID(), server.getName(), channel_name, user_data, int(data[2])))
def _MODE(server, data, target, nickname): modes = common.splitModes(data) if target[0] in GLOBAL.IRC_CHANNEL_PREFIX: channel = server.getChannel(target) if not channel: return channel.updateModes(modes) user_data = channel.getUserData(nickname) if not user_data: user_data = user_functions.generateUserData(user_functions.splitUserData(nickname)) server.addEvent( outboundDictionaries.IRC_Channel_Modes_Update( server.getContextID(), server.getName(), target, modes, data, {}, channel.getModes(), channel.getModeStringFull(), channel.getModeStringSafe(), user_data, ) ) else: server.updateUserModes(modes) server.addEvent( outboundDictionaries.IRC_User_Modes( server.getContextID(), server.getName(), nickname, modes, data, server.getUserModes(), server.getUserModeString(), ) )
def handleResponseCode(server, userstring, text, raw_string): """ This function parses and processes a colon-prefixed event sent by a user. It handles strings that look like:: :[email protected] NOTICE rhx :PING rice @type server: pyrc_irc_abstract.irc_server.Server @param server: A reference to the Server object that received this event. @type userstring: basestring @param userstring: The URI of the user that sent this event (a raw user string). @type text: list @param text: The token used to identify the type of event and the event's data. @type raw_string: basestring @param raw_string: The raw event string. @rtype: None|Tuple @return: Nothing if everything went well; a tuple containing an optional reason and a bool indicating whether PyRC should suppress reconnection if PyRC needs to disconnect. Leaving the reason empty will result in no disconnection event being generated, so the handler will need to take care of informing the IAL. @raise ProtocolError: If the string received from the IRC server did not match the spec expected by PyRC. """ identifier = text[0] text = text[1].split(None, 1) target = text[0] data = None if len(text) > 1: data = text[1] if data: if data.startswith(":"): data = data[1:] user_data = None user_data = user_functions.splitUserData(userstring) user = server.getUser(user_data[0]) if not user: user_data = user_functions.generateUserData(user_data) else: user.setIdentity(user_data[1], user_data[2]) if target[0] in GLOBAL.IRC_CHANNEL_PREFIX: user_data = user.getData(target) else: user_data = user.getData() handler = _response_code_events.get(identifier) if handler: try: if data: data = unicode(data, "utf-8", "replace") return handler(server, data, target, user_data) except Exception, e: import pyrc_common.errlog print pyrc_common.errlog.grabTrace() raise ProtocolError("Error while processing '%s': %s" % (raw_string, e))