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


Python ircmsgs.isCtcp函数代码示例

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


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

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

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

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

示例4: doPrivmsg

 def doPrivmsg(self, irc, msg):
     channel = msg.args[0].lower()
     text = msg.args[1].strip()
     # ignore ctcp, action and only messages in a channel.
     # if txt.startswith(conf.supybot.reply.whenAddressedBy.chars()):
     if ircmsgs.isCtcp(msg) or ircmsgs.isAction(msg) or not irc.isChannel(channel):
         return
     # on to the text. check if we're ignoring the text matching regex here.
     if re.match(self.registryValue('ignoreRegex'), text):
         return
     # should we strip urls from text?
     if self.registryValue('stripUrls'):
         text = re.sub(r'(http[^\s]*)', '', text)
     # determine probability if addressed or not.
     if callbacks.addressed(irc.nick, msg):
         text = re.sub('(' + irc.nick + '*?\W+)', '', text, re.IGNORECASE)
         probability = self.registryValue('probabilityWhenAddressed', channel)
     else:
         probability = self.registryValue('probability', channel)
     # should we strip nicks from the text?
     if self.registryValue('stripNicks'):
         removenicks = '|'.join(item + '\W.*?\s' for item in irc.stats.channels[channel].users)
         text = re.sub(r'' + removenicks + '', '', text)
     # finally, pass to our learn function.
     self._learn(irc, channel, text, probability)
开发者ID:carriercomm,项目名称:MegaHAL,代码行数:25,代码来源:plugin.py

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

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

示例7: doPrivmsg

 def doPrivmsg(self, irc, msg):
     assert self is irc.callbacks[0], \
            'Owner isn\'t first callback: %r' % irc.callbacks
     if ircmsgs.isCtcp(msg):
         return
     s = callbacks.addressed(irc.nick, msg)
     if s:
         ignored = ircdb.checkIgnored(msg.prefix)
         if ignored:
             self.log.info('Ignoring command from %s.', msg.prefix)
             return
         maximum = conf.supybot.abuse.flood.command.maximum()
         self.commands.enqueue(msg)
         if conf.supybot.abuse.flood.command() \
            and self.commands.len(msg) > maximum \
            and not ircdb.checkCapability(msg.prefix, 'trusted'):
             punishment = conf.supybot.abuse.flood.command.punishment()
             banmask = ircutils.banmask(msg.prefix)
             self.log.info('Ignoring %s for %s seconds due to an apparent '
                           'command flood.', banmask, punishment)
             ircdb.ignores.add(banmask, time.time() + punishment)
             irc.reply('You\'ve given me %s commands within the last '
                       'minute; I\'m now ignoring you for %s.' %
                       (maximum,
                        utils.timeElapsed(punishment, seconds=False)))
             return
         try:
             tokens = callbacks.tokenize(s, channel=msg.args[0])
             self.Proxy(irc, msg, tokens)
         except SyntaxError, e:
             irc.queueMsg(callbacks.error(msg, str(e)))
开发者ID:boamaod,项目名称:Limnoria,代码行数:31,代码来源:plugin.py

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

示例9: doNotice

 def doNotice(self, irc, msg):
     if ircmsgs.isCtcp(msg):
         try:
             (version, payload) = msg.args[1][1:-1].split(None, 1)
         except ValueError:
             return
         if version == 'VERSION':
             self.versions.setdefault(payload, []).append(msg.nick)
开发者ID:Athemis,项目名称:Limnoria,代码行数:8,代码来源:plugin.py

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

示例11: doPrivmsg

 def doPrivmsg(self, irc, msg):
     """
     Checks each channel message to see if it contains a trigger word
     """
     channel = msg.args[0]
     is_channel = irc.isChannel(channel)
     is_ctcp = ircmsgs.isCtcp(msg)        
     message = msg.args[1]
     bot_nick = irc.nick
     
     # Check origin nick to make sure the trigger
     # didn"t come from the bot.
     origin_nick = msg.nick
     
     is_message_from_self = origin_nick.lower() == bot_nick.lower()
     
     # Only react to messages/actions in a channel and to messages that aren't from
     # the bot itself.
     if is_channel and not is_ctcp and not is_message_from_self:            
         if type(message) is str and len(message):
             fact_chance = int(self.registryValue("factChance"))
             link_chance = int(self.registryValue("linkChance"))            
             throttle_seconds = int(self.registryValue("throttleInSeconds"))
             triggered = self.message_contains_trigger_word(message)
             now = datetime.datetime.now()
             seconds = 0
             
             if self.last_message_timestamp:                
                 seconds = (now - self.last_message_timestamp).total_seconds()
                 throttled = seconds < throttle_seconds
             else:
                 throttled = False
             
             if triggered is not False:
                 self.log.debug("Cayenne triggered because message contained %s" % (triggered))
                 
                 fact_rand = random.randrange(0, 100) <= fact_chance
                 link_rand = random.randrange(0, 100) <= link_chance
                 
                 if fact_rand or link_rand:
                     if throttled:                    
                         self.log.info("Cayenne throttled. Not meowing: it has been %s seconds" % (round(seconds, 1)))
                     else:
                         self.last_message_timestamp = now
                         
                         if fact_rand:
                             output = self.get_fact()
                         
                         if link_rand:
                             output = self.get_link()
                         
                         if output:
                             irc.sendMsg(ircmsgs.privmsg(channel, output))
                         else:
                             self.log.error("Cayenne: error retrieving output")
开发者ID:butterscotchstallion,项目名称:limnoria-plugins,代码行数:55,代码来源:plugin.py

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

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

示例14: shouldLog

	def shouldLog(self, irc, msg, msgtype):
		if not self.registryValue("enable"):
			return False
		if msgtype == MessageType.privmsg or msgtype == MessageType.notice:
			if not irc.isChannel(msg.args[0]):
				return False
			if ircmsgs.isCtcp(msg) and not ircmsgs.isAction(msg):
				return False
		if msgtype == MessageType.mode and msg.args[0] == irc.nick:
			return False
		return True
开发者ID:ShadowNinja,项目名称:Limnoria-plugins,代码行数:11,代码来源:plugin.py

示例15: doPrivmsg

 def doPrivmsg(self, irc, msg):
     # We don't handle this if we've been addressed because invalidCommand
     # will handle it for us.  This prevents us from accessing the db twice
     # and therefore crashing.
     if not (msg.addressed or msg.repliedTo):
         channel = msg.args[0]
         if irc.isChannel(channel) and \
            not ircmsgs.isCtcp(msg) and \
            self.registryValue('allowUnaddressedKarma', channel):
             irc = callbacks.SimpleProxy(irc, msg)
             thing = msg.args[1].rstrip()
             self._doKarma(irc, msg, channel, thing)
开发者ID:GLolol,项目名称:Limnoria,代码行数:12,代码来源:plugin.py


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