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

Python ircmsgs.isAction函数代码示例

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

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



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

示例1: doPrivmsg

 def doPrivmsg(self, irc, msg):
     channel = msg.args[0]
     self.timeout(irc, channel)
     if ircmsgs.isCtcp(msg) and not ircmsgs.isAction(msg):
         return
     #channel = msg.args[0]
     if irc.isChannel(channel):
         if ircmsgs.isAction(msg):
             text = ircmsgs.unAction(msg)
         else:
             text = msg.args[1]
         if 'ping' in text.lower():
             text = text.replace('!','')\
                     .replace(',','')\
                     .replace(':','')\
                     .replace('?','')
             if len(text.split()) == 2:        
                 if text.lower().startswith('ping'):
                     self.ping(irc, msg, channel, text, inverse=True)
                 elif text.lower().endswith('ping'):
                     self.ping(irc, msg, channel, text)
         elif 'pong' in text.lower():
             text = text.replace(',','')\
                     .replace(':','')\
                     .replace('!','')\
                     .replace('?','')
             if len(text.split()) == 2:        
                 if text.lower().startswith('pong'):
                     self.pong(irc, msg, channel, text, inverse=True)
                 elif text.lower().endswith('pong'):
                     self.pong(irc, msg, channel, text)
开发者ID:Mika64,项目名称:Pingus,代码行数:31,代码来源:plugin.py


示例2: doPrivmsg

    def doPrivmsg(self, irc, msg):
        """check regular IRC chat for votes"""
        # check for a regular channel message
        if ircmsgs.isCtcp(msg) and not ircmsgs.isAction(msg):
            return
        channel = msg.args[0]
        if not irc.isChannel(channel):
            return
        
        # is there an active vote in the channel?
        if not (channel in self._voter_decision):
            return
        
        # get the text of the vote
        if ircmsgs.isAction(msg):
            text = ircmsgs.unAction(msg)
        else:
            text = msg.args[1]
        
        # is it a vote?
        if not text in VALID_VOTE:
            return
        
        # get the voter
        voter = msg.prefix

        # update the cache
        self._voter_decision[channel][voter] = text
开发者ID:arikb,项目名称:Meeting,代码行数:28,代码来源:plugin.py


示例3: outFilter

 def outFilter(self, irc, msg):
     if msg.command == 'PRIVMSG':
         if ircmsgs.isAction(msg):
             s = ircmsgs.unAction(msg)
         else:
             s = msg.args[1]
         reply = []
         bananaProb = 0.1
         maybeBanana = False
         chance = random.random()
         self.log.debug("bananchance: "+str(chance)+" "+str(bananaProb)+" "+s)
         if chance < bananaProb:
             for word in s.split():
                 if maybeBanana:
                     maybeBanana = False
                     chance = random.random()
                     reply.append("banana")
                 else:
                     reply.append(word)
                 if word == "the":
                     maybeBanana = True
             if ircmsgs.isAction(msg):
                 msg = ircmsgs.action(msg.args[0], " ".join(reply), msg=msg)
             else:
                 msg = ircmsgs.IrcMsg(msg = msg, args=(msg.args[0], " ".join(reply)))
     return msg
开发者ID:tdfischer,项目名称:supybot-ArtificialIntelligence,代码行数:26,代码来源:plugin.py


示例4: doPrivmsg

 def doPrivmsg(self, irc, msg):
     if ircmsgs.isCtcp(msg) and not ircmsgs.isAction(msg):
         return
     channel = msg.args[0]
     if irc.isChannel(channel):
         if ircmsgs.isAction(msg):
             text = ircmsgs.unAction(msg)
         else:
             text = msg.args[1]
         for info in present_links(text, color=True):
             irc.reply(info, prefixNick=False)
开发者ID:thefinn93,项目名称:UppitLinks,代码行数:11,代码来源:plugin.py


示例5: doPrivmsg

 def doPrivmsg(self, irc, msg):
     if ircmsgs.isCtcp(msg) and not ircmsgs.isAction(msg):
         return
     channel = msg.args[0]
     if irc.isChannel(channel):
         if ircmsgs.isAction(msg):
             text = ircmsgs.unAction(msg)
         else:
             text = msg.args[1]
         for url in utils.web.urlRe.findall(text):
             self.fetch_url(irc, channel, url)
开发者ID:HacDC,项目名称:wopr,代码行数:11,代码来源:plugin.py


示例6: doPrivmsg

 def doPrivmsg(self, irc, msg):
     if ircmsgs.isCtcp(msg) and not ircmsgs.isAction(msg):
         return
     channel = msg.args[0]
     if callbacks.addressed(irc.nick, msg):
         return
     if self.registryValue('titleSnarfer', channel):
         if irc.isChannel(channel):
             if ircmsgs.isAction(msg):
                 text = ircmsgs.unAction(msg)
             else:
                 text = msg.args[1]
             for info in present_links(text, color=True):
                 irc.reply(info, prefixNick=False, private=False, notice=False)
开发者ID:AwwCookies,项目名称:peacekeeper,代码行数:14,代码来源:plugin.py


示例7: doPrivmsg

 def doPrivmsg(self, irc, msg):
     (recipients, text) = msg.args
     for channel in recipients.split(','):
         if irc.isChannel(channel) and not self.logging_disabled.get(channel):
             noLogPrefix = self.registryValue('noLogPrefix', channel)
             if ((noLogPrefix and text.startswith(noLogPrefix)) or
                (text.startswith('@on')) or
                (text.startswith('mb-chat-logger: on')) or
                (text.startswith('mb-chat-logger, on'))):
                 return
             nick = msg.nick or irc.nick
             if ircmsgs.isAction(msg):
                 self.doLog(irc, channel, 'log',
                            '* %s %s', nick, ircmsgs.unAction(msg))
                 self.doLog(irc, channel, 'html',
                            '<span>&bull; <span class="nick">%s</span> %s</span>', 
                            cgi.escape(nick),
                            replaceurls(cgi.escape(ircmsgs.unAction(msg))),
                            cls="action privmsg")
             else:
                 self.doLog(irc, channel, 'log', '<%s> %s', nick, text)
                 self.doLog(irc, channel, 'html', 
                            '<span><span class="nick">&lt;%s&gt;</span> %s</span>', 
                            cgi.escape(nick), 
                            replaceurls(cgi.escape(text)),
                            cls="privmsg")
开发者ID:ianmcorvidae,项目名称:mb-channel-logger-plugin,代码行数:26,代码来源:plugin.py


示例8: 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


示例9: replacer

    def replacer(self, irc, msg, regex):
        if not self.registryValue('enable', msg.args[0]):
            return None
        iterable = reversed(irc.state.history)
        msg.tag('Replacer')
        target = regex.group('nick') or ''

        if target:
            checkNick = target
            prefix = '%s thinks %s' % (msg.nick, target)
        else:
            checkNick = msg.nick
            prefix = msg.nick

        try:
            message = 's' + msg.args[1][len(target):].split('s', 1)[-1]
            (pattern, replacement, count) = self._unpack_sed(message)
        except ValueError as e:
            self.log.warning(_("Replacer error: %s"), e)
            if self.registryValue('displayErrors', msg.args[0]):
                irc.error(_("Replacer error: %s" % e), Raise=True)
            return None

        next(iterable)
        for m in iterable:
            if m.nick == checkNick and \
                    m.args[0] == msg.args[0] and \
                    m.command == 'PRIVMSG':

                if ircmsgs.isAction(m):
                    text = ircmsgs.unAction(m)
                    tmpl = 'do'
                else:
                    text = m.args[1]
                    tmpl = 'say'

                try:
                    if not self._regexsearch(text, pattern):
                        continue
                except TimeoutError as e: # Isn't working for some reason
                    self.log.error('TIMEOUT ERROR CAUGHT!!')
                    break
                except Exception as e:
                    self.log.error('Replacer: %s' % type(e).__name__)
                    break

                if self.registryValue('ignoreRegex', msg.args[0]) and \
                        m.tagged('Replacer'):
                    continue
                irc.reply(_("%s meant to %s “ %s ”") %
                          (prefix, tmpl, pattern.sub(replacement,
                           text, count)), prefixNick=False)
                return None

        self.log.debug(_("""Replacer: Search %r not found in the last %i
                       messages."""), regex, len(irc.state.history))
        if self.registryValue("displayErrors", msg.args[0]):
            irc.error(_("Search not found in the last %i messages.") %
                      len(irc.state.history), Raise=True)
        return None
开发者ID:ProgVal,项目名称:t3chguy-Limnoria-Plugins,代码行数:60,代码来源:plugin.py


示例10: doPrivmsg

    def doPrivmsg(self, irc, msg):
        channel = msg.args[0]
        linkapi = LinkDBApi()

        if irc.isChannel(channel):
            if ircmsgs.isAction(msg):
                text = ircmsgs.unAction(msg)
            else:
                text = msg.args[1]

            usrmsg = safe_unicode(text)
            for url in utils.web.urlRe.findall(usrmsg):
                if re.search(badurls, url) is not None:
                    continue

                uid = linkapi.insert_and_get_uid(msg.nick)
                urlseen = linkapi.get_url_and_timestamp(url)

                if urlseen is "":
                    titlename = get_url_title(url)
                    if len(titlename) > 0:
                        linkid = linkapi.insert_and_get_linkid(uid, \
                                     titlename, url)
                        irc.reply("Title: %s" % (titlename))
                else:
                    if linkapi.is_link_old(url):
                        linkapi.updateLinkLastseen(url)
                    irc.reply("Title: %s [title updated: %s]" % (urlseen[0], \
                              time.ctime(urlseen[1])))
开发者ID:weezel,项目名称:supybot-plugins,代码行数:29,代码来源:plugin.py


示例11: doPrivmsg

 def doPrivmsg(self, irc, msg):
     if ircmsgs.isCtcp(msg) and not ircmsgs.isAction(msg):
         return
     channel = msg.args[0]
     if irc.isChannel(channel):
         if ircmsgs.isAction(msg):
             text = ircmsgs.unAction(msg)
         else:
             text = msg.args[1]
         for url in utils.web.urlRe.findall(text):
             r = self.registryValue('nonSnarfingRegexp', channel)
             if r and r.search(url):
                 self.log.debug('Skipping adding %u to db.', url)
                 continue
             self.log.debug('Adding %u to db.', url)
             self.db.add(channel, url, msg)
开发者ID:ElectroCode,项目名称:Limnoria,代码行数:16,代码来源:plugin.py


示例12: doPrivmsg

 def doPrivmsg(self, msg):
     isAction = ircmsgs.isAction(msg)
     if ircmsgs.isCtcp(msg) and not isAction:
         return
     self.doPayload(*msg.args)
     if isAction:
         self.actions += 1
开发者ID:Elwell,项目名称:supybot,代码行数:7,代码来源:plugin.py


示例13: 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


示例14: assertActionRegexp

 def assertActionRegexp(self, query, regexp, flags=re.I, **kwargs):
     m = self._feedMsg(query, **kwargs)
     if m is None:
         raise TimeoutError, query
     self.failUnless(ircmsgs.isAction(m))
     s = ircmsgs.unAction(m)
     self.failUnless(re.search(regexp, s, flags), "%r does not match %r" % (s, regexp))
开发者ID:cnelsonsic,项目名称:Limnoria,代码行数:7,代码来源:test.py


示例15: doPrivmsg

    def doPrivmsg(self, irc, msg):
        global BADURLS
        channel = msg.args[0]
        linkapi = LinkDBApi()

        if irc.isChannel(channel):
            if ircmsgs.isAction(msg):
                text = ircmsgs.unAction(msg)
            else:
                text = msg.args[1]

            for url in utils.web.urlRe.findall(text):
                if re.search(BADURLS, url) is not None:
                    continue

                url = unicode(url, "utf-8")
                urlseen = linkapi.getByLink(url)
                if urlseen is "":
                    titlename = self.title(url)
                    if len(titlename) > 0:
                        linkapi.insertLink(msg.nick, titlename, url)
                        try:
                            irc.reply("%s [%s]" % (titlename, url))
                        except UnicodeDecodeError:
                            irc.reply("%s [%s]" % (titlename.encode("utf-8"), url))
                else:
                    linkapi.updateLinkLastseen(url)
                    irc.reply("%s [%s]" % (urlseen[2], urlseen[3]))
开发者ID:rgarch,项目名称:linux-files,代码行数:28,代码来源:plugin.py


示例16: _formatPrivmsg

 def _formatPrivmsg(self, nick, network, msg):
     channel = msg.args[0]
     if self.registryValue('includeNetwork', channel):
         network = '@' + network
     else:
         network = ''
     # colorize nicks
     color = self.registryValue('color', channel) # Also used further down.
     if color:
         nick = ircutils.IrcString(nick)
         newnick = ircutils.mircColor(nick, *ircutils.canonicalColor(nick))
         colors = ircutils.canonicalColor(nick, shift=4)
         nick = newnick
     if ircmsgs.isAction(msg):
         if color:
             t = ircutils.mircColor('*', *colors)
         else:
             t = '*'
         s = format('%s %s%s %s', t, nick, network, ircmsgs.unAction(msg))
     else:
         if color:
             lt = ircutils.mircColor('<', *colors)
             gt = ircutils.mircColor('>', *colors)
         else:
             lt = '<'
             gt = '>'
         s = format('%s%s%s%s %s', lt, nick, network, gt, msg.args[1])
     return s
开发者ID:GlitterCakes,项目名称:PoohBot,代码行数:28,代码来源:plugin.py


示例17: doPrivmsg

 def doPrivmsg(self, irc, msg):
     if ircmsgs.isCtcp(msg) and not ircmsgs.isAction(msg):
         return
     (channel, text) = msg.args
     if irc.isChannel(channel):
         irc = self._getRealIrc(irc)
         if channel not in self.registryValue('channels'):
             return
         ignores = self.registryValue('ignores', channel)
         for ignore in ignores:
             if ircutils.hostmaskPatternEqual(ignore, msg.prefix):
                 self.log.debug('Refusing to relay %s, ignored by %s.',
                                msg.prefix, ignore)
                 return
         # Let's try to detect other relay bots.
         if self._checkRelayMsg(msg):
             if self.registryValue('punishOtherRelayBots', channel):
                 self._punishRelayers(msg)
             # Either way, we don't relay the message.
             else:
                 self.log.warning('Refusing to relay message from %s, '
                                  'it appears to be a relay message.',
                                  msg.prefix)
         else:
             network = self._getIrcName(irc)
             s = self._formatPrivmsg(msg.nick, network, msg)
             m = self._msgmaker(channel, s)
             self._sendToOthers(irc, m)
开发者ID:GlitterCakes,项目名称:PoohBot,代码行数:28,代码来源:plugin.py


示例18: newf

 def newf(self, irc, msg, match, *L, **kwargs):
     url = match.group(0)
     channel = msg.args[0]
     if not irc.isChannel(channel) or (ircmsgs.isCtcp(msg) and not
                                       ircmsgs.isAction(msg)):
         return
     if ircdb.channels.getChannel(channel).lobotomized:
         self.log.debug('Not snarfing in %s: lobotomized.', channel)
         return
     if _snarfed.has(channel, url):
         self.log.info('Throttling snarf of %s in %s.', url, channel)
         return
     irc = SnarfIrc(irc, channel, url)
     def doSnarf():
         _snarfLock.acquire()
         try:
             # This has to be *after* we've acquired the lock so we can be
             # sure that all previous urlSnarfers have already run to
             # completion.
             if msg.repliedTo:
                 self.log.debug('Not snarfing, msg is already repliedTo.')
                 return
             f(self, irc, msg, match, *L, **kwargs)
         finally:
             _snarfLock.release()
     if threading.currentThread() is not world.mainThread:
         doSnarf()
     else:
         L = list(L)
         t = UrlSnarfThread(target=doSnarf, url=url)
         t.start()
开发者ID:boamaod,项目名称:Limnoria,代码行数:31,代码来源:commands.py


示例19: doPrivmsg

 def doPrivmsg(self, irc, msg):
     (recipients, text) = msg.args
     for channel in recipients.split(','):
         if irc.isChannel(channel):
             noLogPrefix = self.registryValue('noLogPrefix', channel)
             cap = ircdb.makeChannelCapability(channel, 'logChannelMessages')
             try:
                 logChannelMessages = ircdb.checkCapability(msg.prefix, cap,
                     ignoreOwner=True)
             except KeyError:
                 logChannelMessages = True
             nick = msg.nick or irc.nick
             if msg.tagged('LogsToDB__relayed'):
                 (nick, text) = text.split(' ', 1)
                 nick = nick[1:-1]
                 msg.args = (recipients, text)
             if (noLogPrefix and text.startswith(noLogPrefix)) or \
                     not logChannelMessages:
                 text = '-= THIS MESSAGE NOT LOGGED =-'
             if ircmsgs.isAction(msg):
                 self.doLog(irc, channel,
                            '* %s %s\n', nick, ircmsgs.unAction(msg))
             else:
                 self.doLog(irc, channel, '<%s> %s\n', nick, text)
             
             message = msg.args[1]
             self.logViewerDB.add_message(msg.nick, msg.prefix, message, channel)
             self.logViewerFile.write_message(msg.nick, message)
开发者ID:hashweb,项目名称:LogsToDB,代码行数:28,代码来源:plugin.py


示例20: tokenize

 def tokenize(self, m):
     if ircmsgs.isAction(m):
         return ircmsgs.unAction(m).split()
     elif ircmsgs.isCtcp(m):
         return []
     else:
         return m.args[1].split()
开发者ID:furtherandsun,项目名称:Supybot-Markov,代码行数:7,代码来源:plugin.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python ircmsgs.isCtcp函数代码示例发布时间:2022-05-27
下一篇:
Python ircmsgs.ban函数代码示例发布时间: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