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


Python ircmsgs.privmsg函数代码示例

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


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

示例1: _announcer

    def _announcer(self):
        for server, url in servers:
            status = self._state[server]
            new_status = check_status(url)
            for irc in world.ircs:
                if CHANNEL in irc.state.channels:
                    for type_  in new_status:
                        if new_status[type_] == status[type_]:
                            continue
                        elif new_status[type_]:
                            msg = '[%s] %s is going up' % (server,
                                    type_.capitalize())
                        else:
                            msg = '[%s] %s is going down' % (server,
                                    type_.capitalize())
                        irc.queueMsg(ircmsgs.privmsg(CHANNEL, msg))
            self._state[server] = new_status

        new_login_status = check_login_status(login)
        if new_login_status == self._login:
            pass
        elif new_login_status:
            irc.queueMsg(ircmsgs.privmsg(CHANNEL, '[login] Going up'))
        else:
            irc.queueMsg(ircmsgs.privmsg(CHANNEL, '[login] Going down'))
        self._login = new_login_status
开发者ID:AlanBell,项目名称:Supybot-plugins,代码行数:26,代码来源:plugin.py

示例2: _checkLogs

    def _checkLogs(self, irc):
        """Checks the files for new lines and, if there be any, prints them to
        IRC.

        Actual work is all done here.
        """

        # Check xlogfile
        self.xlog.seek(0, os.SEEK_CUR)
        line = self.xlog.readline()
        if line:
            data = parse_xlog(line)
            report = report_template.format(**data)
            msg = ircmsgs.privmsg(CONFIG_CHANNEL, report)
            irc.queueMsg(msg)

        # Check livelog
        self.livelog.seek(0, os.SEEK_CUR)
        line = self.livelog.readline()
        if line:
            data = parse_livelog(line)
            report = livelog_announcement(data)
            if report:
                msg = ircmsgs.privmsg(CONFIG_CHANNEL, report)
                irc.queueMsg(msg)
开发者ID:Zhorken,项目名称:zzz-dywypi,代码行数:25,代码来源:plugin.py

示例3: maru

    def maru(self, irc, msg, args, channel, num=None):
        """ [<post number>]

        Prints a blog post to the channel.  If no post number is given,
        returns a random entry.
        """
        if(num == None):
            self.log.info("Randomly getting a maru post:")
            latestM = MaruGet.MaruBlog()
            postNum = randint(2,latestM.latestPost())
        else:
            postNum = num
        self.log.info("Getting maru post number: " + str(postNum))
        m = MaruGet.MaruBlog(postNum)
        r = m.ircContent()
        self.log.debug("Maruing %q in %s due to %s.",
                r, channel, msg.prefix)
        self.log.debug("Type: %s ", type(r))
        r = unicode(r).encode("utf-8")
        maruList = list()

        irc.queueMsg(ircmsgs.privmsg(channel, "Maru blog entry #" +\
            str(postNum) +" (" + m.maruUrl + ")" +":"))
        for maruLine in r.split('\n'):
            try:
                maruList.append(unicode(maruLine).encode("ascii"))
            except UnicodeDecodeError:
                pass
        for line in maruList:
            irc.queueMsg(ircmsgs.privmsg(channel, line))
        irc.noReply()
开发者ID:cswingler,项目名称:MaruBlog,代码行数:31,代码来源:plugin.py

示例4: doJoin

    def doJoin(self, irc, msg):
        """give voice to users that join and meet requirements."""
        if msg.args[0] != self.registryValue('targetChannel') or irc.network != 'freenode':
            return
        if msg.nick == irc.nick: # ignore our own join msgs.
            return

        gpgauth = self._checkGPGAuth(irc, msg.prefix)
        if gpgauth is None:
            try:
                if (not world.testing) and self.registryValue('msgOnJoinVoice') != "" and msg.nick not in irc.state.channels['#bitcoin-otc-foyer'].users:
                    irc.queueMsg(ircmsgs.privmsg(msg.nick, self.registryValue('msgOnJoinVoice')))
            except KeyError:
                pass
            if (not world.testing) and self.registryValue('msgOnJoinIdent') != "":
                irc.queueMsg(ircmsgs.privmsg(msg.nick, self.registryValue('msgOnJoinIdent')))
            return

        info = self._getGPGInfo(irc, gpgauth['nick'])
        if info is not None:
            regtimestamp = info[4]
        else:
            # this should not happen
            return
        trust_nanotube = self._gettrust(irc, 'nanotube', gpgauth['nick'])
        trust_keefe = self._gettrust(irc, 'keefe', gpgauth['nick'])
        mintrust = min(trust_nanotube[0][0] + trust_nanotube[1][0], 
                trust_keefe[0][0] + trust_keefe[1][0])
        if mintrust >= self.registryValue('ratingThreshold') and \
                time.time() - regtimestamp > self.registryValue('accountAgeThreshold'):
            irc.queueMsg(ircmsgs.voice('#bitcoin-otc', msg.nick))
开发者ID:Spunkie,项目名称:supybot-bitcoin-marketmonitor,代码行数:31,代码来源:plugin.py

示例5: doPrivmsg

    def doPrivmsg(self, irc, msg):
        channel = msg.args[0]
        # Ignore messages that start with the command qualifier
        if msg.args[1].startswith('@'):
            return
        # Don't parse non-command messages if a trivia game isn't running 
        # or if there is no active question
        if channel not in self.running or channel not in self.curQuestion:
            return

        else:
            self.curQuestion[channel].check(msg.args[1])
            if self.curQuestion[channel].isCorrect(msg.args[1]) == False:
                if self.lastHint[channel] != self.curQuestion[channel].hint:
                    irc.queueMsg(ircmsgs.privmsg(channel,ircutils.bold("Answer:  ") + self.curQuestion[channel].hint))
                    self.lastHint[channel] = self.curQuestion[channel].hint
                
            else:
                # Answer is correct, assign points
                irc.queueMsg(ircmsgs.privmsg(channel,ircutils.bold("Answer:  ")  + "%s is correct!!" % self.curQuestion[channel].answer))
                irc.queueMsg(ircmsgs.privmsg(channel,"%s gets 5 points!!" % ircutils.bold(msg.nick)))
                self.scores[channel].add(msg.nick,5)
                irc.queueMsg(ircmsgs.privmsg(msg.args[0],("Scores: %s" % self.getFormattedScores(msg.args[0]))))
                self.curQuestion.pop(channel)
                self.ask(irc,msg)
        return
开发者ID:kg-bot,项目名称:SupyBot,代码行数:26,代码来源:plugin.py

示例6: quiet

    def quiet(self, irc, msg, args, channel, nick, expiry):
        """[<channel>] <nick> [<expiry>]

        Quietens <nick> from <channel> for <expiry>.  If <expiry> isn't given,
        the duration is permanent.
        <channel> is only necessary if the message isn't sent in the channel
        itself.
        """
        if irc.isNick(nick):
            bannedNick = nick
            try:
                bannedHostmask = irc.state.nickToHostmask(nick)
            except KeyError:
                irc.error(format(_('I haven\'t seen %s.'), bannedNick), Raise=True)
        else:
            bannedNick = ircutils.nickFromHostmask(nick)
            bannedHostmask = nick
        if not irc.isNick(bannedNick):
            self.log.warning('%q tried to quiet a non nick: %q',
                             msg.prefix, bannedNick)
            raise callbacks.ArgumentError
        banmaskstyle = conf.supybot.protocols.irc.banmask
        banmask = banmaskstyle.makeBanmask(bannedHostmask)
        if ircutils.strEqual(nick, irc.nick):
            irc.error('I cowardly refuse to quiet myself.', Raise=True)
        thismsg=self.registryValue('message')
        self._sendMsg(irc, ircmsgs.mode(channel, ("+q", banmask)))
        if self.registryValue('SendMsgPvt'):
            self._sendMsg(irc, ircmsgs.privmsg(nick,nick+", "+thismsg ))
        else:
            self._sendMsg(irc, ircmsgs.privmsg(channel,nick+", "+thismsg ))
        def f():
            irc.queueMsg(ircmsgs.mode(channel, ("-q", banmask)))
        if expiry:
        	schedule.addEvent(f, expiry)
开发者ID:GlitterCakes,项目名称:PoohBot,代码行数:35,代码来源:plugin.py

示例7: doPrivmsg

 def doPrivmsg(self, irc, msg):
     if(self.registryValue('enable', msg.args[0])):
         # If this is a youtube link, commence lookup
         if(msg.args[1].find("youtube") != -1 or msg.args[1].find("youtu.be") != -1):
             youtube_pattern = re.compile('(?:www\.)?youtu(?:be\.com/watch\?v=|\.be/)([\w\?=\-]*)(&(amp;)?[\w\?=]*)?')
             
             m = youtube_pattern.search(msg.args[1]);
             if(m):
                 r = requests.get('http://gdata.youtube.com/feeds/api/videos/%s?v=2&alt=json' % m.group(1))
                 data = json.loads(r.content)
                 likes = float(data['entry']["yt$rating"]['numLikes'])
                 dislikes = float(data['entry']["yt$rating"]['numDislikes'])
                 rating = (likes/(likes+dislikes))*100
                 message = 'Title: %s, Views: %s, Rating: %s%%' % (ircutils.bold(data['entry']['title']['$t']), ircutils.bold(data['entry']['yt$statistics']['viewCount']), ircutils.bold(round(float(rating))))
                 message = message.encode("utf-8", "replace")
                 irc.queueMsg(ircmsgs.privmsg(msg.args[0], message))
             
         if(msg.args[1].find("vimeo") != -1):
             vimeo_pattern = re.compile('vimeo.com/(\\d+)')
             m = vimeo_pattern.search(msg.args[1]);
             if(m):
                 r = requests.get("http://vimeo.com/api/v2/video/%s.json" % m.group(1))
                 data = json.loads(r.content)
                 message = 'Title: %s, Views: %s, Likes: %s' % (ircutils.bold(data[0]['title']), ircutils.bold(data[0]['stats_number_of_plays']), ircutils.bold(data[0]['stats_number_of_likes']))
                 message = message.encode("utf-8", "replace")
                 irc.queueMsg(ircmsgs.privmsg(msg.args[0], message))
开发者ID:eif0,项目名称:d0b,代码行数:26,代码来源:plugin.py

示例8: cutwire

 def cutwire(self, irc, cutWire):
     cutWire = cutWire.replace("pink", ircutils.mircColor('pink', '13'))
     cutWire = cutWire.replace("red", ircutils.mircColor('red', '4'))
     cutWire = cutWire.replace("orange", ircutils.mircColor('orange', '7'))
     cutWire = cutWire.replace("yellow", ircutils.mircColor('yellow', '8'))
     cutWire = cutWire.replace("green", ircutils.mircColor('green', '3'))
     cutWire = cutWire.replace("blue", ircutils.mircColor('blue', '12'))
     cutWire = cutWire.replace("grey", ircutils.mircColor('grey', '14'))
     cutWire = cutWire.replace("purple", ircutils.mircColor('purple', '6'))
     cutWire = cutWire.replace("lime", ircutils.mircColor('lime', '9'))
     cutWire = cutWire.replace("teal", ircutils.mircColor('teal', '10'))
     cutWire = cutWire.replace("brown", ircutils.mircColor('brown', '5'))
     cutWire = cutWire.replace("cyan", ircutils.mircColor('cyan', '11'))
     self.cutWire = cutWire
     self.responded = True
     if self.thrown == True:
         self.irc.queueMsg(ircmsgs.privmsg(self.channel, 'You don\'t have the coordination to cut wires on bombs in midair while they\'re flying towards your head!  Ducking might be a better idea.'))
     else:
         if self.goodWire.lower() == self.cutWire.lower():
             self.irc.queueMsg(ircmsgs.privmsg(self.channel, '%s has cut the %s wire!  This has defused the bomb!' % (self.victim, self.cutWire)))
             self.irc.queueMsg(ircmsgs.privmsg(self.channel, '%s then quickly rearms the bomb and throws it back at %s with just seconds on the clock!' % (self.victim, self.sender)))
             self.victim = self.sender
             self.thrown = True
             schedule.rescheduleEvent('%s_bomb' % self.channel, time.time() + 10)
             if self.victim == irc.nick:
                 time.sleep(1)
                 self.irc.queueMsg(ircmsgs.privmsg(self.channel, '@duck'))
                 time.sleep(1)
                 self.duck(self.irc, irc.nick)
         else:
             schedule.removeEvent('%s_bomb' % self.channel)
             self.detonate(irc)
开发者ID:GlitterCakes,项目名称:PoohBot,代码行数:32,代码来源:plugin.py

示例9: doNotice

 def doNotice(self, irc, msg):
     if irc.network == self.registryValue('masternetwork'):
         irc.sendMsg(ircmsgs.privmsg('\x23ElectroBNC.log', "Notice from %s: %s" % (msg.nick, msg.args[1])))
     elif irc.network != self.registryValue('masternetwork'):
         otherIrc = self._getIrc(self.registryValue('masternetwork'))
         otherIrc.queueMsg(ircmsgs.privmsg("\x23ElectroBNC.log", "Notice from %[email protected]%s: %s" % (msg.nick, irc.network, msg.args[1])))
     irc.noReply()
开发者ID:ElectroCode,项目名称:ElectroBNC,代码行数:7,代码来源:plugin.py

示例10: np

    def np(self, irc, msg, args):
        """Return a list of a people currently in-game on Steam
        """
        key = self.registryValue('apikey')
        if not key:
            irc.replyError('plugins.steamy.apikey has not been set')
            return

        self.update(key)
        ingame = filter(lambda player: player.isInGame(), self.group.members)
        playerCount = len(ingame)
        playerlist = map(lambda x:
            '{0}: {1}'.format(x.steamID.encode('utf8'), x.gameextrainfo.encode('utf8')), ingame)

        self.log.info(str(playerlist))

        if len(playerlist) != 0:
            reply = 'Now Playing: %s' % (', '.join(playerlist))
        else:
            reply = 'Now Playing: nobody :('

        if ircutils.isChannel(msg.args[0]):
            irc.queueMsg(ircmsgs.privmsg(msg.args[0], reply))
        else:
            irc.queueMsg(ircmsgs.privmsg(msg.nick, reply))
开发者ID:bnrubin,项目名称:Steamy,代码行数:25,代码来源:plugin.py

示例11: _trust_updates

    def _trust_updates(self, irc):
        try:
            added, removed = self.deeds.trust_notify.get(block=False)
            txt = '[trust-update]'

            if added or removed:
                if added:
                    txt += ' added: {0}'.format(', '.join(added))
                if removed:
                    if added: 
                        txt += ' |'
                    txt += ' removed: {0}'.format(', '.join(removed))
            else:
                txt += ' no changes'
                msg = ircmsgs.privmsg('#punkbot', txt)
                irc.queueMsg(msg)
                return

            # announce trust updates
            for channel in irc.state.channels:
                msg = ircmsgs.privmsg(channel, txt)
                irc.queueMsg(msg)

        except Queue.Empty:
            pass
开发者ID:extempore,项目名称:deedbundler,代码行数:25,代码来源:plugin.py

示例12: do311

 def do311(self, irc, msg):
     nick = msg.args[1]
     if not nick.startswith('[YOG]') or nick in self.registryValue('nowelcome').split(' '):
         return
     realname = msg.args[5]
     hostname = self._users.pop(nick)
     try:
         version = 'Glob2 version %s' % realname.split('-')[1]
     except:
         version = 'unknown version'
     g = GeoIP()
     country = g.country(hostname)['country_name']
     if country == 'France':
         irc.queueMsg(ircmsgs.privmsg(nick, ('Bonjour %s, bienvenue dans le '
             'salon de jeu Globulation2 en ligne. Il y a actuellement %i '
             'personnes connectées via IRC, elles pourraient se réveiller et '
             'jouer avec vous. Attendez ici au moins quelques minutes, '
             'quelqu\'un pourrait se connecter d\'ici là.') %
             (nick, len(irc.state.channels['#glob2'].users))))
     else:
         irc.queueMsg(ircmsgs.privmsg(nick, ('Hi %s, welcome to the '
             'globulation online game room. There are currently %i '
             'people connected via IRC, they may awaken and challenge '
             'you to a game. Please stay here at least a few minutes, '
             'someone may connect in the meantime.') %
             (nick, len(irc.state.channels['#glob2'].users))))
     irc.queueMsg(ircmsgs.privmsg('#glob2', ('Welcome to %s, running %s '
         'and connecting from %s.') % (nick, version, country)))
开发者ID:Albnetwork,项目名称:Supybot-plugins,代码行数:28,代码来源:plugin.py

示例13: repoadd

    def repoadd(self, irc, msg, args, channel, reponame, url, channels):
        """ <repository name> <url> <channel[,channel...]>

        Add a new repository with name, url and a comma-separated list
        of channels which should be connected to this repo.
        """

        def cloning_done_cb(result):
            ''' Callback invoked after cloning is done. '''
            if isinstance(result, _Repository):
                self.repos.append(result)
                irc.sendMsg(ircmsgs.privmsg(msg.args[0],"Repository created and cloned"))
            else:
                self.log.info("Cannot clone: " + str(result))
                irc.sendMsg(ircmsgs.privmsg(msg.args[0],"Error: Cannot clone repo: " + str(result)))

        if reponame in config.global_option('repolist').value:
            irc.sendMsg(ircmsgs.privmsg(msg.args[0],'Error: repo exists'))
            return
        opts = {'url': url, 'channels': channels}
        if world.testing:
            _Repository.create(reponame, cloning_done_cb, opts)
            irc.sendMsg(ircmsgs.privmsg(msg.args[0],"Repository created and cloned"))
            return
        t = threading.Thread(target = _Repository.create,
                             args = (reponame, cloning_done_cb, opts))
        t.start()
        irc.sendMsg(ircmsgs.privmsg(msg.args[0],'Cloning of %s started...' % reponame))
开发者ID:gmorell,项目名称:supybot-git,代码行数:28,代码来源:plugin.py

示例14: run

 def run(self):
     while not self.stopped:
         time.sleep(10)
         for url, desc, chan in self.urls:
             try:
                 f = urllib.urlopen(url)
                 s = f.read()
                 f.close()
                 s = filter(s)
             except Exception, e:
                 msg = privmsg("hc", "Wwwdiff: error(1): %s" % e)
                 self.plugin.irc.queueMsg(msg)
                 continue
             try:
                 old = self.texts[url]
                 self.texts[url] = s
             except:
                 self.texts[url] = s
                 continue
             try:
                 diffs = difflib.ndiff(old.split("\n"), s.split("\n"))
                 for diff in diffs:
                     if unwanted(diff):
                         continue
                     if diff[0] == "+":
                         msg = privmsg(chan, "C [%s] %s" % (desc, diff))
                         self.plugin.irc.queueMsg(msg)
             except Exception, e:
                 msg = privmsg("hc", "Wwwdiff: error(2): %s" % e)
                 self.plugin.irc.queueMsg(msg)
                 continue
开发者ID:hce,项目名称:supybotplugins,代码行数:31,代码来源:plugin.py

示例15: doJoin

    def doJoin(self, irc, msg):

        #irc.reply("hello")
        if ircutils.strEqual(irc.nick, msg.nick):
            return # It's us

        channel = msg.args[0]
        if channel != "#code4lib" and channel not in test_channels:
            return
        
        #if self.db[channel, msg.nick] is None:
        try:
            self.db.get(channel, msg.nick)
        except KeyError:
            # The except means that we only message people not yet in the db.
            irc.queueMsg(ircmsgs.privmsg(msg.nick, joinmsg % ( irc.nick ) ))
            irc.noReply()
            #self.db.add(channel, msg.nick)
            self.db.add(channel, msg.nick) 

            # Also notify the helpers privately if a potential newbie shows up,
            # so that we can roll out the welcome mat human-style.
            for helper in self._get_helpers(channel):
                # Sometimes the helpers db stores blank lines, which we should
                # ignore.
                if helper:
                    irc.queueMsg(ircmsgs.privmsg(helper, helpermsg % ( msg.nick ) ))
                    irc.noReply()
开发者ID:dfederlein,项目名称:supybot-plugins,代码行数:28,代码来源:plugin.py


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