def handle_join(event, message): client=Client.findByNick(message.source) if(client is None): return chan=Channel.findByName(message.parameters[0]) if(chan is None): chan=Channel(message.parameters[0], time.time()) Channel.addChannel(chan) chan.addClient(client) log.debug("%s has joined %s", client.nick, chan.name)
def handle_join(event, message): client = Client.findByNick(message.source) if (client is None): return chan = Channel.findByName(message.parameters[0]) if (chan is None): chan = Channel(message.parameters[0], time.time()) Channel.addChannel(chan) chan.addClient(client) log.debug("%s has joined %s", client.nick, chan.name)
def handle_sjoin(event, message): chan_name = message.parameters[1] timestamp = message.parameters[0] chan = Channel.findByName(chan_name) if (chan is None): chan = Channel(chan_name, timestamp) Channel.addChannel(chan) p_idx = 2 if (message.parameters[p_idx][0] == "+"): #we have modes if (chan.timestamp == timestamp): #merge modes chan.setModes(message.parameters[p_idx], message.parameters[p_idx + 1:-1], True) elif (chan.timestamp > timestamp): #clear existing modes and use sjoin modes chan.clearModes() chan.setModes(message.parameters[p_idx], message.parameters[p_idx + 1:-1]) #else ignore sjoin modes new_modes = [] new_params = [] for item in message.parameters[-1].split(): #this could be a channel member, ban, exemption, or invex -- very confusing! # *~@%+ are user statuses qaohv, respectively # & is a ban, " is an exemption, ' is an invex item_type = item[0] if (sjoin_prefix_to_mode.has_key(item_type)): item = item[1:] new_modes.append(sjoin_prefix_to_mode[item_type]) new_params.append(item) if (not sjoin_prefix_to_mode.has_key(item_type) or item_type in ("*", "~", "@", "%", "+")): member = Client.findByNick(item) if (not member is None): log.debug("SJOIN: %s to %s", member.nick, chan.name) chan.addClient(member) if (len(new_modes) > 0): chan.setModes("+" + "".join(new_modes), new_params)
def handle_sjoin(event, message): chan_name=message.parameters[1] timestamp=message.parameters[0] chan=Channel.findByName(chan_name) if(chan is None): chan=Channel(chan_name, timestamp) Channel.addChannel(chan) p_idx=2 if(message.parameters[p_idx][0]=="+"): #we have modes if(chan.timestamp==timestamp): #merge modes chan.setModes(message.parameters[p_idx], message.parameters[p_idx+1:-1], True) elif(chan.timestamp>timestamp): #clear existing modes and use sjoin modes chan.clearModes() chan.setModes(message.parameters[p_idx], message.parameters[p_idx+1:-1]) #else ignore sjoin modes new_modes=[] new_params=[] for item in message.parameters[-1].split(): #this could be a channel member, ban, exemption, or invex -- very confusing! # *~@%+ are user statuses qaohv, respectively # & is a ban, " is an exemption, ' is an invex item_type=item[0] if(sjoin_prefix_to_mode.has_key(item_type)): item=item[1:] new_modes.append(sjoin_prefix_to_mode[item_type]) new_params.append(item) if(not sjoin_prefix_to_mode.has_key(item_type) or item_type in ("*", "~", "@", "%", "+")): member=Client.findByNick(item) if(not member is None): log.debug("SJOIN: %s to %s", member.nick, chan.name) chan.addClient(member) if(len(new_modes)>0): chan.setModes("+"+"".join(new_modes), new_params)