Exemplo n.º 1
0
cfg.define('logtimestamp', '%Y-%m-%dT%H:%M:%S')
cfg.define('filenametimestamp', '%d-%a-%Y')
cfg.define('nologprefix', '[nolog]')
cfg.define('nologmsg', '-= THIS MESSAGE NOT LOGGED =-')

logfiles = {}
stopped = False

nonchanevents = ['NICK','NOTICE','QUIT']

if not os.path.isdir('logs'):
    os.mkdir('logs')
if not os.path.isdir('logs' + os.sep + 'supy'):
    os.mkdir('logs' + os.sep + 'supy')

for chan in cfg.get('channels'):
    if not os.path.isdir('logs' + os.sep + 'supy' + os.sep + chan[0]):
        os.mkdir('logs' + os.sep + 'supy' + os.sep + chan[0])
    if not os.path.isdir('logs' + os.sep + 'supy' + os.sep + chan[0] + os.sep + chan[1]):
        os.mkdir('logs' + os.sep + 'supy' + os.sep + chan[0] + os.sep + chan[1])

def init():
    global stopped
    callbacks.add('ALL', supylogcb, presupylogcb)
    jcallbacks.add('ALL', jabbersupylogcb, jabberpresupylogcb)
    outmonitor.add('supylog', supylogcb, presupylogcb)
    jabbermonitor.add('supylog', jabbersupylogcb, jabberpresupylogcb)
    stopped = False
    return 1

def shutdown():
Exemplo n.º 2
0
plughelp.add('webserver', 'maintain the bots webserver')

cfg = PersistConfig()
cfg.define('webenable', 0)
cfg.define('webport', 8088)
cfg.define('webhost', '')
cfg.define('whitelist', [])
cfg.define('whitelistenable', 1)
cfg.define('blacklist', [])
cfg.define('showplugs', ['infoitems', 'karma', 'quotes'])
cfg.define('denyplugs', [])
cfg.define('deleteenable', 0)

#cfg.syncold(datadir + os.sep + 'web')
doit = cfg.get('webenable')
if not doit:
    rlog(10, 'webserver', 'not enabled')
else:
    if not users.getname('web@web'):
        users.add('web', [
            'web@web',
        ], [
            'WEB',
        ])
webhostname = cfg.get('webhost')
webport = cfg.get('webport')


def init():
    """ init webserver plugin """
Exemplo n.º 3
0
cfg.define('logtimestamp', '%Y-%m-%dT%H:%M:%S')
cfg.define('filenametimestamp', '%d-%a-%Y')
cfg.define('nologprefix', '[nolog]')
cfg.define('nologmsg', '-= THIS MESSAGE NOT LOGGED =-')

logfiles = {}
stopped = False

nonchanevents = ['NICK', 'NOTICE', 'QUIT']

if not os.path.isdir('logs'):
    os.mkdir('logs')
if not os.path.isdir('logs' + os.sep + 'supy'):
    os.mkdir('logs' + os.sep + 'supy')

for chan in cfg.get('channels'):
    if not os.path.isdir('logs' + os.sep + 'supy' + os.sep + chan[0]):
        os.mkdir('logs' + os.sep + 'supy' + os.sep + chan[0])
    if not os.path.isdir('logs' + os.sep + 'supy' + os.sep + chan[0] + os.sep +
                         chan[1]):
        os.mkdir('logs' + os.sep + 'supy' + os.sep + chan[0] + os.sep +
                 chan[1])


def init():
    global stopped
    callbacks.add('ALL', supylogcb, presupylogcb)
    jcallbacks.add('ALL', jabbersupylogcb, jabberpresupylogcb)
    outmonitor.add('supylog', supylogcb, presupylogcb)
    jabbermonitor.add('supylog', jabbersupylogcb, jabberpresupylogcb)
    stopped = False
Exemplo n.º 4
0
    pass

##33 END UPGRADE PART

cfg = PersistConfig()
cfg.define('enable', 0)
cfg.define('wait', 5)
cfg.define('host' , socket.gethostbyname(socket.getfqdn()))
cfg.define('name' , socket.getfqdn())
cfg.define('port' , 10101)
cfg.define('disable', [])
cfg.define('booturl', 'http://gozerbot.org:10101/')
cfg.define('servermode', 0)

waitre = re.compile(' wait (\d+)', re.I)
hp = "%s:%s" % (cfg.get('host'), cfg.get('port'))
url = "http://%s" % hp

# CLIENT PART

class Client(RestClientAsync):

    def auth(self, userhost, perm):
        kwargs = {}
        kwargs['userhost'] = userhost
        kwargs['perm'] = perm
        self.sendpost(kwargs)

class Node(object):

    def __init__(self, name, url):
Exemplo n.º 5
0
    return 1


def mpd(command):
    try:
        s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        s.settimeout(cfg.get("socket-timeout"))
        s.connect((cfg.get("server-host"), cfg.get("server-port")))
    except socket.error, e:
        raise MPDError, "Failed to connect to server: %s" % str(e)
    m = s.makefile("r")
    l = m.readline()
    if not l.startswith("OK MPD "):
        s.close()
        raise MPDError, "Protocol error"
    if cfg.get("server-pass") and cfg.get("server-pass") != "off":
        s.send("password %s\n" % cfg.get("server-pass"))
        l = m.readline()
        if not l.startswith("OK"):
            s.close()
            raise MPDError, "Protocol error"
    s.send("%s\n" % command)
    s.send("close\n")
    d = []
    while True:
        l = m.readline().strip()
        if not l or l == "OK":
            break
        if ": " in l:
            l = l.split(": ", 1)
            l[0] = l[0].lower()
Exemplo n.º 6
0

##33 END UPGRADE PART

cfg = PersistConfig()
cfg.define('enable', 0)
cfg.define('wait', 5)
cfg.define('host', socket.gethostbyname(socket.getfqdn()))
cfg.define('name', socket.getfqdn())
cfg.define('port', 10101)
cfg.define('disable', [])
cfg.define('booturl', 'http://gozerbot.org:10101/')
cfg.define('servermode', 0)

waitre = re.compile(' wait (\d+)', re.I)
hp = "%s:%s" % (cfg.get('host'), cfg.get('port'))
url = "http://%s" % hp

# CLIENT PART


class Client(RestClientAsync):
    def auth(self, userhost, perm):
        kwargs = {}
        kwargs['userhost'] = userhost
        kwargs['perm'] = perm
        self.sendpost(kwargs)


class Node(object):
    def __init__(self, name, url):
Exemplo n.º 7
0
plughelp.add('webserver', 'maintain the bots webserver')

cfg = PersistConfig()
cfg.define('webenable', 0)
cfg.define('webport', 8088)
cfg.define('webhost', '')
cfg.define('whitelist', [])
cfg.define('whitelistenable', 1)
cfg.define('blacklist', [])
cfg.define('showplugs', ['infoitems', 'karma', 'quotes'])
cfg.define('denyplugs', [])
cfg.define('deleteenable', 0)

#cfg.syncold(datadir + os.sep + 'web')
doit =  cfg.get('webenable')
if not doit:
    rlog(10, 'webserver', 'not enabled')
else:
    if not users.getname('web@web'):
        users.add('web', ['web@web', ], ['WEB', ])
webhostname = cfg.get('webhost')
webport = cfg.get('webport')

def init():
    """ init webserver plugin """
    global httpd
    try:
        if doit:
            httpd = BotHTTPServer((webhostname, webport), BotHTTPRequestHandler)
    except Exception, ex:
Exemplo n.º 8
0
    return 1


def mpd(command):
    try:
        s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        s.settimeout(cfg.get('socket-timeout'))
        s.connect((cfg.get('server-host'), cfg.get('server-port')))
    except socket.error, e:
        raise MPDError, 'Failed to connect to server: %s' % str(e)
    m = s.makefile('r')
    l = m.readline()
    if not l.startswith('OK MPD '):
        s.close()
        raise MPDError, 'Protocol error'
    if cfg.get('server-pass') and cfg.get('server-pass') != 'off':
        s.send('password %s\n' % cfg.get('server-pass'))
        l = m.readline()
        if not l.startswith('OK'):
            s.close()
            raise MPDError, 'Protocol error'
    s.send('%s\n' % command)
    s.send('close\n')
    d = []
    while True:
        l = m.readline().strip()
        if not l or l == 'OK':
            break
        if ': ' in l:
            l = l.split(': ', 1)
            l[0] = l[0].lower()