def names(message): # List of users in a channel for nick in message.get_msg().split(): if nick == "@"+Merlin.nick: CUT.opped(message.get_chan(), True) if nick[0] in ("@","+"): nick = nick[1:] CUT.join(message.get_chan(), nick) if Config.get("Misc","usercache") == "join": # Use whois to get the user's pnick message.write("WHOIS %s" % (nick,))
def names(message): # List of users in a channel for nick in message.get_msg().split(): modes, nick = modesre.match(nick).groups() if nick == Merlin.nick and "@" in modes: CUT.opped(message.get_chan(), True) elif nick == Merlin.nick: CUT.opped(message.get_chan(), False) if CUT.mode_is("rapid") and CUT.Nicks.get(nick) is None: # Use whois to get the user's pnick message.write("WHOIS %s" % (nick,)) CUT.join(message.get_chan(), nick)
def channels(message): # Part of a WHOIS result if message.get_chan() == Merlin.nick: # Cycle through the list of channels for chan in message.get_msg().split(): modes, chan = chanre.match(chan).groups() opped = "@" in modes # Reset the channel and get a list of nicks CUT.new_chan(chan) CUT.opped(chan, opped) if CUT.mode_is("rapid", "join"): message.write("NAMES %s\nTOPIC %s" % (chan,chan,))
def names(message): # List of users in a channel for nick in message.get_msg().split(): if nick == "@"+Merlin.nick: CUT.opped(message.get_chan(), True) elif nick == "+"+Merlin.nick or nick == Merlin.nick: CUT.opped(message.get_chan(), False) if nick[0] in ("@","+"): nick = nick[1:] CUT.join(message.get_chan(), nick) if CUT.mode_is("rapid"): # Use whois to get the user's pnick message.write("WHOIS %s" % (nick,))
def channels(message): # Part of a WHOIS result if message.get_chan() == Merlin.nick: # Cycle through the list of channels for chan in message.get_msg().split(): opped = chan[0] == "@" if chan[0] in ("@","+"): chan = chan[1:] # Reset the channel and get a list of nicks CUT.new_chan(chan) CUT.opped(chan, opped) if CUT.mode_is("rapid"): message.write("NAMES %s\nTOPIC %s" % (chan,chan,))
def notice(self, text, target=None, priority=0): # If we're opped in a channel in common with the user, we can reply with # CNOTICE instead of NOTICE which doesn't count towards the flood limit. if hasattr(self, "_channel") and CUT.opped(self.get_chan()) and CUT.nick_in_chan(target or self.get_nick(), self.get_chan()): self.write("CNOTICE %s %s :%s" % (target or self.get_nick(), self.get_chan(), text), priority=priority) else: self.write("NOTICE %s :%s" % (target or self.get_nick(), text), priority=priority)
def notice(self, text, target=None): # If we're opped in a channel in common with the user, we can reply with # CNOTICE instead of NOTICE which doesn't count towards the flood limit. if hasattr(self, "_channel") and CUT.opped(self.get_chan()) and CUT.nick_in_chan(target or self.get_nick(), self.get_chan()): self.write("CNOTICE %s %s :%s" % (target or self.get_nick(), self.get_chan(), text)) else: self.write("NOTICE %s :%s" % (target or self.get_nick(), text))
def privmsg(self, text, target=None, priority=0): if os.path.isfile("/tmp/meetingmode"): return # Privmsg someone. Target defaults to the person who triggered this line # Should we send colours? if ( Config.has_option("Connection", "color") and not Config.has_option("NoColor", target) and not (target[0] in ["#", "&"] and Config.has_option("NoColorChan", target[1:])) ): text = "\x03" + Config.get("Connection", "color") + text + "\x0F" color = True else: color = False # If we're opped in a channel in common with the user, we can reply with # CPRIVMSG instead of PRIVMSG which doesn't count towards the flood limit. if ( (not target or target[0] not in "#&") and hasattr(self, "_channel") and CUT.opped(self.get_chan()) and CUT.nick_in_chan(target or self.get_nick(), self.get_chan()) ): self.write("CPRIVMSG %s %s :%s" % (target or self.get_nick(), self.get_chan(), text), color, priority) else: self.write("PRIVMSG %s :%s" % (target or self.get_nick(), text), color, priority)
def op(message): # Used for tracking whether or not we're opped in channels if not CUT.Channels.has_key(message.get_chan()): # Probably a user mode change, not a channel return modes = message.line.split(None,4)[3:] if "o" in modes[0] and Merlin.nick in modes[1].split(): # The change in mode involves ops, and the ops might involve us modes, args = modes[0], modes[1].split() if modes[0] not in "+-": # add a '+' before the modes if it isn't specified (e.g. MODE s) modes = "+" + modes # modes that require args, [0] for -, [1] for + require_args = { 'q': (True, True), 'a': (True, True), 'o': (True, True), 'h': (True, True), 'v': (True, True), 'b': (True, True), 'l': (False, True), 'k': (False, True), } for mode in modes: # cycle through modes changed if mode == "+": set = True elif mode == "-": set = False else: if mode == "o": # ops changing, pop out the target being changed target = args.pop(0) if target == Merlin.nick: # update our op status CUT.opped(message.get_chan(), set) elif require_args.get(mode, (False, False))[set] is True: # some other mode that requires an argument target = args.pop(0)
def privmsg(self, text, target=None, priority=0): # Privmsg someone. Target defaults to the person who triggered this line # Should we send colours? if (Config.has_option("Connection", "color") and not Config.has_option("NoColor", target) and not (target[0] in ['#', '&'] and Config.has_option("NoColorChan", target[1:]))): text = "\x03" + Config.get("Connection", "color") + text + "\x0F" color = True else: color = False # If we're opped in a channel in common with the user, we can reply with # CPRIVMSG instead of PRIVMSG which doesn't count towards the flood limit. if (not target or target[0] not in "#&") and hasattr( self, "_channel") and CUT.opped( self.get_chan()) and CUT.nick_in_chan( target or self.get_nick(), self.get_chan()): self.write( "CPRIVMSG %s %s :%s" % (target or self.get_nick(), self.get_chan(), text), color, priority) else: self.write("PRIVMSG %s :%s" % (target or self.get_nick(), text), color, priority)