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


Python plugins.getChannel函数代码示例

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


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

示例1: doPrivmsg

    def doPrivmsg(self, irc, msg):

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

            isNickInMessage = irc.nick in msg.args[1]
            isCommandPrefixInMessage = any("@" in s for s in msg.args) #HACK, fix with conf.supybot.reply.whenAddressedBy.chars ?

            if isNickInMessage and not isCommandPrefixInMessage:
                speakChan = msg.args[0]
                dbChan = plugins.getChannel(speakChan)
                now = time.time()
                f = self._markov(speakChan, irc, prefixNick=False,
                                 to=speakChan, Random=True)
                schedule.addEvent(lambda: self.q.enqueue(f), now)

            elif not isNickInMessage:
                speakChan = msg.args[0]
                dbChan = plugins.getChannel(speakChan)
                canSpeak = False
                now = time.time()
                throttle = self.registryValue('randomSpeaking.throttleTime',
                                              speakChan)
                prob = self.registryValue('randomSpeaking.probability', speakChan)
                delay = self.registryValue('randomSpeaking.maxDelay', speakChan)
                if now > self.lastSpoke + throttle:
                    canSpeak = True
                if canSpeak and random.random() < prob:
                    f = self._markov(speakChan, irc, prefixNick=False,
                                     to=speakChan, Random=True)
                    schedule.addEvent(lambda: self.q.enqueue(f), now + delay)
                    self.lastSpoke = now + delay
                words = self.tokenize(msg)
                # This shouldn't happen often (CTCP messages being the possible
                # exception)
                if not words:
                    return
                if self.registryValue('ignoreBotCommands', speakChan) and \
                        callbacks.addressed(irc.nick, msg):
                    return
                words.insert(0, None)
                words.insert(0, None)
                words.append(None)
                def doPrivmsg(db):
                    for (first, second, follower) in utils.seq.window(words, 3):
                        db.addPair(dbChan, first, second, follower,
                                   isFirst=(first is None and second is None),
                                   isLast=(follower is None))
                self.q.enqueue(doPrivmsg)
开发者ID:furtherandsun,项目名称:Supybot-Markov,代码行数:48,代码来源:plugin.py

示例2: doPrivmsg

 def doPrivmsg(self, irc, msg):
     if irc.isChannel(msg.args[0]):
         channel = plugins.getChannel(msg.args[0])
         canSpeak = False
         now = time.time()
         throttle = self.registryValue('randomSpeaking.throttleTime',
                                       channel)
         prob = self.registryValue('randomSpeaking.probability', channel)
         delay = self.registryValue('randomSpeaking.maxDelay', channel)
         irc = callbacks.SimpleProxy(irc, msg)
         if now > self.lastSpoke + throttle:
             canSpeak = True
         if canSpeak and random.random() < prob:
             f = self._markov(channel, irc, prefixNick=False, to=channel,
                              Random=True)
             schedule.addEvent(lambda: self.q.enqueue(f), now + delay)
             self.lastSpoke = now + delay
         words = self.tokenize(msg)
         words.insert(0, '\n')
         words.insert(0, '\n')
         words.append('\n')
         # This shouldn't happen often (CTCP messages being the possible exception)
         if not words or len(words) == 3:
             return
         if self.registryValue('ignoreBotCommands', channel) and \
                 callbacks.addressed(irc.nick, msg):
             return
         def doPrivmsg(db):
             for (first, second, follower) in utils.seq.window(words, 3):
                 db.addPair(channel, first, second, follower)
         self.q.enqueue(doPrivmsg)
开发者ID:D0MF,项目名称:supybot-plugins,代码行数:31,代码来源:plugin.py

示例3: invalidCommand

 def invalidCommand(self, irc, msg, tokens):
     if "=~" in tokens:
         self.changeFactoid(irc, msg, tokens)
     elif tokens and tokens[0] in ("no", "no,"):
         self.replaceFactoid(irc, msg, tokens)
     elif ["is", "also"] in utils.seq.window(tokens, 2):
         self.augmentFactoid(irc, msg, tokens)
     else:
         key = " ".join(tokens)
         key = self._sanitizeKey(key)
         channel = plugins.getChannel(msg.args[0])
         fact = self.db.getFactoid(channel, key)
         if fact:
             self.db.updateRequest(channel, key, msg.prefix)
             # getFactoid returns "all results", so we need to extract the
             # first one.
             fact = fact[0]
             # Update the requested count/requested by for this key
             hostmask = msg.prefix
             # Now actually get the factoid and respond accordingly
             (type, text) = self._parseFactoid(irc, msg, fact)
             if type == "action":
                 irc.reply(text, action=True)
             elif type == "reply":
                 irc.reply(text, prefixNick=False)
             elif type == "define":
                 irc.reply(format(_("%s is %s"), key, text), prefixNick=False)
             else:
                 assert False, "Spurious type from _parseFactoid"
         else:
             if "is" in tokens or "_is_" in tokens:
                 self.addFactoid(irc, msg, tokens)
开发者ID:Hoaas,项目名称:Limnoria,代码行数:32,代码来源:plugin.py

示例4: doPrivmsg

    def doPrivmsg(self, irc, msg):
        if (irc.isChannel(msg.args[0])):

            channel = plugins.getChannel(msg.args[0])

            if (not msg.tagged("repliedTo")):
                self._reply(channel, irc, msg, False)
开发者ID:tdfischer,项目名称:supybot-Whatis,代码行数:7,代码来源:plugin.py

示例5: invalidCommand

 def invalidCommand(self, irc, msg, tokens):
     if '=~' in tokens:
         self.changeFactoid(irc, msg, tokens)
     elif tokens and tokens[0] in ('no', 'no,'):
         self.replaceFactoid(irc, msg, tokens)
     elif ['is', 'also'] in utils.seq.window(tokens, 2):
         self.augmentFactoid(irc, msg, tokens)
     else:
         key = ' '.join(tokens)
         key = self._sanitizeKey(key)
         channel = plugins.getChannel(msg.args[0])
         fact = self.db.getFactoid(channel, key)
         if fact:
             self.db.updateRequest(channel, key, msg.prefix)
             # getFactoid returns "all results", so we need to extract the
             # first one.
             fact = fact[0]
             # Update the requested count/requested by for this key
             hostmask = msg.prefix
             # Now actually get the factoid and respond accordingly
             (type, text) = self._parseFactoid(irc, msg, fact)
             if type == 'action':
                 irc.reply(text, action=True)
             elif type == 'reply':
                 irc.reply(text, prefixNick=False)
             elif type == 'define':
                 irc.reply(format(_('%s is %s'), key, text),
                                  prefixNick=False)
             else:
                 assert False, 'Spurious type from _parseFactoid'
         else:
             if 'is' in tokens or '_is_' in tokens:
                 self.addFactoid(irc, msg, tokens)
开发者ID:AssetsIncorporated,项目名称:Limnoria,代码行数:33,代码来源:plugin.py

示例6: addMsg

 def addMsg(self, msg):
     assert msg.command == 'PRIVMSG'
     (channel, text) = msg.args
     if not ircutils.isChannel(channel):
         return
     channel = plugins.getChannel(channel)
     text = text.strip().lower()
     if not text:
         return
     try:
         id = ircdb.users.getUserId(msg.prefix)
     except KeyError:
         return
     msgwords = [s.strip(nonAlphaNumeric).lower() for s in text.split()]
     if channel not in self.channelWords:
         self.channelWords[channel] = {}
     for word in self.channelWords[channel]:
         lword = word.lower()
         count = msgwords.count(lword)
         if count:
             self.channelWords[channel][word] += count
             if (channel, id) not in self:
                 self[channel, id] = {}
             if word not in self[channel, id]:
                 self[channel, id][word] = 0
             self[channel, id][word] += count
开发者ID:D0MF,项目名称:supybot-plugins-1,代码行数:26,代码来源:plugin.py

示例7: doPrivmsg

 def doPrivmsg(self, irc, msg):
     if (irc.isChannel(msg.args[0])):
         channel = plugins.getChannel(msg.args[0])
         canSpeak = False
         now = time.time()
         throttle = self.registryValue('randomSpeaking.throttleTime', channel)
         prob = self.registryValue('randomSpeaking.probability', channel)
         delay = self.registryValue('randomSpeaking.maxDelay', channel)
         irc = callbacks.SimpleProxy(irc, msg)
         if now > self.lastSpoke + throttle:
             canSpeak = True
         if canSpeak and random.random() < prob:
             #f = self._markov(channel, irc, prefixNick=False, to=channel, Random=True)
             reply = self.db.buildReply(channel, None)
             if (reply is None):
                 return
             irc.reply(reply, prefixNick=False, to=channel)
             #self._markov(channel, irc, prefixNick=False, to=channel, Random=True)
             #schedule.addEvent(lambda: self.q.enqueue(f), now+delay)
             self.lastSpoke = now+delay
         words = self.tokenize(msg)
         if not words or len(words) == 3:
             return
         if (self.registryValue('ignoreBotCommands', channel) and callbacks.addressed(irc.nick, msg)):
             return
         self.db.addPair(channel, None, words[0])
         self.db.addPair(channel, words[-1], None)
         for (first, second) in utils.seq.window(words, 2):
             self.db.addPair(channel, first, second)
开发者ID:tdfischer,项目名称:supybot-ArtificialIntelligence,代码行数:29,代码来源:plugin.py

示例8: doPayload

 def doPayload(self, channel, payload):
     channel = plugins.getChannel(channel)
     self.chars += len(payload)
     self.words += len(payload.split())
     fRe = conf.supybot.plugins.ChannelStats.get('frowns').get(channel)()
     sRe =conf.supybot.plugins.ChannelStats.get('smileys').get(channel)()
     self.frowns += len(fRe.findall(payload))
     self.smileys += len(sRe.findall(payload))
开发者ID:Elwell,项目名称:supybot,代码行数:8,代码来源:plugin.py

示例9: addFactoid

 def addFactoid(self, irc, msg, tokens):
     # First, check and see if the entire message matches a factoid key
     channel = plugins.getChannel(msg.args[0])
     id = self._getUserId(irc, msg.prefix)
     try:
         (key, fact) = self._getKeyAndFactoid(tokens)
     except ValueError, e:
         irc.error(str(e), Raise=True)
开发者ID:Athemis,项目名称:Limnoria,代码行数:8,代码来源:plugin.py

示例10: replaceFactoid

 def replaceFactoid(self, irc, msg, tokens):
     # Must be registered!
     channel = plugins.getChannel(msg.args[0])
     id = self._getUserId(irc, msg.prefix)
     del tokens[0] # remove the "no,"
     try:
         (key, fact) = self._getKeyAndFactoid(tokens)
     except ValueError, e:
         irc.error(str(e), Raise=True)
开发者ID:Athemis,项目名称:Limnoria,代码行数:9,代码来源:plugin.py

示例11: _callRegexp

 def _callRegexp(self, name, irc, msg, *L, **kwargs):
     try:
         self.irc = irc
         self.msg = msg
         # For later dynamic scoping
         channel = plugins.getChannel(msg.args[0])
         self.__parent._callRegexp(name, irc, msg, *L, **kwargs)
     finally:
         self.irc = None
         self.msg = None
开发者ID:D0MF,项目名称:supybot-plugins,代码行数:10,代码来源:plugin.py

示例12: changeFactoid

 def changeFactoid(self, irc, msg, tokens):
     id = self._getUserId(irc, msg.prefix)
     (key, regexp) = map(" ".join, utils.iter.split("=~".__eq__, tokens, maxsplit=1))
     channel = plugins.getChannel(msg.args[0])
     # Check and make sure it's in the DB
     fact = self._getFactoid(irc, channel, key)
     self._checkNotLocked(irc, channel, key)
     # It's fair game if we get to here
     try:
         r = utils.str.perlReToReplacer(regexp)
     except ValueError, e:
         irc.errorInvalid("regexp", regexp, Raise=True)
开发者ID:Hoaas,项目名称:Limnoria,代码行数:12,代码来源:plugin.py

示例13: addFactoid

 def addFactoid(self, irc, msg, tokens):
     # First, check and see if the entire message matches a factoid key
     channel = plugins.getChannel(msg.args[0])
     id = self._getUserId(irc, msg.prefix)
     try:
         (key, fact) = self._getKeyAndFactoid(tokens)
     except ValueError as e:
         irc.error(str(e), Raise=True)
     # Check and make sure it's not in the DB already
     if self.db.getFactoid(channel, key):
         irc.error(format(_('Factoid %q already exists.'), key), Raise=True)
     self.db.addFactoid(channel, key, fact, id)
     irc.replySuccess()
开发者ID:AssetsIncorporated,项目名称:Limnoria,代码行数:13,代码来源:plugin.py

示例14: addMsg

 def addMsg(self, msg, id=None):
     if ircutils.isChannel(msg.args[0]):
         channel = plugins.getChannel(msg.args[0])
         if (channel, 'channelStats') not in self:
             self[channel, 'channelStats'] = ChannelStat()
         self[channel, 'channelStats'].addMsg(msg)
         try:
             if id is None:
                 id = ircdb.users.getUserId(msg.prefix)
         except KeyError:
             return
         if (channel, id) not in self:
             self[channel, id] = UserStat()
         self[channel, id].addMsg(msg)
开发者ID:Elwell,项目名称:supybot,代码行数:14,代码来源:plugin.py

示例15: mensa

    def mensa(self, irc, msg, args, argstring):
        """[<mensa>] [<time>]

    Shows the dishes served today in <mensa>. <mensa> is one of "kath"
    (default) for Mensa 1 (Katharinenstraße), "beeth" for Mensa 2 
    (Beethovenstraße), "hbk" for Mensa HBK or "abend" for Abendmensa
    (Katharinenstraße, default for times between 3pm and 8pm).
    <time> specifies the time to show, can be one of "mo", "di", "mi", "do",
    "fr", "sa" for the respective weekdays, or "today"/"heute" (default),
    "tomorrow"/"morgen" for todays resp. tomorrows dishes. From 8pm on, the 
    dishes for the next day are shown.
    """

        multiline = self.registryValue("multiline", plugins.getChannel(msg.args[0]))

        # parse parameters if given
        day = None
        mensa = None
        if argstring and len(argstring) > 0:
            arglist = argstring.split(" ")
            for argn in arglist:
                # translate to english :P
                if argn.strip() == "morgen":
                    day = "tomorrow"
                elif argn.strip() == "heute":
                    day = "today"
                elif argn.strip() in ["mo", "di", "mi", "do", "fr", "sa", "today", "tomorrow"]:
                    day = argn

                if argn.strip() in ["kath", "beeth", "abend", "hbk", "3"]:
                    mensa = argn
                elif argn.strip().rfind("1") != -1:
                    mensa = "kath"
                elif argn.strip().rfind("2") != -1:
                    mensa = "beeth"

        # print "calling mensa with mensa=%s,day=%s,multiline=%d" % (mensa, day, multiline)

        rply = self._mensa(mensa, day, multiline)

        if rply == False:
            irc.reply("Error in parameters. See help for this command.")
            return

        # do reply
        if multiline:
            for s in rply:
                irc.reply(s, prefixNick=False)
        else:
            irc.reply(" ".join(rply), prefixNick=False)
开发者ID:rohieb,项目名称:supybot-MensaTUBS,代码行数:50,代码来源:plugin.py


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