1 import pyirclib
   2 import string
   3 import sys
   4 import os
   5 import time
   6 import signal
   7 
   8 server   = "irc.openprojects.net"
   9 chan     = "#linuxwiki.de"
  10 nickserv = "xxxxxx"
  11 pagedir  = "/org/linuxwiki.de/data/text"
  12 date     = time.strftime("%Y_2d%m_2d%d")
  13 page     = "IrcLog_2f" + date
  14 pagefile = pagedir + "/" + page
  15 pidfile = "/var/run/irc2wiki.pid"
  16 
  17 def signal_handler(signal,frame):
  18     irc.logout('going to die')
  19     os.remove(pidfile)
  20     sys.exit(0)
  21     
  22 signal.signal(signal.SIGTERM,signal_handler)
  23 
  24 irc = pyirclib.Irclib(server,6667)
  25 irc.setDebug = 0
  26 irc.login('LinuxWiki',username = 'LinuxWiki')
  27 irc.privmsg("nickserv","identify "+nickserv)
  28 irc.join(chan)
  29 
  30 irc.privmsg(chan,"Hi Wikizens! All your word are belong to us! ;)")
  31 
  32 def parsemessage(msg):
  33     if msg['event'] == "PRIVMSG":
  34         if str(msg['text']) != "!NAMES":
  35             nick=str(msg['nickname'])
  36             ofile =  open(pagefile,"a") 
  37             ofile.write('||<)tableborder="0"> ' + nick + ":|| " + msg['text'][:-1] + " ||\n")
  38             ofile.close()
  39     
  40 try:
  41   while 1:
  42     message = irc.getmessage()
  43     parsemessage(message)
  44 except:
  45   os.remove(pidfile)
  46   sys.exit(0)

IrcLog/QuellCode (zuletzt geändert am 2007-12-23 22:46:46 durch localhost)