]> jfr.im git - erebus.git/blobdiff - erebus.py
log rotation
[erebus.git] / erebus.py
index 34a4ef133b338e5485b542b0170108c2e254cbf7..a4d6ca300c01fae1694830e053f1513da720076f 100644 (file)
--- a/erebus.py
+++ b/erebus.py
@@ -27,7 +27,9 @@ class Erebus(object):
                        self.chans = []
 
                def msg(self, *args, **kwargs):
-                       main.randbot.msg(self, *args, **kwargs)
+                       main.randbot().msg(self, *args, **kwargs)
+               def fastmsg(self, *args, **kwargs):
+                       main.randbot().fastmsg(self, *args, **kwargs)
 
                def isauthed(self):
                        return self.auth is not None
@@ -84,7 +86,9 @@ class Erebus(object):
 
 
                def msg(self, *args, **kwargs):
-                       self.bot.msg(self.name, *args, **kwargs)
+                       self.bot.msg(self, *args, **kwargs)
+               def fastmsg(self, *args, **kwargs):
+                       self.bot.fastmsg(self, *args, **kwargs)
 
                def levelof(self, auth):
                        if auth is None:
@@ -253,6 +257,11 @@ def setup():
        global cfg, main
 
        cfg = config.Config('bot.config')
+
+       pidfile = open(cfg.pidfile, 'w')
+       pidfile.write(str(os.getpid()))
+       pidfile.close()
+
        main = Erebus(cfg)
 
        autoloads = [mod for mod, yes in cfg.items('autoloads') if int(yes) == 1]
@@ -275,5 +284,9 @@ def loop():
                        main.fd(fileno).parse(line)
 
 if __name__ == '__main__':
+       try: os.rename('logfile', 'oldlog.%s' % (time.time()))
+       except: pass
+       sys.stdout = open('logfile', 'w')
+       sys.stderr = sys.stdout
        setup()
        while True: loop()