コード例 #1
0
    def grab(self, irc, msg, args, channel, nick):
        """[<channel>] <nick>

        Grabs a quote from <channel> by <nick> for the quotegrabs table.
        <channel> is only necessary if the message isn't sent in the channel
        itself.
        """
        # chan is used to make sure we know where to grab the quote from, as
        # opposed to channel which is used to determine which db to store the
        # quote in
        chan = msg.args[0]
        if chan is None or not irc.isChannel(chan):
            raise callbacks.ArgumentError
        if ircutils.nickEqual(nick, msg.nick):
            irc.error(_('You can\'t quote grab yourself.'), Raise=True)
        if conf.supybot.protocols.irc.experimentalExtensions():
            msgid = msg.server_tags.get('+draft/reply')
        else:
            msgid = None
        for m in reversed(irc.state.history):
            if msgid and m.server_tags.get('msgid') != msgid:
                continue
            if m.command == 'PRIVMSG' and ircutils.nickEqual(m.nick, nick) \
                    and ircutils.strEqual(m.args[0], chan):
                # TODO: strip statusmsg prefix for comparison? Must be careful
                # abouk leaks, though.
                self._grab(channel, irc, m, msg.prefix)
                irc.replySuccess()
                return
        irc.error(_('I couldn\'t find a proper message to grab.'))
コード例 #2
0
ファイル: plugin.py プロジェクト: affix/supybot-plugins
 def getTopUsers(self, channel, word, n):
     L = [(id, d[word]) for ((chan, id), d) in self.iteritems()
          if ircutils.nickEqual(channel, chan) and word in d]
     utils.sortBy(lambda (_, i): i, L)
     L = L[-n:]
     L.reverse()
     return L
コード例 #3
0
ファイル: plugin.py プロジェクト: D0MF/supybot-plugins-1
 def delWord(self, channel, word):
     if word in self.channelWords[channel]:
         del self.channelWords[channel][word]
     for ((chan, id), d) in self.iteritems():
         if ircutils.nickEqual(chan, channel):
             if word in d:
                 del d[word]
コード例 #4
0
ファイル: plugin.py プロジェクト: affix/supybot-plugins
 def delWord(self, channel, word):
     if word in self.channelWords[channel]:
         del self.channelWords[channel][word]
     for ((chan, id), d) in self.iteritems():
         if ircutils.nickEqual(chan, channel):
             if word in d:
                 del d[word]
コード例 #5
0
ファイル: plugin.py プロジェクト: D0MF/supybot-plugins-1
 def getTopUsers(self, channel, word, n):
     L = [(id, d[word]) for ((chan, id), d) in self.iteritems()
          if ircutils.nickEqual(channel, chan) and word in d]
     utils.sortBy(lambda (_, i): i, L)
     L = L[-n:]
     L.reverse()
     return L
コード例 #6
0
ファイル: plugin.py プロジェクト: krattai/AEBL
    def tell(self, irc, msg, args, target, text):
        """<nick> <text>

        Tells the <nick> whatever <text> is.  Use nested commands to your
        benefit here.
        """
        if irc.nested:
            irc.error("This command cannot be nested.", Raise=True)
        if target.lower() == "me":
            target = msg.nick
        if ircutils.isChannel(target):
            irc.error("Dude, just give the command.  No need for the tell.")
            return
        if not ircutils.isNick(target):
            irc.errorInvalid("nick", target)
        if ircutils.nickEqual(target, irc.nick):
            irc.error("You just told me, why should I tell myself?", Raise=True)
        if target not in irc.state.nicksToHostmasks and not ircdb.checkCapability(msg.prefix, "owner"):
            # We'll let owners do this.
            s = "I haven't seen %s, I'll let you do the telling." % target
            irc.error(s, Raise=True)
        if irc.action:
            irc.action = False
            text = "* %s %s" % (irc.nick, text)
        s = "%s wants me to tell you: %s" % (msg.nick, text)
        irc.replySuccess()
        irc.reply(s, to=target, private=True)
コード例 #7
0
ファイル: wvmsupybot.py プロジェクト: Wintervenom/Xn
def combine(msgs, reverse=True, stamps=False, nicks=True, compact=True,
            joiner=r' \ ', nocolor=False):
    """
    Formats and returns a list of IrcMsg objects (<msgs>) as a string.
    <reverse>, if True, prints messages from last to first.
    <stamps>, if True, appends timestamps to messages.
    <reverse>, if True, orders messages by earliest to most recent.
    <compact>, if False, append nicks to consecutive messages
    <joiner>, the character joining lines together (default: ' \ ').
    <nocolor>, if True, strips color from messages.
    Sample output:
        <bigman> DUNK \ <bigbitch> \ bluh \ bluh
    """
    output = []
    lastnick = ''
    for msg in reversed(msgs) if reverse else msgs:
        isaction = ircmsgs.isAction(msg)
        if isaction:
            text = '[%s %s]' % (msg.nick, ircmsgs.unAction(msg))
        else:
            if compact and ircutils.nickEqual(msg.nick, lastnick) or not nicks:
                text = msg.args[1]
            else:
                lastnick = msg.nick
                text = '<%s> %s' % (msg.nick, msg.args[1])
        if stamps:
            stampfmt = '%d-%m-%y %H:%M:%S'
            stamp = time.strftime(stampfmt, time.localtime(msg.receivedAt))
            text = '[{0}] {1}'.format(stamp, text)
        output.append(ircutils.stripFormatting(text))
    return joiner.join(output)
コード例 #8
0
ファイル: plugin.py プロジェクト: vaporstack/Supybot-plugins
 def goodwire(self, irc, msg, args ):
     """ This will certainly help you out in a pinch """
     channel = msg.args[0]
     if not self.registryValue('allowBombs', msg.args[0]):
         irc.noReply()
         return
     try:
         if not ircutils.nickEqual(self.bombs[channel].victim, msg.nick):
             irc.reply("You can't see the wires from there.")
             return
         else:
             self.responded = True
             
         if self.bombs[channel].active:
             randNum = self.rng.randint(0,6)
             if randNum == 0 :
                 s = "uhhhhh uhhhh I think it's the %s wire!" % ( self.bombs[channel].goodWire)
             else:
                 s = "they're all %s wires!" % self.rng.choice(self.bombs[channel].wires)
             irc.reply( s.upper())
             return
         else:
             irc.reply("No active time bomb at the moment.")
     except KeyError:
         pass
コード例 #9
0
ファイル: plugin.py プロジェクト: alxsoares/supybot-plugins
    def cutwire(self, irc, msg, args, channel, cutWire):
        """<colored wire>

        Will cut the given wire if you've been timebombed."""
        channel = ircutils.toLower(channel)
        try:
            if not self.bombs[channel].active:
                return
            if not ircutils.nickEqual(self.bombs[channel].victim, msg.nick):
                irc.reply('You can\'t cut the wire on someone else\'s bomb!')
                return
            else:
                self.responded = True

            spellCheck = False
            for item in self.bombs[channel].wires :
                if item.lower() == cutWire.lower():
                    spellCheck = True
            if spellCheck == False :
                irc.reply("That doesn't appear to be one of the options.")
                return
                
            self.bombs[channel].cutwire(irc, cutWire)
        except KeyError:
            pass
        irc.noReply()
コード例 #10
0
    def tell(self, irc, msg, args, target, text):
        """<nick> <text>

        Tells the <nick> whatever <text> is.  Use nested commands to your
        benefit here.
        """
        if irc.nested:
            irc.error('This command cannot be nested.', Raise=True)
        if target.lower() == 'me':
            target = msg.nick
        if ircutils.isChannel(target):
            irc.error('Dude, just give the command.  No need for the tell.')
            return
        if not ircutils.isNick(target):
            irc.errorInvalid('nick', target)
        if ircutils.nickEqual(target, irc.nick):
            irc.error('You just told me, why should I tell myself?',Raise=True)
        if target not in irc.state.nicksToHostmasks and \
             not ircdb.checkCapability(msg.prefix, 'owner'):
            # We'll let owners do this.
            s = 'I haven\'t seen %s, I\'ll let you do the telling.' % target
            irc.error(s, Raise=True)
        if irc.action:
            irc.action = False
            text = '* %s %s' % (irc.nick, text)
        s = '%s wants me to tell you: %s' % (msg.nick, text)
        irc.replySuccess()
        irc.reply(s, to=target, private=True)
コード例 #11
0
ファイル: plugin.py プロジェクト: MrTiggr/supybot_fixes
    def tell(self, irc, msg, args, target, text):
        """<nick> <text>

        Tells the <nick> whatever <text> is.  Use nested commands to your
        benefit here.
        """
        if target.lower() == 'me':
            target = msg.nick
        if ircutils.isChannel(target):
            irc.error('Dude, just give the command.  No need for the tell.')
            return
        if not ircutils.isNick(target):
            irc.errorInvalid('nick', target)
        if ircutils.nickEqual(target, irc.nick):
            irc.error('You just told me, why should I tell myself?',Raise=True)
        if target not in irc.state.nicksToHostmasks and \
             not ircdb.checkCapability(msg.prefix, 'owner'):
            # We'll let owners do this.
            s = 'I haven\'t seen %s, I\'ll let you do the telling.' % target
            irc.error(s, Raise=True)
        if irc.action:
            irc.action = False
            text = '* %s %s' % (irc.nick, text)
        s = '%s wants me to tell you: %s' % (msg.nick, text)
        irc.reply(s, to=target, private=True)
コード例 #12
0
ファイル: plugin.py プロジェクト: jacksonmj/StewieGriffin
    def defuse(self, irc, msg, args, channel):
        """Takes no arguments

        Defuses the active bomb (channel ops only)"""
        channel = ircutils.toLower(channel)
        try:
            if self.bombs[channel].active:
                if ircutils.nickEqual(self.bombs[channel].victim, msg.nick) and not (ircutils.nickEqual(self.bombs[channel].victim, self.bombs[channel].sender) or ircdb.checkCapability(msg.prefix, 'admin')):
                    irc.reply('You can\'t defuse a bomb that\'s in your own pants, you\'ll just have to cut a wire and hope for the best.')
                    return
                self.bombs[channel].defuse()
                irc.reply('Bomb defused')
            else:
                irc.error('There is no active bomb')
        except KeyError:
            pass
            irc.error('There is no active bomb')
コード例 #13
0
ファイル: plugin.py プロジェクト: D0MF/supybot-plugins-1
 def addWord(self, channel, word):
     if channel not in self.channelWords:
         self.channelWords[channel] = {}
     self.channelWords[channel][word] = 0
     for ((chan, id), d) in self.iteritems():
         if ircutils.nickEqual(chan, channel):
             if word not in d:
                 d[word] = 0
コード例 #14
0
ファイル: plugin.py プロジェクト: affix/supybot-plugins
 def addWord(self, channel, word):
     if channel not in self.channelWords:
         self.channelWords[channel] = {}
     self.channelWords[channel][word] = 0
     for ((chan, id), d) in self.iteritems():
         if ircutils.nickEqual(chan, channel):
             if word not in d:
                 d[word] = 0
コード例 #15
0
 def duck(self, irc, ducker):
     if self.thrown and ircutils.nickEqual(self.victim, ducker):
         self.irc.queueMsg(
             ircmsgs.privmsg(
                 self.channel,
                 '{} ducks! The bomb misses, and explodes harmlessly a few meters away.'
                 .format(self.victim)))
         self.defuse()
コード例 #16
0
ファイル: plugin.py プロジェクト: wolfy1339/Limnoria-Plugins
    def defuse(self, irc, msg, args, channel):
        """Takes no arguments

        Defuses the active bomb (channel ops only)"""
        channel = ircutils.toLower(channel)
        try:
            if self.bombs[channel].active:
                if ircutils.nickEqual(self.bombs[channel].victim, msg.nick) and not (ircutils.nickEqual(self.bombs[channel].victim, self.bombs[channel].sender) or ircdb.checkCapability(msg.prefix, 'admin')):
                    irc.reply('You can\'t defuse a bomb that\'s in your own pants, you\'ll just have to cut a wire and hope for the best.')
                    return
                self.bombs[channel].defuse()
                irc.reply('Bomb defused')
            else:
                irc.error('There is no active bomb')
        except KeyError:
            pass
            irc.error('There is no active bomb')
コード例 #17
0
ファイル: plugin.py プロジェクト: eif0/d0b
 def doForce(self, irc, msg, match):
     r'^no,\s+(\w+,\s+)?(.+?)\s+(?<!\\)(was|is|am|were|are)\s+(.+?[?!. ]*)$'
     (nick, key, isAre, value) = match.groups()
     value = value.rstrip()
     key.rstrip('?')
     if not msg.addressed:
         if nick is None:
             self.log.debug('Not forcing because we weren\'t addressed and '
                            'payload wasn\'t of the form: no, irc.nick, ..')
             return
         nick = nick.rstrip(' \t,')
         if not ircutils.nickEqual(nick, irc.nick):
             self.log.debug('Not forcing because the regexp nick didn\'t '
                            'match our nick.')
             return
     else:
         if nick is not None:
             stripped = nick.rstrip(' \t,')
             if not ircutils.nickEqual(stripped, irc.nick):
                 key = nick + key
     isAre = isAre.lower()
     if self.added:
         return
     channel = dynamic.channel
     if isAre in ('was', 'is', 'am'):
         if self.db.hasIs(channel, key):
             oldValue = self.db.getIs(channel, key)
             if oldValue.lower() == value.lower():
                 self.reply(format('I already had it that way, %s.',
                                   msg.nick))
                 return
             self.log.debug('Forcing %q to %q.', key, value)
             self.added = True
             self.db.setIs(channel, key, value)
     else:
         if self.db.hasAre(channel, key):
             oldValue = self.db.getAre(channel, key)
             if oldValue.lower() == value.lower():
                 self.reply(format('I already had it that way, %s.',
                                   msg.nick))
                 return
             self.log.debug('Forcing %q to %q.', key, value)
             self.added = True
             self.db.setAre(channel, key, value)
     self.confirm()
コード例 #18
0
 def duck(self, irc, ducker):
     if self.thrown and ircutils.nickEqual(self.victim, ducker):
         self.irc.queueMsg(
             ircmsgs.privmsg(
                 self.channel,
                 "{} ducks!  The bomb misses, and explodes harmlessly a few meters away.".format(self.victim),
             )
         )
         self.defuse()
コード例 #19
0
ファイル: plugin.py プロジェクト: yo-bj/supybot-plugins
 def doForce(self, irc, msg, match):
     r'^no,\s+(\w+,\s+)?(.+?)\s+(?<!\\)(was|is|am|were|are)\s+(.+?)[?!. ]*$'
     (nick, key, isAre, value) = match.groups()
     if not msg.addressed:
         if nick is None:
             self.log.debug('Not forcing because we weren\'t addressed and '
                            'payload wasn\'t of the form: no, irc.nick, ..')
             return
         nick = nick.rstrip(' \t,')
         if not ircutils.nickEqual(nick, irc.nick):
             self.log.debug('Not forcing because the regexp nick didn\'t '
                            'match our nick.')
             return
     else:
         if nick is not None:
             stripped = nick.rstrip(' \t,')
             if not ircutils.nickEqual(stripped, irc.nick):
                 key = nick + key
     isAre = isAre.lower()
     if self.added:
         return
     channel = dynamic.channel
     if isAre in ('was', 'is', 'am'):
         if self.db.hasIs(channel, key):
             oldValue = self.db.getIs(channel, key)
             if oldValue.lower() == value.lower():
                 self.reply(
                     format('I already had it that way, %s.', msg.nick))
                 return
             self.log.debug('Forcing %q to %q.', key, value)
             self.added = True
             self.db.setIs(channel, key, value)
     else:
         if self.db.hasAre(channel, key):
             oldValue = self.db.getAre(channel, key)
             if oldValue.lower() == value.lower():
                 self.reply(
                     format('I already had it that way, %s.', msg.nick))
                 return
             self.log.debug('Forcing %q to %q.', key, value)
             self.added = True
             self.db.setAre(channel, key, value)
     self.confirm()
コード例 #20
0
ファイル: plugin.py プロジェクト: scornflakes/peacekeeper
 def duck(self, irc, ducker):
     if self.thrown and ircutils.nickEqual(self.victim, ducker):
         self.irc.queueMsg(
             ircmsgs.privmsg(
                 self.channel,
                 '%s ducks!  The bomb misses, and explodes harmlessly a few meters away.'
                 % self.victim))
         self.active = False
         self.thrown = False
         schedule.removeEvent('%s_bomb' % self.channel)
コード例 #21
0
ファイル: plugin.py プロジェクト: EnderBlue/supybot
 def duck(self, irc, ducker):
     if self.thrown and ircutils.nickEqual(self.victim, ducker):
         self.irc.queueMsg(
             ircmsgs.privmsg(
                 self.channel,
                 "%s ducks!  The bomb misses, and explodes harmlessly a few meters away." % self.victim,
             )
         )
         self.active = False
         self.thrown = False
         schedule.removeEvent("%s_bomb" % self.channel)
コード例 #22
0
ファイル: plugin.py プロジェクト: ki113d/Limnoria
    def grab(self, irc, msg, args, channel, nick):
        """[<channel>] <nick>

        Grabs a quote from <channel> by <nick> for the quotegrabs table.
        <channel> is only necessary if the message isn't sent in the channel
        itself.
        """
        # chan is used to make sure we know where to grab the quote from, as
        # opposed to channel which is used to determine which db to store the
        # quote in
        chan = msg.args[0]
        if chan is None:
            raise callbacks.ArgumentError
        if ircutils.nickEqual(nick, msg.nick):
            irc.error(_("You can't quote grab yourself."), Raise=True)
        for m in reversed(irc.state.history):
            if m.command == "PRIVMSG" and ircutils.nickEqual(m.nick, nick) and ircutils.strEqual(m.args[0], chan):
                self._grab(channel, irc, m, msg.prefix)
                irc.replySuccess()
                return
        irc.error(_("I couldn't find a proper message to grab."))
コード例 #23
0
    def wat(self, irc, msg, args, nick):
        """<nick>

        Grabs the last line said by <nick> and returns it with emojis translated
        """
        chan = msg.args[0]
        selfCaller = False
        for m in reversed(irc.state.history):
            if m.command == 'PRIVMSG' and \
            ircutils.nickEqual(m.nick, nick) and \
            ircutils.strEqual(m.args[0], chan):
                if ircutils.nickEqual(nick, msg.nick) and selfCaller:
                    irc.reply(emoji.demojize(ircmsgs.prettyPrint(m)))
                    return
                elif ircutils.nickEqual(nick, msg.nick):
                    selfCaller = True
                    continue
                else:
                    irc.reply(emoji.demojize(ircmsgs.prettyPrint(m)))
                    return
        irc.error(_('I couldn\'t find a proper message to translate.'))
コード例 #24
0
    def grab(self, irc, msg, args, channel, nick):
        """[<channel>] <nick>

        Grabs a quote from <channel> by <nick> for the quotegrabs table.
        <channel> is only necessary if the message isn't sent in the channel
        itself.
        """
        # chan is used to make sure we know where to grab the quote from, as
        # opposed to channel which is used to determine which db to store the
        # quote in
        chan = msg.args[0]
        if chan is None:
            raise callbacks.ArgumentError
        if ircutils.nickEqual(nick, msg.nick):
            irc.error('You can\'t quote grab yourself.', Raise=True)
        for m in reversed(irc.state.history):
            if m.command == 'PRIVMSG' and ircutils.nickEqual(m.nick, nick) \
                    and ircutils.strEqual(m.args[0], chan):
                self._grab(channel, irc, m, msg.prefix)
                irc.replySuccess()
                return
        irc.error('I couldn\'t find a proper message to grab.')
コード例 #25
0
 def defuse(self, irc, msg, args, channel):
     """[<channel>]
     Defuses the active bomb (channel ops only).
     """
     channel = ircutils.toLower(channel)
     try:
         if self.bombs[channel].active:
             if ircutils.nickEqual(
                     self.bombs[channel].victim, msg.nick) and not (
                         ircutils.nickEqual(self.bombs[channel].victim,
                                            self.bombs[channel].sender)
                         or ircdb.checkCapability(msg.prefix, "admin")):
                 irc.reply(
                     "You can't defuse a bomb that's in your own pants, you'll just"
                     " have to cut a wire and hope for the best.")
                 return
             self.bombs[channel].defuse()
             irc.reply("Bomb defused.")
         else:
             irc.error("There is no active bomb.")
     except KeyError:
         pass
         irc.error("There is no active bomb")
コード例 #26
0
ファイル: plugin.py プロジェクト: jacksonmj/StewieGriffin
    def cutwire(self, irc, msg, args, channel, cutWire):
        """<colored wire>

        Will cut the given wire if you've been timebombed."""
        channel = ircutils.toLower(channel)
        try:
            if not self.bombs[channel].active:
                return
            if not ircutils.nickEqual(self.bombs[channel].victim, msg.nick) and not ircdb.checkCapability(msg.prefix, 'admin'):
                irc.reply('You can\'t cut the wire on someone else\'s bomb!')
                return
            self.bombs[channel].cutwire(irc, cutWire)
        except KeyError:
            pass
        irc.noReply()
コード例 #27
0
ファイル: plugin.py プロジェクト: EnderBlue/supybot
    def cutwire(self, irc, msg, args, channel, cutWire):
        """<colored wire>

        Will cut the given wire if you've been timebombed."""
        channel = ircutils.toLower(channel)
        try:
            if not self.bombs[channel].active:
                return
            if not ircutils.nickEqual(self.bombs[channel].victim, msg.nick):
                irc.reply("You can't cut the wire on someone else's bomb!")
                return
            self.bombs[channel].cutwire(irc, cutWire)
        except KeyError:
            pass
        irc.noReply()
コード例 #28
0
 def duck(self, irc, msg, args, channel):
     """[<channel>]
     DUCK! (You'll want to do this if someone throws a bomb back at you.)
     """
     channel = ircutils.toLower(channel)
     try:
         if (not self.bombs[channel].active
                 or not self.bombs[channel].rethrown
                 or not ircutils.nickEqual(self.bombs[channel].victim,
                                           msg.nick)):
             return
     except KeyError:
         return
     self.bombs[channel].duck(irc, msg.nick)
     irc.noReply()
コード例 #29
0
ファイル: plugin.py プロジェクト: scornflakes/peacekeeper
    def cutwire(self, irc, msg, args, channel, cutWire):
        """<colored wire>

        Will cut the given wire if you've been timebombed."""
        channel = ircutils.toLower(channel)
        try:
            if not self.bombs[channel].active:
                return
            if not ircutils.nickEqual(self.bombs[channel].victim, msg.nick):
                irc.reply('You can\'t cut the wire on someone else\'s bomb!')
                return
            self.bombs[channel].cutwire(irc, cutWire)
        except KeyError:
            pass
        irc.noReply()
コード例 #30
0
ファイル: plugin.py プロジェクト: fred0r/limnoria-plugins
    def cutwire(self, irc, msg, args, channel, cutWire):
        """[<channel>] <color>
        Will cut the given wire if you've been bombed.
        """
        channel = ircutils.toLower(channel)
        try:
            if not self.bombs[channel].active or self.bombs[channel].rethrown:
                return

            if not ircutils.nickEqual(self.bombs[channel].victim, msg.nick) and not ircdb.checkCapability(msg.prefix, 'admin'):
                irc.reply('You can\'t cut the wire on someone else\'s bomb!')
                return
            self.bombs[channel].cutwire(irc, cutWire)
        except KeyError:
            pass
        irc.noReply()
コード例 #31
0
ファイル: plugin.py プロジェクト: Chalks/Supybot
    def ungrab(self, irc, msg, args, channel, grab):
        """[<channel>] <number>

        Removes the grab <number> (the last by default) on <channel>.
        <channel> is only necessary if the message isn't sent in the channel
        itself.  You may only ungrab quotes you made or grabbed.
        """
        try:
            original = self.db.get(channel, grab)
            if ircutils.nickEqual(ircutils.nickFromHostmask(original.grabber), msg.nick) or ircutils.nickEqual(original.by, msg.nick):
                self.db.remove(channel, grab)
                irc.replySuccess()
            else:
                irc.error('Can only ungrab quotes made or grabbed by you.')
        except dbi.NoRecordError:
            if grab is None:
                irc.error('Nothing to ungrab.')
            else:
                irc.error('Invalid grab number.')
コード例 #32
0
ファイル: plugin.py プロジェクト: Wintervenom/Xn
 def doPrivmsg(self, irc, msg):
     if not (self.source and irc.network == self.network and \
             ircutils.nickEqual(msg.nick, self.target)):
         return
     elif time.time() - self.lastreply > self.timeout:
         self._result('Gave up waiting for a response.')
         return
     text = msg.args[1]
     count = re.sub(r'.*\((\d+) more messages?\)\W?$', r'\1', text)
     if count.isdigit():
         self.replies.append(re.sub(r'%s$' % pagetext, '', text))
         if self.page < self.pagelimit:
             self.page += 1
             self._proxy('more')
             return
         else:
             text = ' [Truncated]'
     text = ''.join(self.replies) + text
     self._result(text)
     self.replies = []
     self.page = 0
コード例 #33
0
ファイル: plugin.py プロジェクト: Wintervenom/Xn
    def grab(self, irc, msg, args, channel, expr):
        """[<channel>] [<nick|expr>:] <expr>

        Grabs the last message in the channel backlog that matches the
        expression in <expr>, optionally from <nick>, which is also part
        of <expr>, and can, therefore, use expression syntax.
        See $exprhelp for expression syntax and $delims for valid
        delimiter characters.
        """
        chan = msg.args[0]
        if chan is None:
            raise callbacks.ArgumentError
        gmsg = wvm.find(irc, chan, expr, limit=1)
        if len(gmsg) == 0:
            irc.error("Couldn't find a matching line to grab.")
            return
        gmsg = gmsg[0]
        if ircutils.nickEqual(msg.nick, gmsg.nick):
            irc.error("You can't grab yourself, Michael Jackson.",
                      Raise=True)
        self._grab(channel, irc, gmsg, msg.prefix)
        text = wvm.formatmsg(gmsg)
        irc.reply('Grabbed: %s' % text)
コード例 #34
0
ファイル: plugin.py プロジェクト: alxsoares/supybot-plugins
 def goodwire(self, irc, msg, args ):
     channel = msg.args[0]
     if not self.registryValue('allowBombs', msg.args[0]):
         irc.noReply()
         return
     try:
         if not ircutils.nickEqual(self.bombs[channel].victim, msg.nick):
             irc.reply("You can't see the wires from there.")
             return
         else:
             self.responded = True
             
         if self.bombs[channel].active:
             randNum = self.rng.randint(0,6)
             if randNum == 0 :
                 s = "uhhhhh uhhhh I think it's the %s wire!" % ( self.bombs[channel].goodWire)
             else:
                 s = "they're all %s wires!" % self.rng.choice(self.bombs[channel].wires)
             irc.reply( s.upper())
             return
         else:
             irc.reply("No active time bomb at the moment.")
     except KeyError:
         pass
コード例 #35
0
ファイル: plugin.py プロジェクト: Wintervenom/Xn
    def rmvar(self, irc, msg, args, name, keys):
        """<var> [<key> ...]

        Deletes the variable <var> or one or more matching <key>s in <var>.
        """
        try:
            if name.startswith("_"):
                name = "%s-%s" % (name, msg.nick)
                name = name.lower()
                owner = self.variables[name][2]
                if not ircutils.nickEqual(owner, msg.nick):
                    irc.error("Variable <%s> locked by %s." % (name, owner))
                    return
            if not keys:
                del (self.variables[name])
            else:
                for key in keys:
                    try:
                        del (self.variables[name][0][key])
                    except:
                        pass
            irc.reply("")
        except KeyError:
            irc.error("Variable <%s> is undefined." % name)
コード例 #36
0
ファイル: plugin.py プロジェクト: Poorchop/Limnoria
 def _tell(self, irc, msg, args, target, text, notice):
     if irc.nested:
         irc.error('This command cannot be nested.', Raise=True)
     if target.lower() == 'me':
         target = msg.nick
     if ircutils.isChannel(target):
         irc.error(_('Hey, just give the command.  No need for the tell.'))
         return
     if not ircutils.isNick(target):
         irc.errorInvalid('nick', target)
     if ircutils.nickEqual(target, irc.nick):
         irc.error(_('You just told me, why should I tell myself?'),
                   Raise=True)
     if target not in irc.state.nicksToHostmasks and \
          not ircdb.checkCapability(msg.prefix, 'owner'):
         # We'll let owners do this.
         s = _('I haven\'t seen %s, I\'ll let you do the telling.') % target
         irc.error(s, Raise=True)
     if irc.action:
         irc.action = False
         text = '* %s %s' % (irc.nick, text)
     s = _('%s wants me to tell you: %s') % (msg.nick, text)
     irc.replySuccess()
     irc.reply(s, to=target, private=True, notice=notice)
コード例 #37
0
ファイル: plugin.py プロジェクト: Athemis/Limnoria
 def p(s1, s2):
     # text_factory seems to only apply as an output adapter,
     # so doesn't apply to created functions; so we use str()
     return ircutils.nickEqual(str(s1), str(s2))
コード例 #38
0
ファイル: plugin.py プロジェクト: Wintervenom/Xn
 def p(s1, s2):
     return ircutils.nickEqual(str(s1), str(s2))
コード例 #39
0
ファイル: plugin.py プロジェクト: affix/supybot-plugins
 def getNumUsers(self, channel):
     i = 0
     for ((chan, _), _) in self.iteritems():
         if ircutils.nickEqual(chan, channel):
             i += 1
     return i
コード例 #40
0
ファイル: plugin.py プロジェクト: Wintervenom/Xn
 def doNotice(self, irc, msg):
     if self.source and ircutils.nickEqual(msg.nick, self.target):
         self.doPrivmsg(irc, msg)
コード例 #41
0
 def p(s1, s2):
     # text_factory seems to only apply as an output adapter,
     # so doesn't apply to created functions; so we use str()
     return ircutils.nickEqual(str(s1), str(s2))
コード例 #42
0
ファイル: plugin.py プロジェクト: D0MF/supybot-plugins-1
 def getNumUsers(self, channel):
     i = 0
     for ((chan, _), _) in self.iteritems():
         if ircutils.nickEqual(chan, channel):
             i += 1
     return i
コード例 #43
0
 def p(s1, s2):
     return int(ircutils.nickEqual(s1, s2))
コード例 #44
0
ファイル: plugin.py プロジェクト: nod/boombot
def nickeq(s1, s2):
    return int(ircutils.nickEqual(s1.encode('iso8859-1'),
				  s2.encode('iso8859-1')))
コード例 #45
0
ファイル: plugin.py プロジェクト: Wintervenom/Xn
    def var(self, irc, msg, args, opts, name, elements):
        """[--i] [--d=<default>] [--u=<ifundef>] [--t=<timeout>] [--o=<owner>] <var>[:<index>] [[<key>:]<string> ...]

        If no <key>:<string> pair or <string> arguments are included,
        returns the <string> whose <key> matches <index> in variable
        <var>.  If the <index> is left out, it will be assumed to be
        "0".  An <index> of "?" returns a random item.  Adding
        <key>:<string> pair or <string> arguments will set <var> to
        them.  If an <index> is included with this, the existing
        <string> at that index will be set to the arguments as one
        merged <string>.  If a <key> is left out, it will be assingned
        the number of that item's position, starting at zero.
        If a <key> is not found for an <index> and a "!" key exists,
        its will be returned instead; otherwise, a key error will be
        thrown.  Multiple keys can be assigned to a string by separating
        them with semicolons.  If --i is set, keys will be case-insensitve.
        Variables will live up to ~10 seconds unless the timeout is set with
        --t (0 == permanent).  Variables can be made private (only the same
        user can modify) by prefixing it with an underscore.  If --d is set,
        <default> will be returned as the value.  If --u is set, <ifundef>
        will be returned as the error if the variable isn't defined.  If --o
        is set, will give read-only access to variables belonging to that
        owner.
        """
        name = name.split(":", 1)
        default = None
        ifundef = None
        index = None
        private = False
        casei = False
        count = False
        owner = msg.nick.lower()
        timeout = 10
        for o, a in opts:
            if o == "i":
                casei = True
            elif o == "t":
                timeout = max(0, int(a))
            elif o == "d":
                default = a
            elif o == "u":
                ifundef = a
            elif o == "o":
                owner = a
        if name[0].startswith("_"):
            private = True
            name[0] = "%s-%s" % (name[0], owner)
        if len(name) == 2:
            index = wvm.fixexpr(name[1]).lstrip()
        else:
            index = None
        name = name[0].lower()
        try:
            if not elements:
                if not index:
                    index = "0"
                elif index == "#":
                    try:
                        irc.reply(len(self.variables[name][0]))
                    except KeyError:
                        irc.reply(0)
                    return
                elif index == "@":
                    try:
                        irc.reply(" / ".join(sorted(self.variables[name][0].values())))
                    except KeyError:
                        irc.reply("")
                    return
                elif index == "@@":
                    try:
                        irc.reply(" / ".join(sorted(self.variables[name][0].keys())))
                    except KeyError:
                        irc.reply("")
                    return
                elif index == "?":
                    element = self.variables[name][0].values()
                    irc.reply(self.rng.choice(element))
                    return
                try:
                    if self.variables[name][3]:
                        index = index.lower()
                except KeyError:
                    if default:
                        irc.reply(default)
                    elif ifundef:
                        irc.error(ifundef)
                    else:
                        irc.error('Variable "%s" is undefined.' % name)
                    return
                irc.reply(self.variables[name][0][index])
            else:
                if private and not ircdb.checkCapability(msg.prefix, "owner"):
                    if not ircutils.nickEqual(owner, msg.nick):
                        irc.error("Only read-only allowed outside your scope.")
                        return
                    try:
                        current_owner = self.variables[name][2]
                        if not ircutils.nickEqual(current_owner, msg.nick):
                            irc.error('Variable "%s" is locked by %s.' % (name, current_owner))
                            return
                    except KeyError:
                        pass
                if not index:
                    array = {}
                    for position, element in enumerate(elements):
                        element = element.split(":", 1)
                        if len(element) == 1:
                            array[str(position)] = element[0]
                        else:
                            if casei:
                                element[0] = element[0].lower()
                            for key in element[0].split(";"):
                                array[wvm.fixexpr(key, False)] = wvm.fixexpr(element[1]).lstrip()
                    self.variables[name] = [array, (time.time(), timeout), owner, casei]
                else:
                    if casei:
                        index = index.lower()
                    try:
                        self.variables[name][0][index] = " ".join(elements)
                        self.variables[name][1] = (time.time(), timeout)
                        self.variables[name][2] = owner
                    except KeyError:
                        self.variables[name] = [{index: " ".join(elements)}, (time.time(), timeout), owner, casei]
                self._writevarsfile()
                irc.reply("")
        except KeyError:
            try:
                irc.reply(self.variables[name][0]["!"])
            except KeyError:
                irc.error("No such variable key: %s[%s]" % (name, index))
コード例 #46
0
ファイル: plugin.py プロジェクト: Criptomonedas/supybot_fixes
 def p(s1, s2):
     return int(ircutils.nickEqual(s1, s2))
コード例 #47
0
def nickeq(s1, s2):
    return int(
        ircutils.nickEqual(s1.encode('iso8859-1'), s2.encode('iso8859-1')))