• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python ircutils.stripFormatting函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: invalidCommand

    def invalidCommand(self,irc,msg,tokens):
        try:
            self.log.debug('Channel is: "+str(irc.isChannel(msg.args[0]))')
            self.log.debug("Message is: "+str(msg.args))
        except:
            self.log.error("message not retrievable.")

        if irc.isChannel(msg.args[0]) and self.registryValue('react',msg.args[0]):
            channel = msg.args[0]
            self.log.debug("Fetching response...")
            reply = self.getResponse(irc,msg,ircutils.stripFormatting(msg.args[1]).strip())
            self.log.debug("Got response!")
            if reply is not None:
                self.log.debug("Reply is: "+str(reply))
                if self.registryValue('enable', channel):
                     irc.reply(reply)
            else:
                irc.reply("My AI is down, sorry! :( I couldn't process what you said... blame it on a brain fart. :P")
        elif (msg.args[0] == irc.nick) and self.registryValue('reactprivate',msg.args[0]):
            err = ""
            self.log.debug("Fetching response...")
            reply = self.getResponse(irc,msg,ircutils.stripFormatting(msg.args[1]).strip())
            self.log.debug("Got response!")
            if reply is not None:
                self.log.debug("Reply is: "+str(reply))
                if self.registryValue('enable', channel):
                     irc.reply(reply)
            else:
                irc.reply("My AI is down, sorry! :( I couldn't process what you said... blame it on a brain fart. :P", err, None, True, None, None)
开发者ID:AlanBell,项目名称:Supybot-plugins,代码行数:29,代码来源:plugin.py


示例2: testStripFormatting

 def testStripFormatting(self):
     self.assertEqual(ircutils.stripFormatting(ircutils.bold('foo')), 'foo')
     self.assertEqual(ircutils.stripFormatting(ircutils.reverse('foo')),
                      'foo')
     self.assertEqual(ircutils.stripFormatting(ircutils.underline('foo')),
                      'foo')
     self.assertEqual(ircutils.stripFormatting('\x02bold\x0302,04foo\x03'
                                               'bar\x0f'),
                      'boldfoobar')
     s = ircutils.mircColor('[', 'blue') + ircutils.bold('09:21')
     self.assertEqual(ircutils.stripFormatting(s), '[09:21')
开发者ID:krattai,项目名称:AEBL,代码行数:11,代码来源:test_ircutils.py


示例3: tp

    def tp(self, irc, msg, args, text):
        """tp <text>

        Translates <text> through multiple rounds of Google Translate to get amusing results.
        """
        outlang = self.registryValue('language', msg.args[0])
        if outlang not in self.langs:
            irc.error("Unrecognized output language. Please set "
                "'config plugins.wte.language' correctly.", Raise=True)

        # Randomly choose 4 to 8 languages from the list of supported languages.
        # The amount can be adjusted if you really wish - 4 to 8 is reasonable
        # in that it gives interesting results but doesn't spam Google's API
        # (and risk getting blocked) too much.
        ll = random.sample(self.langs.keys(), random.randint(4,8))
        self.log.debug(format("TranslateParty: Using %i languages: %L "
            "(outlang %s)", len(ll), ll, outlang))

        text = ircutils.stripFormatting(text)
        # For every language in this list, translate the text given from
        # auto-detect into the target language, and replace the original text
        # with it.
        for targetlang in ll:
            text = self.getTranslation(irc, "auto", targetlang, text)
        text = self.getTranslation(irc, "auto", outlang, text)
        text = text.strip()

        if self.registryValue("verbose", msg.args[0]):
            # Verbose output was requested, show the language codes AND
            # names that we translated through.
            languages = [ircutils.bold("%s [%s]" % (self.langs[lang], lang)) for lang in ll]
            irc.reply(format("Translated through \x02%i\x02 languages: %L "
                             "(output language %s)", len(ll), languages, outlang))
        irc.reply(text)
开发者ID:GLolol,项目名称:SupyPlugins,代码行数:34,代码来源:plugin.py


示例4: combine

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)
开发者ID:Wintervenom,项目名称:Xn,代码行数:31,代码来源:wvmsupybot.py


示例5: doLog

 def doLog(self, irc, channel, notice, nick, s, *args):
     ''' notice: Boolean. True if message should be styled as a notice. '''
     if not self.registryValue('enable', channel):
         return
     s = format(s, *args)
     channel = self.normalizeChannel(irc, channel)
     log = self.getLog(irc, channel)
     row_classes = row_class
     if notice:
         row_classes = row_class + " " + notice_class
     log.write('<p class="%s">' % row_classes)
     if self.registryValue('timestamp', channel):
         log.write('<span class="%s">' % timestamp_class)
         self.timestamp(log)
         log.write('</span>')
     if nick != None:
         log.write('<span class="%s">' % nick_class)
         log.write(html_escape("<%s> " %nick))
         log.write('</span>')
     if self.registryValue('stripFormatting', channel):
         s = ircutils.stripFormatting(s)
     log.write('<span class="%s">' % message_class)
     log.write(self.linkify(html_escape(s)))
     log.write('</span>')
     log.write('</p>\n')
     if self.registryValue('flushImmediately'):
         log.flush()
开发者ID:Balooga,项目名称:HtmlLogger,代码行数:27,代码来源:plugin.py


示例6: inFilter

 def inFilter(self, irc, msg):
     self.filtering = True
     # We need to check for bad words here rather than in doPrivmsg because
     # messages don't get to doPrivmsg if the user is ignored.
     if msg.command == 'PRIVMSG':
         channel = msg.args[0]
         self.updateRegexp(channel)
         s = ircutils.stripFormatting(msg.args[1])
         if ircutils.isChannel(channel) and self.registryValue('kick', channel):
             if self.words and self.regexp.search(s):
                 c = irc.state.channels[channel]
                 cap = ircdb.makeChannelCapability(channel, 'op')
                 if c.isHalfopPlus(irc.nick):
                     if c.isHalfopPlus(msg.nick) or \
                             ircdb.checkCapability(msg.prefix, cap):
                         self.log.debug("Not kicking %s from %s, because "
                                        "they are halfop+ or can't be "
                                        "kicked.", msg.nick, channel)
                     else:
                         message = self.registryValue('kick.message', channel)
                         irc.queueMsg(ircmsgs.kick(channel, msg.nick, message))
                 else:
                     self.log.warning('Should kick %s from %s, but not opped.',
                                      msg.nick, channel)
     return msg
开发者ID:AssetsIncorporated,项目名称:Limnoria,代码行数:25,代码来源:plugin.py


示例7: doNickservNotice

 def doNickservNotice(self, irc, msg):
     nick = self._getNick()
     s = ircutils.stripFormatting(msg.args[1].lower())
     on = 'on %s' % irc.network
     networkGroup = conf.supybot.networks.get(irc.network)
     if 'incorrect' in s or 'denied' in s:
         log = 'Received "Password Incorrect" from NickServ %s.  ' \
               'Resetting password to empty.' % on
         self.log.warning(log)
         self.sentGhost = time.time()
         self._setNickServPassword(nick, '')
     elif self._ghosted(s):
         self.log.info('Received "GHOST succeeded" from NickServ %s.', on)
         self.sentGhost = None
         self.identified = False
         irc.queueMsg(ircmsgs.nick(nick))
     elif 'is not registered' in s:
         self.log.info('Received "Nick not registered" from NickServ %s.',
                       on)
     elif 'currently' in s and 'isn\'t' in s or 'is not' in s:
         # The nick isn't online, let's change our nick to it.
         self.sentGhost = None
         irc.queueMsg(ircmsgs.nick(nick))
     elif ('owned by someone else' in s) or \
          ('nickname is registered and protected' in s) or \
          ('nick belongs to another user' in s):
         # freenode, arstechnica, chatjunkies
         # oftc, zirc.org
         # sorcery
         self.log.info('Received "Registered nick" from NickServ %s.', on)
     elif '/msg' in s and 'id' in s and 'password' in s:
         # Usage info for identify command; ignore.
         self.log.debug('Got usage info for identify command %s.', on)
     elif ('please choose a different nick' in s): # oftc, part 3
         # This is a catch-all for redundant messages from nickserv.
         pass
     elif ('now recognized' in s) or \
          ('already identified' in s) or \
          ('password accepted' in s) or \
          ('now identified' in s):
         # freenode, oftc, arstechnica, zirc, ....
         # sorcery
         self.log.info('Received "Password accepted" from NickServ %s.', on)
         self.identified = True
         for channel in irc.state.channels.keys():
             self.checkPrivileges(irc, channel)
         for channel in self.channels:
             irc.queueMsg(networkGroup.channels.join(channel))
         if self.waitingJoins:
             for m in self.waitingJoins:
                 irc.sendMsg(m)
             self.waitingJoins = []
     elif 'not yet authenticated' in s:
         # zirc.org has this, it requires an auth code.
         email = s.split()[-1]
         self.log.warning('Received "Nick not yet authenticated" from '
                          'NickServ %s.  Check email at %s and send the '
                          'auth command to NickServ.', on, email)
     else:
         self.log.debug('Unexpected notice from NickServ %s: %q.', on, s)
开发者ID:Kefkius,项目名称:mazabot,代码行数:60,代码来源:plugin.py


示例8: soccerformation

    def soccerformation(self, irc, msg, args):
        """
        Display a random lineup for channel users.
        """

        if not ircutils.isChannel(msg.args[0]):  # make sure its run in a channel.
            irc.reply("ERROR: Must be run from a channel.")
            return
        # now make sure we have more than 9 users.
        users = [i for i in irc.state.channels[msg.args[0]].users]
        if len(users) < 11:  # need >9 users.
            irc.reply("Sorry, I can only run this in a channel with more than 9 users.")
            return
        # now that we're good..
        formations = {'4-4-2':['(GK)', '(RB)', '(CB)', '(CB)', '(LB)', '(RM)', '(LM)', '(CM)', '(CM)', '(FW)', '(FW)'],
                      '4-4-1-1':['(GK)', '(RB)', '(CB)', '(CB)', '(LB)', '(RM)', '(LM)', '(CM)', '(CM)', '(ST)', '(FW)'],
                      '4-5-1':['(GK)', '(RB)', '(CB)', '(CB)', '(LB)', '(RM)', '(LM)', '(CM)', '(CM)', '(CM)', '(ST)'],
                      '3-5-1-1':['(GK)', '(CB)', '(CB)', '(SW)', '(RM)', '(CM)', '(LM)', '(CM)', '(CM)', '(FW)', '(ST)'],
                      '10-1 (CHELSEA)':['(GK)', '(LB)', '(CB)', '(RB)', '(CB)', '(CB)', '(CB)', '(CB)', '(CB)', '(CB)', '(DROGBA)'],
                      '8-1-1 (PARK THE BUS)':['(GK)', '(LB)', '(CB)', '(RB)', '(CB)', '(CB)', '(CB)', '(CB)', '(CB)', '(CM)', '(ST)']
                     }
        formation = random.choice(formations.keys())
        random.shuffle(formations[formation])  # shuffle.
        lineup = []  # list for output.
        for position in formations[formation]:  # iterate through and highlight.
            a = random.choice(users)  # pick a random user.
            users.remove(a)  # remove so its unique. append below.
            lineup.append("{0}{1}".format(ircutils.bold(a), position))
        # now output.
        output = "{0} ALL-STAR LINEUP ({1}) :: {2}".format(ircutils.mircColor(msg.args[0], 'red'), formation, ", ".join(lineup))
        if not self.registryValue('disableANSI', msg.args[0]):  # display color or not?
            irc.reply(output)
        else:
            irc.reply(ircutils.stripFormatting(output))
开发者ID:reticulatingspline,项目名称:Soccer,代码行数:34,代码来源:plugin.py


示例9: msgtotext

def msgtotext(msg):
    """
    Returns only the message text from an IrcMsg (<msg>).
    """
    isaction = ircmsgs.isAction(msg)
    text = ircmsgs.unAction(msg) if isaction else msg.args[1]
    return ircutils.stripFormatting(text), isaction
开发者ID:Wintervenom,项目名称:Xn,代码行数:7,代码来源:wvmsupybot.py


示例10: inFilter

 def inFilter(self, irc, msg):
     if ircutils.isChannel(msg.args[0]):
         if self.registryValue('enabled', msg.args[0]) and \
            len(msg.args) > 1:
             s = ircutils.stripFormatting(msg.args[1])
             msg = ircmsgs.privmsg(msg.args[0], s, msg=msg)
             return msg
     return msg
开发者ID:D0MF,项目名称:supybot-plugins-1,代码行数:8,代码来源:plugin.py


示例11: doPrivmsg

 def doPrivmsg(self, irc, msg):
     if ircmsgs.isCtcp(msg) and not ircmsgs.isAction(msg):
         return
     if ircutils.isChannel(msg.args[0]) and self._is_voting_enabled(irc, msg):
         channel = msg.args[0]
         message = ircutils.stripFormatting(msg.args[1])
         match = self.regexp.match(message)
         if match and match.group(1) in irc.state.channels[channel].users:
             self._gegen(irc, msg, match.group(1))
开发者ID:buckket,项目名称:supybot-scherbengericht,代码行数:9,代码来源:plugin.py


示例12: doBounce

 def doBounce(self, irc, s, channel, **kw):
     channel = self.normalizeChannel(irc, channel)
     s = ircutils.stripFormatting(s)
     for t in self.targets:
         if ircutils.isChannel(channel):
             inreply = channel
         else:
             inreply = kw['nick']
         t.sendReply(s.strip(), source='bnc', inreply=inreply, **kw)
开发者ID:D0MF,项目名称:supybot-plugins-1,代码行数:9,代码来源:plugin.py


示例13: _cleantext

    def _cleantext(self, text):
        """Clean-up text for input into corpus."""

        text = self._decode_irc(text)
        text = ircutils.stripFormatting(text)
        text = text.strip()
        text = re.sub("[^[email protected]!?;:/%\$§\-_ ]", " ", text)
        text = utils.str.normalizeWhitespace(text)
        return text
开发者ID:carriercomm,项目名称:MegaHAL,代码行数:9,代码来源:plugin.py


示例14: doLog

 def doLog(self, irc, channel, s):
     if not self.registryValue('enabled', channel):
         return
     channel = ircutils.toLower(channel) 
     if channel not in self.logs.keys():
         self.logs[channel] = []
     format = conf.supybot.log.timestampFormat()
     if format:
         s = time.strftime(format, time.gmtime()) + " " + ircutils.stripFormatting(s)
     self.logs[channel] = self.logs[channel][-199:] + [s.strip()]
开发者ID:Affix,项目名称:Fedbot,代码行数:10,代码来源:plugin.py


示例15: outFilter

 def outFilter(self, irc, msg):
     if self.filtering and msg.command == 'PRIVMSG':
         self.updateRegexp()
         s = msg.args[1]
         if self.registryValue('stripFormatting'):
             s = ircutils.stripFormatting(s)
         t = self.regexp.sub(self.sub, s)
         if t != s:
             msg = ircmsgs.privmsg(msg.args[0], t, msg=msg)
     return msg
开发者ID:Kefkius,项目名称:mazabot,代码行数:10,代码来源:plugin.py


示例16: _checkRelayMsg

 def _checkRelayMsg(self, msg):
     channel = msg.args[0]
     if channel in self.lastRelayMsgs:
         q = self.lastRelayMsgs[channel]
         unformatted = ircutils.stripFormatting(msg.args[1])
         normalized = utils.str.normalizeWhitespace(unformatted)
         for s in q:
             if s in normalized:
                 return True
     return False
开发者ID:GlitterCakes,项目名称:PoohBot,代码行数:10,代码来源:plugin.py


示例17: _addRelayMsg

 def _addRelayMsg(self, msg):
     channel = msg.args[0]
     if channel in self.lastRelayMsgs:
         q = self.lastRelayMsgs[channel]
     else:
         q = TimeoutQueue(60) # XXX Make this configurable.
         self.lastRelayMsgs[channel] = q
     unformatted = ircutils.stripFormatting(msg.args[1])
     normalized = utils.str.normalizeWhitespace(unformatted)
     q.enqueue(normalized)
开发者ID:GlitterCakes,项目名称:PoohBot,代码行数:10,代码来源:plugin.py


示例18: outFilter

 def outFilter(self, irc, msg):
     if self.filtering and msg.command == 'PRIVMSG':
         if self.lastModified < self.words.lastModified:
             self.makeRegexp(self.words())
             self.lastModified = time.time()
         s = msg.args[1]
         if self.registryValue('stripFormatting'):
             s = ircutils.stripFormatting(s)
         s = self.regexp.sub(self.sub, s)
         msg = ircmsgs.privmsg(msg.args[0], s, msg=msg)
     return msg
开发者ID:D0MF,项目名称:supybot-plugins-1,代码行数:11,代码来源:plugin.py


示例19: normalize

 def normalize(self, s, bot, nick):
     s = ircutils.stripFormatting(s)
     s = s.strip() # After stripFormatting for formatted spaces.
     s = utils.str.normalizeWhitespace(s)
     s = self._iAm[0].sub(self._iAm[1] % nick, s)
     s = self._my[0].sub(self._my[1] % nick, s)
     s = self._your[0].sub(self._your[1] % bot, s)
     contractions = [('what\'s', 'what is'), ('where\'s', 'where is'),
                     ('who\'s', 'who is'), ('wtf\'s', 'wtf is'),]
     for (contraction, replacement) in contractions:
         if s.startswith(contraction):
             s = replacement + s[len(contraction):]
     return s
开发者ID:D0MF,项目名称:supybot-plugins,代码行数:13,代码来源:plugin.py


示例20: doLog

 def doLog(self, irc, channel, s, *args):
     if not self.registryValue('enable', channel):
         return
     s = format(s, *args)
     channel = self.normalizeChannel(irc, channel)
     log = self.getLog(irc, channel)
     if self.registryValue('timestamp', channel):
         self.timestamp(log)
     if self.registryValue('stripFormatting', channel):
         s = ircutils.stripFormatting(s)
     log.write(s)
     if self.registryValue('flushImmediately'):
         log.flush()
开发者ID:hashweb,项目名称:LogsToDB,代码行数:13,代码来源:plugin.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python ircutils.toLower函数代码示例发布时间:2022-05-27
下一篇:
Python ircutils.strEqual函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap