コード例 #1
0
ファイル: sioclogbot.py プロジェクト: tuukka/sioclog
 def sendLine(self, line):
     """send line to server, and add outbound requests to lists."""
     if line.cmd == 'PING':
         self.pingreq[line.args[0]] = True
     if line.cmd == 'WHO':
         self.addRequest(self.whoreq, line)
     if line.cmd == 'TOPIC' and len(line.args) == 1:
         self.addRequest(self.topicreq, line)
     if line.cmd == 'MODE' and len(line.args) == 1:
         self.addRequest(self.modereq, line)
     if line.cmd == 'NAMES':
         self.addRequest(self.namesreq, line)
     if line.cmd == 'AWAY':
         if len(line.args) > 0 and line.args[0] != '': # if setting away:
             self.awaymsg = line.args[0]
     if line.cmd in ["PRIVMSG", "NOTICE"]:
         # need to log self. simulate server info:
         fakeargs = line.args
         fakeargs[1] = "+" + fakeargs[1] # we are "identified"
         fakeline = Line(cmd=line.cmd, args=fakeargs,
                           prefix=self.clientprefix, time=w3c_timestamp())
         # log the line *after* the line currently being processed
         reactor.callLater(0, self.logLine, fakeline)
     if dbg: info("Sent to server: %s" % line)
     Irc.sendLine(self, line)
コード例 #2
0
ファイル: sioclogwww.py プロジェクト: tuukka/sioclog
def sitemap_index(sink, root):
    now = convert_timestamp_to_z(w3c_timestamp())
    today = now.split("T")[0]
    print """
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
"""

    # individual files:
    sitemap_entry(root, max(sink.channel2latest.values()), "hourly", 1.0)
    sitemap_entry(root+"about", None, "weekly", 1.0)
    sitemap_entry(root+"users", None, "daily", 1.0)
    print
    # users:
    nicks = sorted(sink.nicks.keys())
    for nick in nicks:
        sitemap_entry(root+"users/"+nick, sink.nick2latest[nick], "weekly", 0.9)
    print
    # channels:
    channels = sorted(sink.channels.keys())
    channelURIs = []
    for channel in channels:
        channelID = channel.strip("#").lower()
        channelURI = root + channelID + "#channel"

        sitemap_entry(channelURI, sink.channel2latest[channelID], "hourly", 0.9)
    print
    # today's logs:
    for channel in channels:
        channelID = channel.strip("#").lower()
        logURI = "%s%s/%s" % (root, channelID, today)
        latest = max([today, sink.channel2latest[channelID]])
        sitemap_entry(logURI, latest, "hourly", 0.9)
    print
    # daily logs:
    for channel in channels:
        channelID = channel.strip("#").lower()
        for day in sorted(sink.channel2days[channel]):
            logURI = "%s%s/%s" % (root, channelID, day)

            if day != today:
                sitemap_entry(logURI, day, "never", 0.8)

    print "</urlset>"