예제 #1
0
파일: irc.py 프로젝트: maw/kibot
    def kick(self, cmd):
        """kick a user from a channel
        irc.kick [channel] nick(s) [comment]
        """
        args = cmd.shsplit()
        channel = cmd.channel    # default channel
        comment = "have a nice day!"
        ircdb = self.bot.ircdb
        nicks = []

        if args and is_channel(args[0]): channel = args.pop(0)
        while args:
            if ircdb.users.has_key(args[0]): nicks.append(args.pop(0))
            else: break
        if args: comment = ' '.join(args)
        if comment.startswith('comment='): comment = comment[8:]
        if not channel:
            cmd.reply("What channel?")
            return
        elif not self._i_have_op(channel):
            cmd.reply("I don't have ops on %s" % channel)
            return

        chan_obj = self.bot.ircdb.channels[channel]
        chnicks = chan_obj.users()
        chopers = chan_obj.opers()
        for nick in nicks:
            if nick not in chnicks:
                cmd.reply("There is no %s on %s" % (nick, channel))
            else:
                self.bot.conn.kick(channel, nick, comment)
예제 #2
0
    def kick(self, cmd):
        """kick a user from a channel
        irc.kick [channel] nick(s) [comment]
        """
        args = cmd.shsplit()
        channel = cmd.channel    # default channel
        comment = "have a nice day!"
        ircdb = self.bot.ircdb
        nicks = []

        if args and is_channel(args[0]): channel = args.pop(0)
        while args:
            if ircdb.users.has_key(args[0]): nicks.append(args.pop(0))
            else: break
        if args: comment = ' '.join(args)
        if comment.startswith('comment='): comment = comment[8:]
        if not channel:
            cmd.reply("What channel?")
            return
        elif not self._i_have_op(channel):
            cmd.reply("I don't have ops on %s" % channel)
            return

        chan_obj = self.bot.ircdb.channels[channel]
        chnicks = chan_obj.users()
        for nick in nicks:
            if nick not in chnicks:
                cmd.reply("There is no %s on %s" % (nick, channel))
            else:
                self.bot.conn.kick(channel, nick, comment)
예제 #3
0
    def op(self, cmd):
        """give ops to someone
        irc.op [channel] [nick(s)]
        """
        args = cmd.asplit()
        channel = cmd.channel    # default channel
        if args and is_channel(args[0]): channel = args.pop(0)
        if not channel:
            cmd.reply("What channel?")
            return
        elif not self._i_have_op(channel):
            cmd.reply("I don't have ops on %s" % channel)
            return
        
        if args: nicks = args
        else: nicks = [cmd.nick]

        chan_obj = self.bot.ircdb.channels[channel]
        chnicks = chan_obj.users()
        chopers = chan_obj.opers()
        for nick in nicks:
            if nick not in chnicks:
                cmd.reply("There is no %s on %s" % (nick, channel))
            elif nick in chopers:
                cmd.reply("%s already has ops on %s" % (nick, channel))
            else:
                self.bot.conn.mode(channel, '+o '+nick)
예제 #4
0
파일: irc.py 프로젝트: maw/kibot
    def op(self, cmd):
        """give ops to someone
        irc.op [channel] [nick(s)]
        """
        args = cmd.asplit()
        channel = cmd.channel    # default channel
        if args and is_channel(args[0]): channel = args.pop(0)
        if not channel:
            cmd.reply("What channel?")
            return
        elif not self._i_have_op(channel):
            cmd.reply("I don't have ops on %s" % channel)
            return
        
        if args: nicks = args
        else: nicks = [cmd.nick]

        chan_obj = self.bot.ircdb.channels[channel]
        chnicks = chan_obj.users()
        chopers = chan_obj.opers()
        for nick in nicks:
            if nick not in chnicks:
                cmd.reply("There is no %s on %s" % (nick, channel))
            elif nick in chopers:
                cmd.reply("%s already has ops on %s" % (nick, channel))
            else:
                self.bot.conn.mode(channel, '+o '+nick)
예제 #5
0
파일: CommandHandler.py 프로젝트: maw/kibot
 def nnotice(self, *args):
     """same as nreply, but with notice instead of privmsg"""
     target, message = self._get_target_and_message(args)
     if is_channel(target):
         message = '%s: %s' % (self.nick, message)
     if hasattr(self, "bot"):
         self.bot.log(7, "NoReply.nnotice: %s: %s" % (target, message))
예제 #6
0
파일: CommandHandler.py 프로젝트: maw/kibot
 def nreply(self, *args):
     """same as reply, but if it's a public response, the user's nick
     (the one who typed the command) is prepended"""
     target, message = self._get_target_and_message(args)
     if is_channel(target):
         message = '%s: %s' % (self.nick, message)
     if hasattr(self, "bot"):
         self.bot.log(7, "NoReply.nreply: %s: %s" % (target, message))
예제 #7
0
 def _on_mode(self, c, e):
     mynick = self.bot.nick
     modes = parse_channel_modes(' '.join(e.args))
     t = e.target
     if is_channel(t):
         if not self._i_have_op(t): return
         for sign, mode, nick in modes:
             if sign == "+" and mode == "o" and nick == mynick:
                 self._check_all(c, t)
예제 #8
0
파일: irc.py 프로젝트: maw/kibot
 def _on_mode(self, c, e):
     mynick = self.bot.nick
     modes = parse_channel_modes(string.join(e.args))
     t = e.target
     if is_channel(t):
         if not self._i_have_op(t): return
         for sign, mode, nick in modes:
             if sign == "+" and mode == "o" and nick == mynick:
                 self._check_all(c, t)
예제 #9
0
파일: slashdot.py 프로젝트: maw/kibot
 def _notify(self, target, new):
     if is_channel(target):
         if not target in self.bot.ircdb.channels.keys():
             return
     else:
         if not target in self.bot.ircdb.users.keys():
             return
     for art in new:
         self.bot.conn.privmsg(target, "Slashdot: %s" % art)
예제 #10
0
파일: PermObjects.py 프로젝트: maw/kibot
 def check_target(self, userperms, context, best_match):
     try: target = context['target']
     except KeyError:
         if context.has_key('cmd'):
             args = context['cmd'].asplit()
             channel = context['cmd'].channel
             if args and is_channel(args[0]): target = args[0]
             else: target = channel
         else:
             target = None
     if not target: return 0
     if target == 'NONE': return 1
     uperm = userperms[best_match]
     try: checklist = uperm.misc[0]
     except IndexError, e: checklist = uperm.channels
     return self.check_globlist(checklist, target)
예제 #11
0
파일: irc.py 프로젝트: maw/kibot
 def join(self, cmd):
     """tell the bot to join a channel
     irc.join <channel>
     """
     if self.bot.ircdb.channels.has_key(cmd.args):
         cmd.reply("I'm already on that channel")
     elif not is_channel(cmd.args):
         cmd.reply("that's not a legal channel")
     else:
         args = cmd.asplit()
         channel = args[0]
         key = None
         
         if len(args) > 2:
             cmd.reply("too many arguments")
         elif len(args) == 2:
             key = args[1]
         self.bot.conn.join(channel, key)
예제 #12
0
    def invite(self, cmd):
        """invite a user to an invite-only channel
        irc.invite [channel] [nick(s)]
        """
        args = cmd.asplit()
        channel = cmd.channel    # default channel
        if args and is_channel(args[0]): channel = args.pop(0)
        if not channel:
            cmd.reply("What channel?")
            return
        
        if args: nicks = args
        else: nicks = [cmd.nick]

        chan_obj = self.bot.ircdb.channels[channel]
        chnicks = chan_obj.users()
        for nick in nicks:
            if nick in chnicks:
                cmd.reply("%s is already on %s" % (nick, channel))
            else:
                self.bot.conn.invite(nick, channel)
예제 #13
0
파일: irc.py 프로젝트: maw/kibot
    def invite(self, cmd):
        """invite a user to an invite-only channel
        irc.invite [channel] [nick(s)]
        """
        args = cmd.asplit()
        channel = cmd.channel    # default channel
        if args and is_channel(args[0]): channel = args.pop(0)
        if not channel:
            cmd.reply("What channel?")
            return
        
        if args: nicks = args
        else: nicks = [cmd.nick]

        chan_obj = self.bot.ircdb.channels[channel]
        chnicks = chan_obj.users()
        for nick in nicks:
            if nick in chnicks:
                cmd.reply("%s is already on %s" % (nick, channel))
            else:
                self.bot.conn.invite(nick, channel)
예제 #14
0
    def join(self, cmd):
        """tell the bot to join a channel
        irc.join <channel>
        """
        if self.bot.ircdb.channels.has_key(cmd.args):
            cmd.reply("I'm already on that channel")
        elif not is_channel(cmd.args):
            cmd.reply("that's not a legal channel")
        else:
            args = cmd.asplit()
            channel = args[0]
            key = None
            
            if len(args) > 2:
                cmd.reply("too many arguments")
            elif len(args) == 2:
                key = args[1]

            if key is not None:
                self.bot.conn.join(channel, key)
            else:
                self.bot.conn.join(channel)
예제 #15
0
파일: CommandHandler.py 프로젝트: maw/kibot
 def nnotice(self, *args):
     """same as nreply, but with notice instead of privmsg"""
     target, message = self._get_target_and_message(args)
     if is_channel(target): message = '%s: %s' % (self.nick, message)
     self.connection.notice(target, message)
예제 #16
0
파일: CommandHandler.py 프로젝트: maw/kibot
 def nreply(self, *args):
     """same as reply, but if it's a public response, the user's nick
     (the one who typed the command) is prepended"""
     target, message = self._get_target_and_message(args)
     if is_channel(target): message = '%s: %s' % (self.nick, message)
     self.connection.privmsg(target, message)
예제 #17
0
파일: m_irclib.py 프로젝트: maw/kibot
            if m.group("argument"):
                a = string.split(m.group("argument"), " :", 1)
                arguments = string.split(a[0])
                if len(a) == 2:
                    arguments.append(a[1])

            if command == "nick":
                if nm_to_n(prefix) == self.real_nickname:
                    self.real_nickname = arguments[0]

            if command in ["privmsg", "notice"]:
                target, message = arguments[0], arguments[1]
                messages = _ctcp_dequote(message)

                if command == "privmsg":
                    if is_channel(target):
                        command = "pubmsg"
                else:
                    if is_channel(target):
                        command = "pubnotice"
                    else:
                        command = "privnotice"

                for m in messages:
                    if type(m) is types.TupleType:
                        if command in ["privmsg", "pubmsg"]:
                            command = "ctcp"
                        else:
                            command = "ctcpreply"

                        m = list(m)