5
finop.py - A Utility IRC Bot for #ubuntu-ar
6
Copyright 2010, Marcos Vanetta, malev.com.ar
7
Licensed under the GLP3.
9
https://code.launchpad.net/~marcosvanetta/+junk/finop
10
http://blog.malev.com.ar
12
do not execute this file only.
13
Call for main.py first!
22
from storm.locals import *
25
the_db_file = config.DATABASE
28
class Message (object):
30
In some how it must store:
31
time, nickname, message
32
it also has to store the people who logs in and other message.
33
with css I can manage it to not interrupt the readding.
35
http://chatlogs.musicbrainz.org/musicbrainz/2010/2010-04/2010-04-15.html
41
__storm_table__ = "message"
42
id = Int(primary=True)
49
def __init__(self, message, user):
50
self.date = datetime.datetime.now()
51
self.user = unicode(user, 'utf-8')
52
self.message = unicode(message, 'utf-8')
58
Message.store.commit()
63
if not os.path.exists(the_db_file):
64
cls.database = create_database("sqlite:///" + the_db_file)
65
cls.store = Store(cls.database)
68
CREATE TABLE message (
69
id INTEGER PRIMARY KEY,
77
logging.error('when trying to create table')
79
cls.database = create_database("sqlite:///" + the_db_file)
80
cls.store = Store(cls.database)
82
def write_db(others_nickname, message):
83
if not Message.connectedDB:
85
print "%s: %s" % (others_nickname, message)
86
a = Message(message, others_nickname)
88
if __name__ == '__main__':
93
# a = Message("un dia muy largo", "malev")
95
#logging.debug('This is a debug message')
96
#logging.info('This is an info message')
97
#logging.warning('This is a warning message')
98
#logging.error('This is an error message')
99
#logging.critical('This is a critical error message')