Exemplo n.º 1
0
    def __init__(self, fname):
        Persist.__init__(self, fname)
        if not self.data:
            self.data = []
        for i in self.data:
            z = Alarmitem(d=i)
            try:
                getattr(z, 'printto')
            except AttributeError:
                setattr(z, 'printto', "")
            periodical.addjob(z.time - time.time(), 1, self.alarmsay, z.nick, \
z)
Exemplo n.º 2
0
def convertpickle(src, target):
    p = gozerbot.compat.persist.Persist(src)    
    if p and p.data:
        pers = Persist(target)
        if not pers.data:
            pers.data = {}
        pers.data.update(p.data)
        try:
            pers.save()
        except TypeError:
            pers2 = Persist(target)
            if not pers2.data:
                pers2.data = {}
            for item, value in p.data.iteritems():
                pers2.data[jsonstring(item)] = value
            pers2.save()
Exemplo n.º 3
0
         db = Db(dbtype='sqlite')
         db.connect('db/infoitem.db')
         result = db.execute(""" SELECT * FROM infoitems """)
         if result:
             for i in result:
                 info.add(*i[1:])
                 teller += 1
     except Exception, ex:
         handle_exception()
 else:
     oldfile = datadir + os.sep + 'old' + os.sep + 'infoitems'
     try:
         from gozerbot.utils.generic import dosed
         from gozerbot.compat.persist import Persist
         dosed(oldfile, 's/cgozerbot\.compat/cgozerplugs/')
         oldinfo = Persist(oldfile)
         assert(oldinfo)
         if not oldinfo.data:
             return
         for item, descrlist in oldinfo.data.iteritems():
             for descr in descrlist:
                 info.add(item, descr, 'none', 0)
                 teller += 1
     except IOError, ex:
         if "No such file" in str(ex):
             rlog(10, 'infoitem', 'nothing to upgrade')
     except Exception, ex:
         rlog(10, 'infoitem', "can't upgrade: %s" % str(ex))
         return
 rlog(10, 'infoitem', 'upgraded %s infoitems' % str(teller))
 return teller
Exemplo n.º 4
0
            if result:
                for i in result:
                    try:
                        quotes.add(i[4], i[2], i[1], i[3])
                    except:
                        quotes.add(i[3], i[2], i[1], i[4])
                    teller += 1
        except Exception, ex:
            handle_exception()
        return teller
    try:
        from gozerbot.utils.generic import dosed
        from gozerbot.compat.persist import Persist
        from gozerbot.compat.todo import Todoitem
        dosed(oldfile, 's/cgozerbot\.compat/cgozerplugs/')
        oldpersist = Persist(oldfile)
        if not oldpersist or not oldpersist.data:
            return
        for item in oldpersist.data:
            quotes.add(item.nick, item.userhost, item.quote)
            teller += 1
    except IOError, ex:
        if "No such file" in str(ex):
            rlog(10, 'quote', 'nothing to upgrade')
    except Exception, ex:
        rlog(10, 'quote', "can't upgrade .. reason: %s" % str(ex))
        handle_exception()
    else:
        rlog(10, 'quote', "upgraded %s items" % teller)

Exemplo n.º 5
0
 def __init__(self, filename, ddir=None):
     self.datadir = ddir or datadir
     Persist.__init__(self, filename)
     if not self.data:
         self.data = {}
     self.users = self.data
Exemplo n.º 6
0
def convertpickle(src, target):
    p = gozerbot.compat.persist.Persist(src)
    if p and p.data:
        pers = Persist(target)
        if not pers.data:
            pers.data = {}
        pers.data.update(p.data)
        try:
            pers.save()
        except TypeError:
            pers2 = Persist(target)
            if not pers2.data:
                pers2.data = {}
            for item, value in p.data.iteritems():
                pers2.data[jsonstring(item)] = value
            pers2.save()
Exemplo n.º 7
0
#

""" command aliases """

__copyright__ = 'this file is in the public domain'


# gozerbot imports
from gozerbot.persist.persist import Persist
from gozerbot.datadir import datadir

# basic import
import os

# the aliases object
aliases = Persist(datadir + os.sep + 'aliases.new', init=False)
if not aliases.data:
    aliases.data = {}

def aliasreverse(what):
    """ get the reverse of an alias. """
    for i, j in aliases.data.iteritems():
        if what == j:
            return i

def aliascheck(ievent):

    """ check if alias is available. """

    try:
Exemplo n.º 8
0
# gozerbot/aliases.py
#
#
""" command aliases """

__copyright__ = 'this file is in the public domain'

# gozerbot imports
from gozerbot.persist.persist import Persist
from gozerbot.datadir import datadir

# basic import
import os

# the aliases object
aliases = Persist(datadir + os.sep + 'aliases.new', init=False)
if not aliases.data:
    aliases.data = {}


def aliasreverse(what):
    """ get the reverse of an alias. """
    for i, j in aliases.data.iteritems():
        if what == j:
            return i


def aliascheck(ievent):
    """ check if alias is available. """

    try:
Exemplo n.º 9
0
from gozerbot.generic import decode_html_entities, get_encoding, geturl, \
geturl2, rlog, handle_exception
from gozerbot.persist.persist import Persist
from gozerbot.persist.persistconfig import PersistConfig
import urllib
import urllib2
import urlparse
import copy
import re
import socket

plughelp.add(
    'snarf', 'the snarf plugin gets the title of the web page of \
the provided url or the last url in the log')

cfg = Persist('snarf', {})
pcfg = PersistConfig()
pcfg.define('allow', ['text/plain', 'text/html', 'application/xml'])
re_html_title = re.compile(u'<title>(.*)</title>', re.I | re.M | re.S)
re_url_match = re.compile(u'((?:http|https)://\S+)')
re_html_valid = {
    'result':
    re.compile('(Failed validation, \
\d+ errors?|Passed validation)', re.I | re.M),
    'modified':
    re.compile('<th>Modified:</th>\
<td colspan="2">([^<]+)</td>', re.I | re.M),
    'server':
    re.compile('<th>Server:</th>\
<td colspan="2">([^<]+)</td>', re.I | re.M),
    'size':
Exemplo n.º 10
0
 def __init__(self, filename, ddir=None):
     self.datadir = ddir or datadir
     Persist.__init__(self, filename)
     if not self.data:
         self.data = {}
     self.users = self.data