예제 #1
0
    def last(self, irc, msg, args, channel, text):
        """[<channel>] <text>

        Find the last instance of <text> in my logs. <channel> is not necessary
unless the command is called outside of the channel.
        """
        result = "I could not find that text in the logs."
        prevResult = "" + result
        world.flush()

        filename = str(conf.supybot.directories.log) + "/ChannelLogger/"
        filename += irc.network + "/" + channel + "/" + channel + ".log"
        f = open(filename, 'r')

        line = f.readline()

        lastWasMatch = False

        while line:
            lastWasMatch = False
            if string.find(line, text) > -1:
                prevResult = "" + result
                result = line[0:-1]
                lastWasMatch = True
            line = f.readline()

        if not lastWasMatch or prevResult == result:
            irc.reply(result, prefixNick=False)
            return
        irc.reply(prevResult, prefixNick=False)
예제 #2
0
    def last(self, irc, msg, args, channel, text):
        """[<channel>] <text>

        Find the last instance of <text> in my logs. <channel> is not necessary
unless the command is called outside of the channel.
        """
        result="I could not find that text in the logs."
        prevResult="" + result
        world.flush()

        filename=str(conf.supybot.directories.log) + "/ChannelLogger/"
        filename+= irc.network + "/" + channel + "/" + channel + ".log"
        f=open(filename,'r')

        line=f.readline()

        lastWasMatch=False

        while line:
            lastWasMatch = False
            if string.find(line, text) > -1:
                prevResult = "" + result
                result=line[0:-1]
                lastWasMatch = True
            line=f.readline()

        if not lastWasMatch or prevResult == result:
            irc.reply(result, prefixNick=False)
            return
        irc.reply(prevResult, prefixNick=False)
예제 #3
0
파일: plugin.py 프로젝트: boamaod/Limnoria
    def flush(self, irc, msg, args):
        """takes no arguments

        Runs all the periodic flushers in world.flushers.  This includes
        flushing all logs and all configuration changes to disk.
        """
        world.flush()
        irc.replySuccess()
예제 #4
0
    def flush(self, irc, msg, args):
        """takes no arguments

        Runs all the periodic flushers in world.flushers.  This includes
        flushing all logs and all configuration changes to disk.
        """
        world.flush()
        irc.replySuccess()
예제 #5
0
    def logsearch(self, irc, msg, args, channel, text):
        """[<channel>] <text>

        greps for <text> in my logs. <channel> is only
necessary if the command is called outside of the channel.
        """
        world.flush()
        filename=str(conf.supybot.directories.log) + "/ChannelLogger/"
        filename+= irc.network + "/" + channel + "/" + channel + ".log"
        self.runShCmd(irc, "grep -m 4 \'" + text + "\' " + filename)
예제 #6
0
    def logsearch(self, irc, msg, args, channel, text):
        """[<channel>] <text>

        greps for <text> in my logs. <channel> is only
necessary if the command is called outside of the channel.
        """
        world.flush()
        filename = str(conf.supybot.directories.log) + "/ChannelLogger/"
        filename += irc.network + "/" + channel + "/" + channel + ".log"
        self.runShCmd(irc, "grep -m 4 \'" + text + "\' " + filename)
예제 #7
0
    def first(self, irc, msg, args, channel, text):
        """[<channel>] <text>

        Find the first instance of <text> in my logs. <channel> is only
necessary if the command is called outside of the channel.
        """
        world.flush()
        filename=str(conf.supybot.directories.log) + "/ChannelLogger/"
        filename+= irc.network + "/" + channel + "/" + channel + ".log"
        f=open(filename,'r')

        line=f.readline()
        while line:
            if string.find(line, text) > -1:
                irc.reply(line[0:-1], prefixNick=False)
                return
            line=f.readline()
        irc.reply("I could not find that text in the logs.", prefixNick=True)
예제 #8
0
    def first(self, irc, msg, args, channel, text):
        """[<channel>] <text>

        Find the first instance of <text> in my logs. <channel> is only
necessary if the command is called outside of the channel.
        """
        world.flush()
        filename = str(conf.supybot.directories.log) + "/ChannelLogger/"
        filename += irc.network + "/" + channel + "/" + channel + ".log"
        f = open(filename, 'r')

        line = f.readline()
        while line:
            if string.find(line, text) > -1:
                irc.reply(line[0:-1], prefixNick=False)
                return
            line = f.readline()
        irc.reply("I could not find that text in the logs.", prefixNick=True)
예제 #9
0
    def _calculate_active_user(self, irc, msg):
        channel = msg.args[0]
        voting_active_time = int(self.registryValue("voting_active_time"))

        world.flush()
        seen_db = SeenDB(seen_filename)

        active_users = []
        for nick in irc.state.channels[channel].users:
            if nick not in self.recently_joined:
                try:
                    results = [[nick, seen_db.seen(channel, nick)]]
                    if len(results) == 1:
                        (nick, info) = results[0]
                        (when, said) = info
                        if (time.time() - when) <= voting_active_time:
                            active_users.append(nick)
                except KeyError:
                    pass

        return active_users