Пример #1
0
    def doJoin(self, irc, msg):
        if ircutils.strEqual(irc.nick, msg.nick):
            return  # It's us.
        if msg.nick in self.splitters:
            self.log.debug('Not heralding %s, recent split.', msg.nick)
            return  # Recently split.
        channel = msg.args[0]
        irc = callbacks.SimpleProxy(irc, msg)
        if self.registryValue('heralding', channel):
            try:
                id = ircdb.users.getUserId(msg.prefix)
                heraldAll = self.db['#ALL', id]
            except KeyError:
                heraldAll = ""

            try:
                id = ircdb.users.getUserId(msg.prefix)
                if id in self.splitters:
                    self.log.debug('Not heralding id #%s, recent split.', id)
                    return
                herald = self.db[channel, id]
            except KeyError:
                if heraldAll == "":
                    default = self.registryValue('default', channel)
                    if default:
                        default = ircutils.standardSubstitute(
                            irc, msg, default)
                        msgmaker = ircmsgs.privmsg
                        if self.registryValue('default.notice', channel):
                            msgmaker = ircmsgs.notice
                        target = msg.nick
                        if self.registryValue('default.public', channel):
                            target = channel
                        irc.queueMsg(msgmaker(target, default))
                    return
                else:
                    herald = heraldAll

            now = time.time()
            throttle = self.registryValue('throttle', channel)
            if now - self.lastHerald.get((channel, id), 0) > throttle:
                if (channel, id) in self.lastParts:
                    i = self.registryValue('throttle.afterPart', channel)
                    if now - self.lastParts[channel, id] < i:
                        return
                self.lastHerald[channel, id] = now
                herald = ircutils.standardSubstitute(irc, msg, herald)
                irc.reply(herald, prefixNick=False)
Пример #2
0
    def part(self, irc, msg, args, channel, reason):
        """[<channel>] [<reason>]

        Tells the bot to part the list of channels you give it.  <channel> is
        only necessary if you want the bot to part a channel other than the
        current channel.  If <reason> is specified, use it as the part
        message.  Otherwise, the default part message specified in
        supybot.plugins.Channel.partMsg will be used. No part message will be
        used if no default is configured.
        """
        channel = channel or msg.channel
        if not channel:
            irc.error(Raise=True)
        capability = ircdb.makeChannelCapability(channel, 'op')
        if not ircdb.checkCapabilities(msg.prefix, [capability, 'admin']):
            irc.errorNoCapability(capability, Raise=True)
        try:
            network = conf.supybot.networks.get(irc.network)
            network.channels().remove(channel)
        except KeyError:
            pass
        if channel not in irc.state.channels:
            irc.error(_('I\'m not in %s.') % channel, Raise=True)
        reason = (reason or self.registryValue("partMsg", channel, irc.network))
        reason = ircutils.standardSubstitute(irc, msg, reason)
        irc.queueMsg(ircmsgs.part(channel, reason))
        if msg.nick in irc.state.channels[channel].users:
            irc.noReply()
        else:
            irc.replySuccess()
Пример #3
0
    def part(self, irc, msg, args, channel, reason):
        """[<channel>] [<reason>]

        Tells the bot to part the list of channels you give it.  <channel> is
        only necessary if you want the bot to part a channel other than the
        current channel.  If <reason> is specified, use it as the part
        message.  Otherwise, the default part message specified in
        supybot.plugins.Channel.partMsg will be used. No part message will be
        used if no default is configured.
        """
        if channel is None:
            if irc.isChannel(msg.args[0]):
                channel = msg.args[0]
            else:
                irc.error(Raise=True)
        capability = ircdb.makeChannelCapability(channel, 'op')
        hostmask = irc.state.nickToHostmask(msg.nick)
        if not ircdb.checkCapabilities(hostmask, [capability, 'admin']):
            irc.errorNoCapability(capability, Raise=True)
        try:
            network = conf.supybot.networks.get(irc.network)
            network.channels().remove(channel)
        except KeyError:
            pass
        if channel not in irc.state.channels:
            irc.error(_('I\'m not in %s.') % channel, Raise=True)
        reason = (reason or self.registryValue("partMsg", channel))
        reason = ircutils.standardSubstitute(irc, msg, reason)
        irc.queueMsg(ircmsgs.part(channel, reason))
        if msg.nick in irc.state.channels[channel].users:
            irc.noReply()
        else:
            irc.replySuccess()
Пример #4
0
 def doJoin(self, irc, msg):
     if ircutils.strEqual(irc.nick, msg.nick):
         return # It's us.
     if msg.nick in self.splitters:
         self.log.debug('Not heralding %s, recent split.', msg.nick)
         return # Recently split.
     channel = msg.args[0]
     irc = callbacks.SimpleProxy(irc, msg)
     if self.registryValue('heralding', channel):
         try:
             id = ircdb.users.getUserId(msg.prefix)
             heraldAll = self.db['#ALL', id]
         except KeyError:
             heraldAll = ""
         
         try:
             id = ircdb.users.getUserId(msg.prefix)
             if id in self.splitters:
                 self.log.debug('Not heralding id #%s, recent split.', id)
                 return
             herald = self.db[channel, id]
         except KeyError:
             if heraldAll == "":
                 default = self.registryValue('default', channel)
                 if default:
                     default = ircutils.standardSubstitute(irc, msg, default)
                     msgmaker = ircmsgs.privmsg
                     if self.registryValue('default.notice', channel):
                         msgmaker = ircmsgs.notice
                     target = msg.nick
                     if self.registryValue('default.public', channel):
                         target = channel
                     irc.queueMsg(msgmaker(target, default))
                 return
             else:
                 herald = heraldAll
                 
         now = time.time()
         throttle = self.registryValue('throttle', channel)
         if now - self.lastHerald.get((channel, id), 0) > throttle:
             if (channel, id) in self.lastParts:
                i = self.registryValue('throttle.afterPart', channel)
                if now - self.lastParts[channel, id] < i:
                    return
             self.lastHerald[channel, id] = now
             herald = ircutils.standardSubstitute(irc, msg, herald)
             irc.reply(herald, prefixNick=False)
Пример #5
0
    def jira(self, irc, msg, args, text):
        """<text>

        Returns the arguments given it.  Uses our standard substitute on the
        string(s) given to it; $nick (or $who), $randomNick, $randomInt,
        $botnick, $channel, $user, $host, $today, $now, and $randomDate are all
        handled appropriately.
        """
        text = ircutils.standardSubstitute(irc, msg, text)
        result = []
        self.log.info('Looking up: ' + text)

        self._auth()
        
        cachekey = msg.args[0] + "_" + text # todo: show channel
        if(cachekey in self.recent):
            last = self.recent[cachekey]
            now = datetime.now()
            self.log.info('last seen ' + cachekey + ' at ' + str(last) + ' now is ' + str(now) + ' ' + str(now-last))
            if ((now - last) < timedelta (seconds = self.registryValue('duplicate_graceperiod'))):
                irc.noReply()
                return
        else:
            self.log.info('new lookup')
            
        self.recent[cachekey] = datetime.now()

        try:
            issue = self.s.jira1.getIssue(self.auth, text)

            #for k,v in sorted(issue.items()):
            #	irc.reply(k, prefixNick=True)

            #irc.reply(issue['description'], prefixNick=True)
            result.append(getName(issue['type'], self.jiradata['types']) + ": ")
            result.append("[" + issue['key'] + "]")
            result.append(" " + issue['summary'])
            result.append(" [")
            result.append(getName(issue['status'], self.jiradata['statuses']) + ", ")
            result.append(getName(issue['priority'], self.jiradata['priorities']) + ", ")

            if('components' in issue):
                components = []
                for f in issue['components']:
                    components.append(encode(f['name']))
                if(components):
                    result.append("(")
                    result.append(", ".join(str(x) for x in components))
                    result.append("), ")
            if('assignee' in issue):
                result.append(issue['assignee'])  #should be username ?
            else:
                result.append("Unassigned")
            result.append("] ")
            result.append(self.registryValue('browseurl') + issue['key'])
            irc.reply("".join(result), prefixNick=False)
        except Fault, f:
            self.log.exception("Error when looking up " + text)
            irc.noReply()
Пример #6
0
 def invalidCommand(self, irc, msg, tokens):
     channel = msg.args[0]
     if irc.isChannel(channel):
         dunno = self.db.random(channel)
         if dunno is not None:
             dunno = dunno.text
             prefixNick = self.registryValue('prefixNick', channel)
             env = {'command': tokens[0]}
             dunno = ircutils.standardSubstitute(irc, msg, dunno, env=env)
             irc.reply(dunno, prefixNick=prefixNick)
Пример #7
0
 def invalidCommand(self, irc, msg, tokens):
     channel = msg.args[0]
     if irc.isChannel(channel):
         dunno = self.db.random(channel)
         if dunno is not None:
             dunno = dunno.text
             prefixNick = self.registryValue('prefixNick', channel)
             env = {'command': tokens[0]}
             dunno = ircutils.standardSubstitute(irc, msg, dunno, env=env)
             irc.reply(dunno, prefixNick=prefixNick)
Пример #8
0
def getTopic(irc, msg, args, state, format=True):
    separator = state.cb.registryValue("separator", state.channel)
    if separator in args[0]:
        state.errorInvalid("topic", args[0], format(_("The topic must not include %q."), separator))
    topic = args.pop(0)
    if format:
        env = {"topic": topic}
        formatter = state.cb.registryValue("format", state.channel)
        topic = ircutils.standardSubstitute(irc, msg, formatter, env)
    state.args.append(topic)
Пример #9
0
    def echo(self, irc, msg, args, text):
        """<text>

        Returns the arguments given it.  Uses our standard substitute on the
        string(s) given to it; $nick (or $who), $randomNick, $randomInt,
        $botnick, $channel, $user, $host, $today, $now, and $randomDate are all
        handled appropriately.
        """
        text = ircutils.standardSubstitute(irc, msg, text)
        irc.reply(text, prefixNick=False)
Пример #10
0
    def echo(self, irc, msg, args, text):
        """<text>

        Returns the arguments given it.  Uses our standard substitute on the
        string(s) given to it; $nick (or $who), $randomNick, $randomInt,
        $botnick, $channel, $user, $host, $today, $now, and $randomDate are all
        handled appropriately.
        """
        text = ircutils.standardSubstitute(irc, msg, text)
        irc.reply(text, prefixNick=False)
Пример #11
0
def getTopic(irc, msg, args, state, format=True):
    separator = state.cb.registryValue('separator', state.channel)
    if separator in args[0]:
        state.errorInvalid('topic', args[0],
                           format('The topic must not include %q.', separator))
    topic = args.pop(0)
    if format:
        env = {'topic': topic}
        formatter = state.cb.registryValue('format', state.channel)
        topic = ircutils.standardSubstitute(irc, msg, formatter, env)
    state.args.append(topic)
Пример #12
0
def getTopic(irc, msg, args, state, format=True):
    separator = state.cb.registryValue('separator', state.channel)
    if separator in args[0]:
        state.errorInvalid('topic', args[0],
                           format('The topic must not include %q.', separator))
    topic = args.pop(0)
    if format:
        env = {'topic': topic}
        formatter = state.cb.registryValue('format', state.channel)
        topic = ircutils.standardSubstitute(irc, msg, formatter, env)
    state.args.append(topic)
Пример #13
0
 def doJoin(self, irc, msg):
     if ircutils.strEqual(irc.nick, msg.nick):
         return # It's us.
     if msg.nick in self.splitters:
         self.log.debug('Not greeting %s, recent split.', msg.nick)
         return # Recently split.
     channel = msg.args[0]
     irc = callbacks.SimpleProxy(irc, msg)
     if self.registryValue('greeting', channel):
         try:
             id = ircdb.users.getUserId(msg.prefix)
             if id in self.splitters:
                 self.log.debug('Not greeting id #%s, recent split.', id)
                 return
             greet = self.db[channel, id]
         except KeyError:
             default = self.registryValue('default', channel)
             if default:
                 default = ircutils.standardSubstitute(irc, msg, default)
                 msgmaker = ircmsgs.privmsg
                 if self.registryValue('default.notice', channel):
                     msgmaker = ircmsgs.notice
                 target = msg.nick
                 if self.registryValue('default.public', channel):
                     target = channel
                 irc.queueMsg(msgmaker(target, default))
             return
         now = time.time()
         throttle = self.registryValue('throttle', channel)
         if now - self.lastGreet.get((channel, id), 0) > throttle:
             if (channel, id) in self.lastParts:
                i = self.registryValue('throttle.afterPart', channel)
                if now - self.lastParts[channel, id] < i:
                    return
             self.lastGreet[channel, id] = now
             greet = ircutils.standardSubstitute(irc, msg, greet)
             if re.search(r"/me ", greet, re.I):
             	greet = greet.replace("/me ","")
             	irc.reply(greet, prefixNick=False, action=True)
             else:
             	irc.reply(greet, prefixNick=True)
Пример #14
0
 def invalidCommand(self, irc, msg, tokens):
     if msg.channel:
         dunno = self.db.random(msg.channel)
         if dunno is not None:
             dunno = dunno.text
             prefixNick = self.registryValue('prefixNick', msg.channel,
                                             irc.network)
             env = {'command': tokens[0]}
             self.log.info('Issuing "dunno" answer, %s is not a command.',
                           tokens[0])
             dunno = ircutils.standardSubstitute(irc, msg, dunno, env=env)
             irc.reply(dunno, prefixNick=prefixNick)
Пример #15
0
 def _parseFactoid(self, irc, msg, fact):
     type = 'define'  # Default is to just spit the factoid back as a
     # definition of what the key is (i.e., "foo is bar")
     newfact = pickOptions(fact)
     if newfact.startswith(self._replyTag):
         newfact = newfact[len(self._replyTag):]
         type = 'reply'
     elif newfact.startswith(self._actionTag):
         newfact = newfact[len(self._actionTag):]
         type = 'action'
     newfact = newfact.strip()
     newfact = ircutils.standardSubstitute(irc, msg, newfact)
     return (type, newfact)
Пример #16
0
    def send(self, irc, msg, args, address, text):
        """<address> <text>

        Sends an email to <address> with contents <text>.
        """
        now = time.strftime(conf.supybot.reply.format.time(), time.localtime())
        subjectFormat = self.registryValue('subject')
        subject = ircutils.standardSubstitute(irc, msg, subjectFormat)
        mail = popen2.Popen4(['mail', '-s', subject, address])
        introFormat = self.registryValue('introduction')
        intro = ircutils.standardSubstitute(irc, msg, introFormat)
        mail.tochild.write(intro)
        mail.tochild.write('\n\n')
        mail.tochild.write(text)
        mail.tochild.close()
        status = mail.wait()
        if not status:
            irc.replySuccess(format('Email sent to %s.', address))
        else:
            errorLines = mail.fromchild.readlines()
            errorMsg = utils.str.normalizeWhitespace(' '.join(errorLines))
            irc.error(format('Mail returned %s: %s', status, errorMsg))
Пример #17
0
 def reply(self, s, irc=None, msg=None, action=False, substitute=True):
     if irc is None:
         assert self.irc is not None
         irc = self.irc
     if msg is None:
         assert self.msg is not None
         msg = self.msg
     if msg.repliedTo:
         self.log.debug('Already replied, not replying again.')
         return
     if substitute:
         s = ircutils.standardSubstitute(irc, msg, s)
     irc.reply(s, prefixNick=False, action=action, msg=msg)
Пример #18
0
 def _parseFactoid(self, irc, msg, fact):
     type = 'define'  # Default is to just spit the factoid back as a
                      # definition of what the key is (i.e., "foo is bar")
     newfact = pickOptions(fact)
     if newfact.startswith(self._replyTag):
         newfact = newfact[len(self._replyTag):]
         type = 'reply'
     elif newfact.startswith(self._actionTag):
         newfact = newfact[len(self._actionTag):]
         type = 'action'
     newfact = newfact.strip()
     newfact = ircutils.standardSubstitute(irc, msg, newfact)
     return (type, newfact)
Пример #19
0
 def reply(self, s, irc=None, msg=None, action=False, substitute=True):
     if irc is None:
         assert self.irc is not None
         irc = self.irc
     if msg is None:
         assert self.msg is not None
         msg = self.msg
     if msg.repliedTo:
         self.log.debug('Already replied, not replying again.')
         return
     if substitute:
         s = ircutils.standardSubstitute(irc, msg, s)
     irc.reply(s, prefixNick=False, action=action, msg=msg)
Пример #20
0
    def cycle(self, irc, msg, args, channel, reason):
        """[<channel>]

        If you have the #channel,op capability, this will cause the bot to
        "cycle", or PART and then JOIN the channel. <channel> is only necessary
        if the message isn't sent in the channel itself. If <reason> is not
        specified, the default part message specified in
        supybot.plugins.Channel.partMsg will be used. No part message will be
        used if neither a cycle reason nor a default part message is given.
        """
        reason = (reason or self.registryValue("partMsg", channel))
        reason = ircutils.standardSubstitute(irc, msg, reason)
        self._sendMsg(irc, ircmsgs.part(channel, reason))
        networkGroup = conf.supybot.networks.get(irc.network)
        self._sendMsg(irc, networkGroup.channels.join(channel))
Пример #21
0
    def cycle(self, irc, msg, args, channel, reason):
        """[<channel>] [<reason>]

        If you have the #channel,op capability, this will cause the bot to
        "cycle", or PART and then JOIN the channel. <channel> is only necessary
        if the message isn't sent in the channel itself. If <reason> is not
        specified, the default part message specified in
        supybot.plugins.Channel.partMsg will be used. No part message will be
        used if neither a cycle reason nor a default part message is given.
        """
        reason = (reason or self.registryValue("partMsg", channel, irc.network))
        reason = ircutils.standardSubstitute(irc, msg, reason)
        self._sendMsg(irc, ircmsgs.part(channel, reason))
        networkGroup = conf.supybot.networks.get(irc.network)
        self._sendMsg(irc, networkGroup.channels.join(channel))
Пример #22
0
 def ctcp(self, irc, msg, match):
     "^\x01(.*?)\x01$"
     payload = match.group(1)
     if payload:
         payload = payload.split()[0].upper()
         if payload in ('PING', 'ACTION'):
             return
         try:
             response = self.db[payload]
             response = ircutils.standardSubstitute(irc, msg, response)
             self._reply(irc, msg, payload, response)
             self.log.info('CtcpNext: Received CTCP %s from %s', payload,
                           msg.prefix)
         except KeyError:
             self.log.info('CtcpNext: Received unhandled CTCP %s from %s',
                           payload, msg.prefix)
Пример #23
0
    def quit(self, irc, msg, args, text):
        """[<text>]

        Exits the bot with the QUIT message <text>.  If <text> is not given,
        the default quit message (supybot.plugins.Owner.quitMsg) will be used.
        If there is no default quitMsg set, your nick will be used. The standard
        substitutions ($version, $nick, etc.) are all handled appropriately.
        """
        text = text or self.registryValue('quitMsg') or msg.nick
        text = ircutils.standardSubstitute(irc, msg, text)
        irc.noReply()
        m = ircmsgs.quit(text)
        world.upkeep()
        for irc in world.ircs[:]:
            irc.queueMsg(m)
            irc.die()
Пример #24
0
 def ctcp(self, irc, msg, match):
     "^\x01(.*?)\x01$"
     payload = match.group(1)
     if payload:
         payload = payload.split()[0].upper()
         if payload in ('PING', 'ACTION'):
             return
         try:
             response = self.db[payload]
             response = ircutils.standardSubstitute(irc, msg, response)
             self._reply(irc, msg, payload, response)
             self.log.info('CtcpNext: Received CTCP %s from %s', payload,
                           msg.prefix)
         except KeyError:
             self.log.info('CtcpNext: Received unhandled CTCP %s from %s',
                           payload, msg.prefix)
Пример #25
0
    def quit(self, irc, msg, args, text):
        """[<text>]

        Exits the bot with the QUIT message <text>.  If <text> is not given,
        the default quit message (supybot.plugins.Owner.quitMsg) will be used.
        If there is no default quitMsg set, your nick will be used. The standard
        substitutions ($version, $nick, etc.) are all handled appropriately.
        """
        text = text or self.registryValue('quitMsg') or msg.nick
        text = ircutils.standardSubstitute(irc, msg, text)
        irc.noReply()
        m = ircmsgs.quit(text)
        world.upkeep()
        for irc in world.ircs[:]:
            irc.queueMsg(m)
            irc.die()
Пример #26
0
    def reconnect(self, irc, msg, args, otherIrc, quitMsg):
        """[<network>] [<quit message>]

        Disconnects and then reconnects to <network>.  If no network is given,
        disconnects and then reconnects to the network the command was given
        on.  If no quit message is given, uses the configured one
        (supybot.plugins.Owner.quitMsg) or the nick of the person giving the
        command.
        """
        standard_msg = conf.supybot.plugins.Owner.quitMsg()
        if standard_msg:
            standard_msg = ircutils.standardSubstitute(irc, msg, standard_msg)
        quitMsg = quitMsg or standard_msg or msg.nick
        otherIrc.queueMsg(ircmsgs.quit(quitMsg))
        if otherIrc != irc:
            # No need to reply if we're reconnecting ourselves.
            irc.replySuccess()
Пример #27
0
    def disconnect(self, irc, msg, args, otherIrc, quitMsg):
        """[<network>] [<quit message>]

        Disconnects from the network represented by the network <network>.
        If <quit message> is given, quits the network with the given quit
        message.  <network> is only necessary if the network is different
        from the network the command is sent on.
        """
        standard_msg = conf.supybot.plugins.Owner.quitMsg()
        if standard_msg:
            standard_msg = ircutils.standardSubstitute(irc, msg, standard_msg)
        quitMsg = quitMsg or standard_msg or msg.nick
        otherIrc.queueMsg(ircmsgs.quit(quitMsg))
        otherIrc.die()
        conf.supybot.networks().discard(otherIrc.network)
        if otherIrc != irc:
            irc.replySuccess(_("Disconnection to %s initiated.") % otherIrc.network)
Пример #28
0
    def disconnect(self, irc, msg, args, otherIrc, quitMsg):
        """<network> [<quit message>]

        Disconnects from the network represented by the network <network>.
        If <quit message> is given, quits the network with the given quit
        message.
        """
        standard_msg = conf.supybot.plugins.Owner.quitMsg()
        if standard_msg:
            standard_msg = ircutils.standardSubstitute(irc, msg, standard_msg)
        quitMsg = quitMsg or standard_msg or msg.nick
        otherIrc.queueMsg(ircmsgs.quit(quitMsg))
        otherIrc.die()
        conf.supybot.networks().discard(otherIrc.network)
        if otherIrc != irc:
            irc.replySuccess(
                _('Disconnection to %s initiated.') % otherIrc.network)
Пример #29
0
    def reconnect(self, irc, msg, args, otherIrc, quitMsg):
        """[<network>] [<quit message>]

        Disconnects and then reconnects to <network>.  If no network is given,
        disconnects and then reconnects to the network the command was given
        on.  If no quit message is given, uses the configured one
        (supybot.plugins.Owner.quitMsg) or the nick of the person giving the
        command.
        """
        standard_msg = conf.supybot.plugins.Owner.quitMsg()
        if standard_msg:
            standard_msg = ircutils.standardSubstitute(irc, msg, standard_msg)
        quitMsg = quitMsg or standard_msg or msg.nick
        otherIrc.queueMsg(ircmsgs.quit(quitMsg))
        if otherIrc != irc:
            # No need to reply if we're reconnecting ourselves.
            irc.replySuccess()
Пример #30
0
    def announce(self, irc, msg, args, text):
        """<text>

        Sends <text> to all channels the bot is currently on and not
        lobotomized in.
        """
        u = ircdb.users.getUser(msg.prefix)

        template = self.registryValue('announceFormat')

        text = ircutils.standardSubstitute(
            irc, msg, template, env={'owner': u.name, 'text': text})

        for channel in irc.state.channels:
            c = ircdb.channels.getChannel(channel)
            if not c.lobotomized:
                irc.queueMsg(ircmsgs.privmsg(channel, text))

        irc.noReply()
Пример #31
0
    def announce(self, irc, msg, args, text):
        """<text>

        Sends <text> to all channels the bot is currently on and not
        lobotomized in.
        """
        u = ircdb.users.getUser(msg.prefix)

        template = self.registryValue('announceFormat')

        text = ircutils.standardSubstitute(
            irc, msg, template, env={'owner': u.name, 'text': text})

        for channel in irc.state.channels:
            c = ircdb.channels.getChannel(channel)
            if not c.lobotomized:
                irc.queueMsg(ircmsgs.privmsg(channel, text))

        irc.noReply()
Пример #32
0
 def prefixer(v):
     env['value'] = v
     formatter = self.registryValue('format', msg.args[0])
     return ircutils.standardSubstitute(irc, msg, formatter,
                                        env)
Пример #33
0
    def jira(self, irc, msg, args, text):
        """<text>

        Returns the arguments given it.  Uses our standard substitute on the
        string(s) given to it; $nick (or $who), $randomNick, $randomInt,
        $botnick, $channel, $user, $host, $today, $now, and $randomDate are all
        handled appropriately.
        """
        text = ircutils.standardSubstitute(irc, msg, text)
        result = []
        self.log.info('Looking up: ' + text)

        self._auth()

        cachekey = msg.args[0] + "_" + text  # todo: show channel
        if (cachekey in self.recent):
            last = self.recent[cachekey]
            now = datetime.now()
            self.log.info('last seen ' + cachekey + ' at ' + str(last) +
                          ' now is ' + str(now) + ' ' + str(now - last))
            if ((now - last) < timedelta(
                    seconds=self.registryValue('duplicate_graceperiod'))):
                irc.noReply()
                return
        else:
            self.log.info('new lookup')

        self.recent[cachekey] = datetime.now()

        try:
            issue = self.s.jira1.getIssue(self.auth, text)

            #for k,v in sorted(issue.items()):
            #	irc.reply(k, prefixNick=True)

            #irc.reply(issue['description'], prefixNick=True)
            result.append(
                getName(issue['type'], self.jiradata['types']) + ": ")
            result.append("[" + issue['key'] + "]")
            result.append(" " + issue['summary'])
            result.append(" [")
            result.append(
                getName(issue['status'], self.jiradata['statuses']) + ", ")
            result.append(
                getName(issue['priority'], self.jiradata['priorities']) + ", ")

            if ('components' in issue):
                components = []
                for f in issue['components']:
                    components.append(encode(f['name']))
                if (components):
                    result.append("(")
                    result.append(", ".join(str(x) for x in components))
                    result.append("), ")
            if ('assignee' in issue):
                result.append(issue['assignee'])  #should be username ?
            else:
                result.append("Unassigned")
            result.append("] ")
            result.append(self.registryValue('browseurl') + issue['key'])
            irc.reply("".join(result), prefixNick=False)
        except Fault, f:
            self.log.exception("Error when looking up " + text)
            irc.noReply()
Пример #34
0
 def prefixer(v):
     env['value'] = v
     formatter = self.registryValue('format', msg.channel,
                                    irc.network)
     return ircutils.standardSubstitute(irc, msg, formatter,
                                        env)
Пример #35
0
 def format_fact(text):
     if raw:
         return text
     else:
         return ircutils.standardSubstitute(irc, msg, text)
Пример #36
0
 def format_fact(text):
     if raw:
         return text
     else:
         return ircutils.standardSubstitute(irc, msg, text)
Пример #37
0
 def prefixer(v):
     env['value'] = v
     formatter = self.registryValue('format', msg.args[0])
     return ircutils.standardSubstitute(irc, msg,
                                        formatter, env)