当前位置: 首页>>代码示例>>Python>>正文


Python ircmsgs.prettyPrint函数代码示例

本文整理汇总了Python中supybot.ircmsgs.prettyPrint函数的典型用法代码示例。如果您正苦于以下问题:Python prettyPrint函数的具体用法?Python prettyPrint怎么用?Python prettyPrint使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了prettyPrint函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _normalize

 def _normalize(self, m):
     if ircmsgs.isAction(m):
         n = ircmsgs.prettyPrint(m).split(None, 2)
         try:
             return [" ".join(n[:2]), n[2]]
         except IndexError:  # empty action
             return [" ".join(n[:2]), "\x00"]
     else:
         pretty = ircmsgs.prettyPrint(m).split(None, 1)
         if len(pretty) == 1:
             pretty.append("\x00")
         return pretty
开发者ID:stepnem,项目名称:supybot-plugins,代码行数:12,代码来源:plugin.py

示例2: doPart

 def doPart(self, irc, msg):
     channel = msg.args[0]
     said = ircmsgs.prettyPrint(msg)
     self.anydb.update(channel, msg.nick, said)
     try:
         id = ircdb.users.getUserId(msg.prefix)
         self.anydb.update(channel, id, said)
     except KeyError:
         pass # Not in the database.
开发者ID:bnrubin,项目名称:supybot_fixes,代码行数:9,代码来源:plugin.py

示例3: doQuit

 def doQuit(self, irc, msg):
     said = ircmsgs.prettyPrint(msg)
     try:
         id = ircdb.users.getUserId(msg.prefix)
     except KeyError:
         id = None # Not in the database.
     for channel in msg.tagged('channels'):
         self.anydb.update(channel, msg.nick, said)
         if id is not None:
             self.anydb.update(channel, id, said)
开发者ID:ElectroCode,项目名称:Limnoria,代码行数:10,代码来源:plugin.py

示例4: doPrivmsg

 def doPrivmsg(self, irc, msg):
     if self.shouldRelay(msg):
         target = self.registryValue('target')
         if target and target in irc.state.channels:
             if self.registryValue('fancy'):
                 s = ircmsgs.prettyPrint(msg)
             else:
                 s = msg.args[1]
             s = self.registryValue('prefix') + s
             irc.queueMsg(ircmsgs.privmsg(target, s))
开发者ID:D0MF,项目名称:supybot-plugins-1,代码行数:10,代码来源:plugin.py

示例5: twitter_post

    def twitter_post(self, irc, msg):
        text = ircmsgs.prettyPrint(msg)
        text = text[text.find('>') + 2:]

        if len(text) > 140:
            text = text[:138] + '...'

        try:
            self.twitter.PostUpdate(text)
        except twitter.TwitterError:
            self.log.exception('Posting quote to twitter failed')
开发者ID:jreese,项目名称:supybot-plugins,代码行数:11,代码来源:plugin.py

示例6: doMode

 def doMode(self, irc, msg):
     # Filter out messages from network Services
     if msg.nick:
         try:
             id = ircdb.users.getUserId(msg.prefix)
         except KeyError:
             id = None # Not in the database.
         channel = msg.args[0]
         said = ircmsgs.prettyPrint(msg)
         self.anydb.update(channel, msg.nick, said)
         if id is not None:
             self.anydb.update(channel, id, said)
开发者ID:ElectroCode,项目名称:Limnoria,代码行数:12,代码来源:plugin.py

示例7: doPrivmsg

 def doPrivmsg(self, irc, msg):
     ''' Dummy docstring. '''
     if self.shouldRelay(msg):
         target = self.registryValue('target')
         if target and target in irc.state.channels:
             if self.registryValue('fancy'):
                 s = ircmsgs.prettyPrint(msg)
             else:
                 s = msg.args[1]
             s = self.registryValue('prefix') + s
             self.log.debug("regexrelay, queuing: " + s)
             irc.queueMsg(ircmsgs.privmsg(target, s))
开发者ID:leamas,项目名称:supybot-regexrelay,代码行数:12,代码来源:plugin.py

示例8: doQuit

 def doQuit(self, irc, msg):
     said = ircmsgs.prettyPrint(msg)
     if irc not in self.ircstates:
         return
     try:
         id = ircdb.users.getUserId(msg.prefix)
     except KeyError:
         id = None # Not in the database.
     for channel in self.ircstates[irc].channels:
         if msg.nick in self.ircstates[irc].channels[channel].users:
             self.anydb.update(channel, msg.nick, said)
             if id is not None:
                 self.anydb.update(channel, id, said)
开发者ID:bnrubin,项目名称:supybot_fixes,代码行数:13,代码来源:plugin.py

示例9: doPrivmsg

 def doPrivmsg(self, irc, msg):
     if ircmsgs.isCtcp(msg) and not ircmsgs.isAction(msg):
         return
     if irc.isChannel(msg.args[0]):
         channel = msg.args[0]
         said = ircmsgs.prettyPrint(msg)
         self.db.update(channel, msg.nick, said)
         self.anydb.update(channel, msg.nick, said)
         try:
             id = ircdb.users.getUserId(msg.prefix)
             self.db.update(channel, id, said)
             self.anydb.update(channel, id, said)
         except KeyError:
             pass # Not in the database.
开发者ID:bnrubin,项目名称:supybot_fixes,代码行数:14,代码来源:plugin.py

示例10: add

 def add(self, channel, msg, by):
     db = self._getDb(channel)
     cursor = db.cursor()
     text = ircmsgs.prettyPrint(msg)
     # Check to see if the latest quotegrab is identical
     cursor.execute("""SELECT quote FROM quotegrabs
                       WHERE nick=%s
                       ORDER BY id DESC LIMIT 1""", msg.nick)
     if cursor.rowcount != 0:
         if text == cursor.fetchone()[0]:
             return
     cursor.execute("""INSERT INTO quotegrabs
                       VALUES (NULL, %s, %s, %s, %s, %s)""",
                    msg.nick, msg.prefix, by, int(time.time()), text)
     db.commit()
开发者ID:jreese,项目名称:supybot-plugins,代码行数:15,代码来源:plugin.py

示例11: add

 def add(self, channel, msg, by):
     db = self._getDb(channel)
     cursor = db.cursor()
     text = ircmsgs.prettyPrint(msg)
     # Check to see if the latest quotegrab is identical
     cursor.execute("""SELECT quote FROM quotegrabs
                       WHERE nick=?
                       ORDER BY id DESC LIMIT 1""", (msg.nick,))
     results = cursor.fetchall()
     if len(results) != 0:
         if text == results[0][0]:
             return
     cursor.execute("""INSERT INTO quotegrabs
                       VALUES (NULL, ?, ?, ?, ?, ?)""",
                    (msg.nick, msg.prefix, by, int(time.time()), text,))
     db.commit()
开发者ID:Athemis,项目名称:Limnoria,代码行数:16,代码来源:plugin.py

示例12: add

 def add(self, msg, by):
     channel = msg.args[0]
     db = self.getDb(channel)
     cursor = db.cursor()
     text = ircmsgs.prettyPrint(msg)
     # Check to see if the latest quotegrab is identical
     cursor.execute("""SELECT quote FROM quotegrabs
                       WHERE nick=?
                       ORDER BY id DESC LIMIT 1""", (msg.nick,))
     quote = cursor.fetchone()
     if quote and text == quote[0]:
         return
     cursor.execute("""INSERT INTO quotegrabs
                       VALUES (NULL, ?, ?, ?, ?, ?, 0)""",
                    (msg.nick, msg.prefix, by, int(time.time()), text))
     db.commit()
开发者ID:nod,项目名称:boombot,代码行数:16,代码来源:plugin.py

示例13: doPrivmsg

    def doPrivmsg(self, irc, msg):
        curTime = time.time()
        if (self.lastSent + COOL_DOWN_SECONDS) > curTime:
            return  # skip, we're cooling down

        if irc.isChannel(msg.args[0]):
            channel = msg.args[0]
            said = ircmsgs.prettyPrint(msg, showNick=False)
            nick = msg.nick

            __dir__ = os.path.dirname(os.path.abspath(__file__))
            filepath = os.path.join(__dir__, "opinions.csv")

            opinions = csv.reader(open(filepath, "rb"))
            for row in opinions:
                # match beginning of string/whitespace word end of string/whitespace
                if re.search("(\(|\s|^)" + row[0].lower() + "(\s|\)|\.|\?|\!|$)", said.lower()) is not None:
                    irc.reply(row[0] + "? " + row[1] + ". " + ",".join(row[2:]))
                    self.lastSent = time.time()
开发者ID:Salient,项目名称:KrailOS,代码行数:19,代码来源:plugin.py

示例14: doPrivmsg

    def doPrivmsg(self, irc, msg):
        __dir__ = os.path.dirname(os.path.abspath(__file__))

        if not irc.isChannel(msg.args[0]):
            return 

        curTime = time.time()
        channel = msg.args[0]
        said = ircmsgs.prettyPrint(msg, showNick=False)
        nick = msg.nick

        print("Checking %s %s: %s at time %d" % (channel, nick, said, curTime));

        if said.find("I CALL UPON THE POWER OF THE SPREADSHEET") != -1:
            if (self.lastPull + SS_DOWNLOAD_SECONDS) < curTime:
                irc.reply("loading hacking tools...")
                os.system("cd " + __dir__ + "; ./get_new_opinions.sh")
                irc.reply("hacking tools loaded, %d hacks total" % (len(self.opinions),))
                self.load_opinions()
                self.lastPull = time.time()
                self.lastSent = time.time() - COOL_DOWN_SECONDS # allow test
            else:
                print("ignored %s, %d minutes remain" % 
                    (said, 
                    ((self.lastPull + SS_DOWNLOAD_SECONDS) - curTime)/60))
            return

        didReply = False
        for (reg, res) in self.opinions:
            # match beginning of string/whitespace word end of string/whitespace
            m = reg.search(said)
            if m is not None:
                if (self.lastSent + COOL_DOWN_SECONDS) < curTime:
                    irc.reply(m.group(2) + res)
                    didReply = True
                else:
                    print("ignored %s, %d minutes remain" % 
                        (said, 
                        ((self.lastSent + COOL_DOWN_SECONDS) - curTime)/60))

        if didReply:
            self.lastSent = time.time()
开发者ID:m-wynn,项目名称:KrailOS,代码行数:42,代码来源:plugin.py

示例15: last


#.........这里部分代码省略.........
                if arg != msg.args[0]:
                    skipfirst = False
            elif option == "on":

                def f(m, arg=arg):
                    return m.receivedOn == arg

                predicates["on"] = f
            elif option == "with":

                def f(m, arg=arg):
                    return arg.lower() in m.args[1].lower()

                predicates.setdefault("with", []).append(f)
            elif option == "without":

                def f(m, arg=arg):
                    return arg.lower() not in m.args[1].lower()

                predicates.setdefault("without", []).append(f)
            elif option == "regexp":

                def f(m, arg=arg):
                    def f1(s, arg):
                        """Since we can't enqueue match objects into the multiprocessing queue,
                        we'll just wrap the function to return bools."""
                        if arg.search(s) is not None:
                            return True
                        else:
                            return False

                    if ircmsgs.isAction(m):
                        m1 = ircmsgs.unAction(m)
                        # return arg.search(ircmsgs.unAction(m))
                    else:
                        m1 = m.args[1]
                        # return arg.search(m.args[1])
                    try:
                        # use a subprocess here, since specially crafted regexps can
                        # take exponential time and hang up the bot.
                        # timeout of 0.1 should be more than enough for any normal regexp.
                        v = commands.process(f1, m1, arg, timeout=0.1, pn=self.name(), cn="last")
                        return v
                    except commands.ProcessTimeoutError:
                        return False

                predicates.setdefault("regexp", []).append(f)
            elif option == "nolimit":
                nolimit = True
        iterable = ifilter(self._validLastMsg, reversed(irc.state.history))
        if skipfirst:
            # Drop the first message only if our current channel is the same as
            # the channel we've been instructed to look at.
            iterable.next()
        predicates = list(utils.iter.flatten(predicates.itervalues()))
        # Make sure the user can't get messages from channels they aren't in
        def userInChannel(m):
            return m.args[0] in irc.state.channels and msg.nick in irc.state.channels[m.args[0]].users

        predicates.append(userInChannel)
        # Make sure the user can't get messages from a +s channel unless
        # they're calling the command from that channel or from a query
        def notSecretMsg(m):
            return (
                not irc.isChannel(msg.args[0])
                or msg.args[0] == m.args[0]
                or (m.args[0] in irc.state.channels and "s" not in irc.state.channels[m.args[0]].modes)
            )

        predicates.append(notSecretMsg)
        resp = []
        if irc.nested and not self.registryValue("last.nested.includeTimestamp"):
            tsf = None
        else:
            tsf = self.registryValue("timestampFormat")
        if irc.nested and not self.registryValue("last.nested.includeNick"):
            showNick = False
        else:
            showNick = True
        for m in iterable:
            for predicate in predicates:
                try:
                    if not predicate(m):
                        break
                except RegexpTimeout:
                    irc.error(_("The regular expression timed out."))
                    return
            else:
                if nolimit:
                    resp.append(ircmsgs.prettyPrint(m, timestampFormat=tsf, showNick=showNick))
                else:
                    irc.reply(ircmsgs.prettyPrint(m, timestampFormat=tsf, showNick=showNick))
                    return
        if not resp:
            irc.error(
                _("I couldn't find a message matching that criteria in " "my history of %s messages.")
                % len(irc.state.history)
            )
        else:
            irc.reply(format("%L", resp))
开发者ID:Athemis,项目名称:Limnoria,代码行数:101,代码来源:plugin.py


注:本文中的supybot.ircmsgs.prettyPrint函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。