]> jfr.im git - z_archive/Ophion.git/commitdiff
Minor tweaks
authorJohn Runyon <redacted>
Tue, 2 Apr 2013 10:11:41 +0000 (06:11 -0400)
committerJohn Runyon <redacted>
Tue, 2 Apr 2013 10:12:19 +0000 (06:12 -0400)
README
bot.py
classes.py
modules/trivia.py

diff --git a/README b/README
index 3e8cb6811a2eaa0f32a2b7b4c548ad947781148a..a7fe878308800dda713a74c84c7f1d870be0e813 100644 (file)
--- a/README
+++ b/README
@@ -4,6 +4,9 @@ Config:
     bot.py (top)
     classes.py (class Cache)
 
+Pre-requisites:
+    Python, with MySQLdb library (pip install MySQL-python)
+
 Chat (suggestions/comments/whatever):
     irc.quakenet.org #mustis.dev
 
diff --git a/bot.py b/bot.py
index 36581f9e246de7158e02788861f22647ebf40fe7..f45ac202fd3ba9668eb4f2d30082fc496a8f0e07 100755 (executable)
--- a/bot.py
+++ b/bot.py
@@ -12,12 +12,12 @@ dbhost = 'localhost'
 dbuser = 'bot'
 dbpass = 'roboticism'
 dbname = 'bot'
-rootdir = '/home/ophion'
+rootdir = '/home/bots/'
 logfile = rootdir+'/output.log'
 excfile = rootdir+'/exception.log'
 
-oidfile = '/home/ophion/.oidentd.conf'
-identprefix = 'jobbig' # ident will be <identprefix><bot ID#>
+oidfile = '/home/bots/.oidentd.conf'
+identprefix = 'ophion' # ident will be <identprefix><bot ID#>
 
 import socket, select, sys, os, signal, time
 from threading import *
index 3c0838adcaf21e1a0bb47558efd76a9e0dca8801..1290bb679b087262d4677cb1fc1dad467e389810 100644 (file)
@@ -159,7 +159,8 @@ class Bot:
                self.nick = row['nick']
                self.s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
                self.s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
-               self.s.bind((row['vhost'], 0))
+               if row['vhost'] is not None:
+                       self.s.bind((row['vhost'], 0))
                self.s.connect((row['irchost'], row['ircport']))
                self.rawnow("NICK %s" % (self.nick))
                self.rawnow("USER %s * * :%s" % (ident, row['realname']))
@@ -190,6 +191,20 @@ class Bot:
        def __repr__(self): return "<Bot%d: %s>" % (self.id, self.nick)
 
 class Cache:
+       # config
+       lshost = '0.0.0.0'
+       lsport = 13245 
+       moduledata = '/home/bots/modules/'
+       trigger = '!'
+       cmsgs = { # %(id)d = bot id, %(msg)s = log message.
+               'debug':        "\00303[\037DEBUG\037][%(id)d]: %(msg)s",
+               'info':         "\00312[\037INFO\037][%(id)d]: %(msg)s",
+               'warn':         "\00306[\037WARN\037][%(id)d]: %(msg)s",
+               'fatal':        "\00304[\037FATAL\037][%(id)d]: %(msg)s",
+       }
+
+
+       # NOT config
        dbc = None
        ls = None
        admins = {}
@@ -211,18 +226,6 @@ class Cache:
        users = {}
        chans = {}
 
-       ## CONFIG
-       lshost = '0.0.0.0'
-       lsport = 13245
-       triviapath = '/home/ophion/modules/trivia/'
-       trigger = '!'
-       cmsgs = {
-               'debug':        "\00303[\037DEBUG\037][%(id)d]: %(msg)s",
-               'info':         "\00312[\037INFO\037][%(id)d]: %(msg)s",
-               'warn':         "\00306[\037WARN\037][%(id)d]: %(msg)s",
-               'fatal':        "\00304[\037FATAL\037][%(id)d]: %(msg)s",
-       }
-
        def __init__(self):
                global cache
                cache = self
index 0cb89f5ca33ffed486b3824cf222105f2e55f983..2895f3bc797f42abdcfc62971d5f6cb5f5835966 100644 (file)
@@ -22,7 +22,7 @@ def init(cache):
        cache.trivia = {}
 
        try:
-               qfile = open(cache.triviapath+"/questions.txt", 'r')
+               qfile = open(cache.moduledata+"/trivia/questions.txt", 'r')
        except IOError as e:
                print_exc(None, cache.excfile)
                return True
@@ -30,7 +30,7 @@ def init(cache):
        qfile.close()
 
        try:
-               ptsfile = open(cache.triviapath+"/points.json", 'r')
+               ptsfile = open(cache.moduledata+"/trivia/points.json", 'r')
        except IOError as e:
                print_exc(None, cache.excfile)
                return True
@@ -43,7 +43,7 @@ def deinit(cache, reloading=False):
        global questions, points
        cache.currmod = __name__
 
-       ptsfile = open(cache.triviapath+"/points.json", 'w')
+       ptsfile = open(cache.moduledata+"/trivia/points.json", 'w')
        json.dump(points, ptsfile, indent=4)
        ptsfile.close()