1

add: initial AI support

This commit is contained in:
diSabler
2014-05-01 14:07:44 +04:00
parent 5ffac3efcf
commit e5295eb994
217 changed files with 78827 additions and 1 deletions

View File

@@ -0,0 +1,98 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
# --------------------------------------------------------------------------- #
# #
# Create databases for iSida Jabber Bot #
# Copyright (C) 2011 diSabler <dsy@dsy.name> #
# #
# This program is free software: you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation, either version 3 of the License, or #
# (at your option) any later version. #
# #
# This program is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with this program. If not, see <http://www.gnu.org/licenses/>. #
# #
# --------------------------------------------------------------------------- #
import os, sys, sqlite3
set_folder = u'settings/' # папка настроек
agestat = set_folder+u'agestat.db' # статистика возрастов
jidbase = set_folder+u'jidbase.db' # статистика jid'ов
talkers = set_folder+u'talkers.db' # статистика болтунов
wtfbase = set_folder+u'wtfbase2.db' # определения
answers = set_folder+u'answers.db' # ответы бота
saytobase = set_folder+u'sayto.db' # база команды "передать"
print 'Databases creator for Isida Jabber Bot v2.00 and higher'
print '(c) Disabler Production Lab.'
print 'Create new bases'
stb = os.path.isfile(agestat)
agest = sqlite3.connect(agestat)
cu_agest = agest.cursor()
if not stb:
cu_agest.execute('''create table age (room text, nick text, jid text, time integer, age integer, status integer, type text, message text)''')
agest.commit()
else: print agestat, 'was skiped!'
agest.close()
stb = os.path.isfile(jidbase)
jidst = sqlite3.connect(jidbase)
cu_jidst = jidst.cursor()
if not stb:
cu_jidst.execute('''create table jid (login text, server text, resourse text)''')
jidst.commit()
else: print jidbase, 'was skiped!'
jidst.close()
stb = os.path.isfile(talkers)
talkst = sqlite3.connect(talkers)
cu_talkst = talkst.cursor()
if not stb:
cu_talkst.execute('''create table talkers (room text, jid text, nick text, words integer, frases integer)''')
talkst.commit()
else: print talkers, 'was skiped!'
talkst.close()
stb = os.path.isfile(wtfbase)
wtfst = sqlite3.connect(wtfbase)
cu_wtfst = wtfst.cursor()
if not stb:
cu_wtfst.execute('''create table wtf (ind integer, room text, jid text, nick text, wtfword text, wtftext text, time text, lim integer)''')
wtfst.commit()
else: print wtfbase, 'was skiped!'
wtfst.close()
stb = os.path.isfile(answers)
answst = sqlite3.connect(answers)
cu_answst = answst.cursor()
if not stb:
cu_answst.execute('''create table answer (ind integer, body text)''')
cu_answst.execute('insert into answer values (?,?)', (1,u';-)'))
cu_answst.execute('insert into answer values (?,?)', (2,u'Привет'))
answst.commit()
else: print answers, 'was skiped!'
answst.close()
stb = os.path.isfile(saytobase)
sdb = sqlite3.connect(saytobase)
cu = sdb.cursor()
if not stb:
cu.execute('''create table st (who text, room text, jid text, message text)''')
sdb.commit()
else: print saytobase, 'was skiped!'
sdb.close()
########################################
print 'Finished!'

165
scripts/old/feed_update.py Normal file
View File

@@ -0,0 +1,165 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
# --------------------------------------------------------------------------- #
# #
# Feeds updater for iSida Jabber Bot #
# Copyright (C) 2011 diSabler <dsy@dsy.name> #
# #
# This program is free software: you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation, either version 3 of the License, or #
# (at your option) any later version. #
# #
# This program is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with this program. If not, see <http://www.gnu.org/licenses/>. #
# #
# --------------------------------------------------------------------------- #
import os,urllib2,sys,re,chardet,hashlib
def smart_encode(text,enc):
tx,splitter = '','|'
while text.count(splitter): splitter += '|'
ttext = text.replace('</','<%s/' % splitter).split(splitter)
for tmp in ttext:
try: tx += unicode(tmp,enc)
except: pass
return tx
def html_encode(body):
encidx = body.find('encoding=')
if encidx >= 0:
enc = body[encidx+10:encidx+30]
if enc.count('"'): enc = enc[:enc.find('"')]
elif enc.count('\''): enc = enc[:enc.find('\'')]
elif enc.count('&'): enc = enc[:enc.find('&')]
else:
encidx = body.find('charset=')
if encidx >= 0:
enc = body[encidx+8:encidx+30]
if enc.count('"'): enc = enc[:enc.find('"')]
elif enc.count('\''): enc = enc[:enc.find('\'')]
elif enc.count('&'): enc = enc[:enc.find('&')]
else: enc = chardet.detect(body)['encoding']
if body == None: body = ''
if enc == None or enc == '' or enc.lower() == 'unicode': enc = 'utf-8'
if enc == 'ISO-8859-2':
tx,splitter = '','|'
while body.count(splitter): splitter += '|'
tbody = body.replace('</','<'+splitter+'/').split(splitter)
cntr = 0
for tmp in tbody:
try:
enc = chardet.detect(tmp)['encoding']
if enc == None or enc == '' or enc.lower() == 'unicode': enc = 'utf-8'
tx += unicode(tmp,enc)
except:
ttext = ''
for tmp2 in tmp:
if (tmp2<='~'): ttext+=tmp2
else: ttext+='?'
tx += ttext
cntr += 1
return tx
else:
try: return smart_encode(body,enc)
except: return 'Encoding error!'
def readfile(filename):
fp = file(filename)
data = fp.read()
fp.close()
return data
def writefile(filename, data):
fp = file(filename, 'w')
fp.write(data)
fp.close()
def getFile(filename,default):
if os.path.isfile(filename):
try: filebody = eval(readfile(filename))
except:
if os.path.isfile(filename+'.back'):
while True:
try:
filebody = eval(readfile(filename+'.back'))
break
except: pass
else:
filebody = default
writefile(filename,str(default))
else:
filebody = default
writefile(filename,str(default))
writefile(filename+'.back',str(filebody))
return filebody
def get_tag(body,tag):
T = re.findall('<%s.*?>(.*?)</%s>' % (tag,tag),body,re.S)
if T: return T[0]
else: return ''
# --------- Settings ----------
set_folder = 'settings/'
feeds = set_folder+'feed'
user_agent = 'Mozilla/5.0 (X11; U; Linux x86_64; ru; rv:1.9.0.4) Gecko/2008120916 Gentoo Firefox/3.0.4'
# -----------------------------
feedbase = getFile(feeds,[])
newfeed = []
for fdd in feedbase:
link = fdd[0]
print link,
if not link[:10].count('://'): link = 'http://'+link
try:
if float(sys.version[:3]) >= 2.6: # python 2.6 and higher
req = urllib2.Request(link.encode('utf-8'))
req.add_header('User-Agent','user_agent')
feed = urllib2.urlopen(url=req,timeout=30).read(262144)
else: feed = urllib.urlopen(link).read()
except: feed = 'Unable to access server!'
is_rss_aton,fc = 0,feed[:256]
if fc.count('<?xml version='):
if fc.count('<feed'):
is_rss_aton = 2
t_feed = feed.split('<title>')
feed = t_feed[0]
for tmp in t_feed[1:]:
tm = tmp.split('</title>',1)
if ord(tm[0][-1]) == 208: tm[0] = tm[0][:-1] + '...'
feed += '<title>%s</title>%s' % tuple(tm)
elif fc.count('<rss') or fc.count('<rdf'): is_rss_aton = 1
feed = html_encode(feed)
feed = re.sub(u'(<span.*?>.*?</span>)','',feed)
feed = re.sub(u'(<div.*?>)','',feed)
feed = re.sub(u'(</div>)','',feed)
if is_rss_aton and feed != 'Encoding error!' and feed != 'Unable to access server!':
print '... readed',
if is_rss_aton == 1:
if feed.count('<item>'): fd = feed.split('<item>')
else: fd = feed.split('<item ')
feed = [fd[0]]
for tmp in fd[1:]: feed.append(tmp.split('</item>')[0])
else:
if feed.count('<entry>'): fd = feed.split('<entry>')
else: fd = feed.split('<entry ')
feed = [fd[0]]
for tmp in fd[1:]: feed.append(tmp.split('</entry>')[0])
break_point = []
for tmp in feed[1:]:
ttitle = get_tag(tmp,'title').replace('&lt;br&gt;','\n')
break_point.append(hashlib.md5(ttitle.encode('utf-8')).hexdigest())
newfeed.append([link,fdd[1],fdd[2],fdd[3],fdd[4],break_point])
print '... generated'
else: print '... fault!'
writefile(feeds,str(newfeed))
print 'done!'
# The end is near!

View File

@@ -0,0 +1,171 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
# --------------------------------------------------------------------------- #
# #
# Create and indexate databases for iSida Jabber Bot #
# Copyright (C) 2011 diSabler <dsy@dsy.name> #
# #
# This program is free software: you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation, either version 3 of the License, or #
# (at your option) any later version. #
# #
# This program is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with this program. If not, see <http://www.gnu.org/licenses/>. #
# #
# --------------------------------------------------------------------------- #
import os, sys, sqlite3
set_folder = u'settings/' # папка настроек
agestat = set_folder+u'agestat.db' # статистика возрастов
jidbase = set_folder+u'jidbase.db' # статистика jid'ов
talkers = set_folder+u'talkers.db' # статистика болтунов
wtfbase = set_folder+u'wtfbase2.db' # определения
answers = set_folder+u'answers.db' # ответы бота
saytobase = set_folder+u'sayto.db' # база команды "передать"
distbase = set_folder+u'dist_user.db' # пользоватальская база команды "dist"
print 'Databases creator and indexator for Isida Jabber Bot v2.00 and higher'
print '(c) Disabler Production Lab.'
stb = os.path.isfile(agestat)
agest = sqlite3.connect(agestat)
cu_agest = agest.cursor()
print agestat,
if not stb:
cu_agest.execute('''create table age (room text, nick text, jid text, time integer, age integer, status integer, type text, message text)''')
agest.commit()
print 'was created,',
else: print 'used exist,',
try: cu_agest.execute('''drop index rj''')
except: pass
try: cu_agest.execute('''drop index rnj''')
except: pass
cu_agest.execute('''create index rj on age (room,jid)''')
cu_agest.execute('''create index rnj on age (room,nick,jid)''')
agest.commit()
print 'indexed'
agest.close()
stb = os.path.isfile(jidbase)
jidst = sqlite3.connect(jidbase)
cu_jidst = jidst.cursor()
print jidbase,
if not stb:
cu_jidst.execute('''create table jid (login text, server text, resourse text)''')
jidst.commit()
print 'was created,',
else: print 'used exist,',
try: cu_jidst.execute('''drop index log''')
except: pass
try: cu_jidst.execute('''drop index srv''')
except: pass
try: cu_jidst.execute('''drop index res''')
except: pass
cu_jidst.execute('''create index log on jid (login)''')
cu_jidst.execute('''create index srv on jid (server)''')
cu_jidst.execute('''create index res on jid (resourse)''')
jidst.commit()
print 'indexed'
jidst.close()
stb = os.path.isfile(talkers)
talkst = sqlite3.connect(talkers)
cu_talkst = talkst.cursor()
print talkers,
if not stb:
cu_talkst.execute('''create table talkers (room text, jid text, nick text, words integer, frases integer)''')
talkst.commit()
print 'was created,',
else: print 'used exist,',
try: cu_talkst.execute('''drop index rj''')
except: pass
try: cu_talkst.execute('''drop index rjn''')
except: pass
cu_talkst.execute('''create index rj on talkers (room,jid)''')
cu_talkst.execute('''create index rjn on talkers (room,jid,nick)''')
talkst.commit()
print 'indexed'
talkst.close()
stb = os.path.isfile(wtfbase)
wtfst = sqlite3.connect(wtfbase)
cu_wtfst = wtfst.cursor()
print wtfbase,
if not stb:
cu_wtfst.execute('''create table wtf (ind integer, room text, jid text, nick text, wtfword text, wtftext text, time text, lim integer)''')
wtfst.commit()
print 'was created,',
else: print 'used exist,',
try: cu_wtfst.execute('''drop index r''')
except: pass
try: cu_wtfst.execute('''drop index rj''')
except: pass
try: cu_wtfst.execute('''drop index rw''')
except: pass
try: cu_wtfst.execute('''drop index rww''')
except: pass
cu_wtfst.execute('''create index r on wtf (room)''')
cu_wtfst.execute('''create index rj on wtf (room,jid)''')
cu_wtfst.execute('''create index rw on wtf (room,wtfword)''')
cu_wtfst.execute('''create index rww on wtf (room,wtfword,wtftext)''')
wtfst.commit()
print 'indexed'
wtfst.close()
stb = os.path.isfile(answers)
answst = sqlite3.connect(answers)
cu_answst = answst.cursor()
print answers,
if not stb:
cu_answst.execute('''create table answer (ind integer, body text)''')
cu_answst.execute('insert into answer values (?,?)', (1,u';-)'))
cu_answst.execute('insert into answer values (?,?)', (2,u'Привет'))
answst.commit()
print 'was created,',
else: print 'used exist,',
try: cu_answst.execute('''drop index id''')
except: pass
cu_answst.execute('''create index id on answer (ind)''')
answst.commit()
print 'indexed'
answst.close()
stb = os.path.isfile(saytobase)
sdb = sqlite3.connect(saytobase)
cu = sdb.cursor()
print saytobase,
if not stb:
cu.execute('''create table st (who text, room text, jid text, message text)''')
sdb.commit()
print 'was created,',
else: print 'used exist,',
try: cu.execute('''drop index rj''')
except: pass
cu.execute('''create index rj on st (room,jid)''')
sdb.commit()
print 'indexed'
sdb.close()
if os.path.isfile(distbase):
distb = sqlite3.connect(distbase)
cu = distb.cursor()
print distbase + ' used exist,',
try: cu.execute('''drop index di''')
except: pass
cu.execute('''create index di on dist (point)''')
distb.commit()
print 'indexed'
distb.close()
########################################
print 'Finished!'

319
scripts/old/pgsql3.0.schema Normal file
View File

@@ -0,0 +1,319 @@
-- --------------------------------------------------------------------------- --
-- --
-- Postgresql scheme for iSida Jabber Bot --
-- Copyright (C) 2012 diSabler <dsy@dsy.name> --
-- --
-- This program is free software: you can redistribute it and/or modify --
-- it under the terms of the GNU General Public License as published by --
-- the Free Software Foundation, either version 3 of the License, or --
-- (at your option) any later version. --
-- --
-- This program is distributed in the hope that it will be useful, --
-- but WITHOUT ANY WARRANTY; without even the implied warranty of --
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --
-- GNU General Public License for more details. --
-- --
-- You should have received a copy of the GNU General Public License --
-- along with this program. If not, see <http://www.gnu.org/licenses/>. --
-- --
-- --------------------------------------------------------------------------- --
--
-- Base of ages
--
CREATE TABLE age (
room text,
nick text,
jid text,
time integer,
age integer,
status integer,
type text,
message text,
no_case_nick text
);
CREATE INDEX age_rj ON age (room,jid);
CREATE INDEX age_rnj ON age (room,nick,jid);
CREATE TABLE jid (
login text,
server text,
resourse text
);
CREATE INDEX jid_log ON jid (login);
CREATE INDEX jid_srv ON jid (server);
CREATE INDEX jid_res ON jid (resourse);
--
-- Base of talkers
--
CREATE TABLE talkers (
room text,
jid text,
nick text,
words integer,
frases integer
);
CREATE INDEX talkers_rj ON talkers (room,jid);
CREATE INDEX talkers_rjn ON talkers (room,jid,nick);
--
-- Base for `WTF` commands
--
CREATE TABLE wtf (
ind integer,
room text,
jid text,
nick text,
wtfword text,
wtftext text,
time integer,
lim integer
);
CREATE INDEX wtf_r ON wtf (room);
CREATE INDEX wtf_rj ON wtf (room,jid);
CREATE INDEX wtf_rw ON wtf (room,wtfword);
--
-- Answers base for random flood
--
CREATE TABLE answer (
ind integer,
body text
);
-- INSERT INTO answer VALUES(1,';-)');
-- INSERT INTO answer VALUES(2,'Hi!');
CREATE INDEX answer_id ON answer (ind);
--
-- Base for `SayTo` plugin
--
CREATE TABLE sayto (
who text,
room text,
jid text,
message text
);
CREATE INDEX sayto_rj ON sayto (room,jid);
--
-- User distances for `Dist` plugin
--
CREATE TABLE dist (
point text,
latitude text,
longtitude text
);
CREATE INDEX dist_di ON dist (point);
CREATE TABLE dist_user (
point text,
latitude text,
longtitude text
);
CREATE INDEX dist_user_di ON dist_user (point);
--
-- Karma base
--
CREATE TABLE karma (
room text,
jid text,
karma int
);
CREATE INDEX karma_krj ON karma (room,jid);
CREATE INDEX karma_crjk ON karma (room,jid,karma);
CREATE TABLE karma_commiters (
room text,
jid text,
karmajid text,
last int
);
CREATE INDEX karma_commiters_rjk ON karma_commiters (room,jid,karmajid);
CREATE TABLE karma_limits (
room text,
jid text,
log text
);
CREATE INDEX karma_limits_lrj ON karma_limits (room,jid);
--
-- Action list base
--
CREATE TABLE acl (
jid text,
action text,
type text,
text text,
command text,
time int,
level int default 9
);
CREATE INDEX acl_jid ON acl (jid,action,type);
--
-- Base for `GisMeteo` plugin
--
CREATE TABLE gis (
code text,
city text,
lcity text
);
CREATE INDEX gis_clcc ON gis (code,lcity,city);
--
-- DEF-Codes
--
CREATE TABLE def_ru_stat (
phone text,
region text,
city text
);
CREATE INDEX def_ru_stat_ph ON def_ru_stat (phone,city);
CREATE TABLE def_ua_stat (
phone text,
region text,
city text
);
CREATE INDEX def_ua_stat_ph ON def_ua_stat (phone,city);
CREATE TABLE def_ru_mobile (
provider text,
region text,
def integer,
defbegin integer,
defend integer,
date text
);
CREATE INDEX def_ru_mobile_ph ON def_ru_mobile (def,defbegin,defend);
--
-- WZ Weather base
--
CREATE TABLE wz (
code text,
city text,
counry text
);
CREATE INDEX wz_ccc ON wz (code,city,counry);
--
-- Muc-filter lock base
--
CREATE TABLE muc_lock (
room text,
jid text
);
CREATE INDEX muc_lock_rj ON muc_lock (room,jid);
--
-- Versions base
--
CREATE TABLE versions (
room text,
jid text,
client text,
version text,
os text,
time integer
);
CREATE INDEX versions_rj ON versions (room,jid);
CREATE INDEX versions_cvo ON versions (client,version,os);
CREATE INDEX versions_rjcvo ON versions (room,jid,client,version,os);
--
-- Issues base
--
CREATE TABLE issues (
id integer,
room text,
jid text,
nick text,
level integer,
tags text,
body text,
status integer,
date integer,
comment text,
accept_by text,
accept_date integer
);
CREATE INDEX issues_r ON issues (room,id);
CREATE INDEX issues_d ON issues (room,date);
--
-- Cron base
--
CREATE TABLE cron (
room text,
jid text,
nick text,
time integer,
repeat text,
command text,
level integer
);
CREATE INDEX cron_r ON cron (room);
CREATE INDEX cron_rt ON cron (room,time);
CREATE INDEX cron_rtr ON cron (room,time,repeat);
--
-- THE END
--

View File

@@ -0,0 +1,103 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
# --------------------------------------------------------------------------- #
# #
# Update iSida Jabber Bot from version 1.6 to 1.7 #
# Copyright (C) 2011 diSabler <dsy@dsy.name> #
# #
# This program is free software: you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation, either version 3 of the License, or #
# (at your option) any later version. #
# #
# This program is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with this program. If not, see <http://www.gnu.org/licenses/>. #
# #
# --------------------------------------------------------------------------- #
import os, sys, sqlite3
set_folder = u'settings/' # папка настроек
agestatfile = set_folder+u'agestat' # статистика возрастов
jidbasefile = set_folder+u'jidbase' # статистика jid'ов
talkersfile = set_folder+u'talkers' # статистика болтунов
wtfbasefile = set_folder+u'wtfbase' # определения
answersfile = set_folder+u'answers' # ответы бота
mainbase = set_folder+u'main.db' # основная база данных
print 'Updater for Isida Jabber Bot from 0.6 to 0.7'
print '(c) Disabler Production Lab.'
def readfile(filename):
fp = file(filename)
data = fp.read()
fp.close()
return data
if os.path.isfile(mainbase):
print 'Remove previos base'
os.system('rm -r '+mainbase)
print 'Create new base'
mtb = os.path.isfile(mainbase)
mdb = sqlite3.connect(mainbase)
cu = mdb.cursor()
cu.execute('''create table age (room text, nick text, jid text, time integer, age integer, status integer, type text, message text)''')
cu.execute('''create table answer (ind integer, body text)''')
cu.execute('''create table jid (login text, server text, resourse text)''')
cu.execute('''create table talkers (room text, jid text, nick text, words integer, frases integer)''')
cu.execute('''create table wtf (ind integer, room text, jid text, nick text, wtfword text, wtftext text, time text)''')
print 'Done'
if os.path.isfile(agestatfile):
agestat = eval(readfile(agestatfile))
print 'Import age statistic ...', len(agestat)
for aa in agestat:
cu.execute('insert into age values (?,?,?,?,?,?,?,?)', (aa[0],aa[1],aa[2],aa[3],aa[4],aa[5],'',''))
if os.path.isfile(answersfile):
answers = eval(readfile(answersfile))
print 'Import auto-answer base ...', len(answers)
cnt = 1
for aa in answers:
cu.execute('insert into answer values (?,?)', (cnt,aa[0]))
cnt += 1
else:
print 'Create defaul auto-answer base'
cu.execute('insert into answer values (?,?)', (1,u';-)'))
cu.execute('insert into answer values (?,?)', (2,u'Привет'))
if os.path.isfile(jidbasefile):
jidbase = eval(readfile(jidbasefile))
print 'Import jid base ...', len(jidbase)
for aa in jidbase:
aa1 = aa[:aa.index('@')]
aa2 = aa[aa.index('@')+1:aa.index('/')]
aa3 = aa[aa.index('/')+1:]
cu.execute('insert into jid values (?,?,?)', (aa1,aa2,aa3))
if os.path.isfile(talkersfile):
talkers = eval(readfile(talkersfile))
print 'Import age statistic ...', len(talkers)
for aa in talkers:
cu.execute('insert into talkers values (?,?,?,?,?)', (aa[0],aa[1],aa[2],aa[3],aa[4]))
if os.path.isfile(wtfbasefile):
cnt = 1
wtfbase = eval(readfile(wtfbasefile))
print 'Import wtf base ...', len(wtfbase)
for aa in wtfbase:
cu.execute('insert into wtf values (?,?,?,?,?,?,?)', (cnt,aa[0],aa[1],aa[2],aa[3],aa[4],aa[5]))
cnt += 1
mdb.commit()
print 'Finished!'

View File

@@ -0,0 +1,110 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
# --------------------------------------------------------------------------- #
# #
# Update iSida Jabber Bot from version 1.7 to 1.8 #
# Copyright (C) 2011 diSabler <dsy@dsy.name> #
# #
# This program is free software: you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation, either version 3 of the License, or #
# (at your option) any later version. #
# #
# This program is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with this program. If not, see <http://www.gnu.org/licenses/>. #
# #
# --------------------------------------------------------------------------- #
import os, sys, sqlite3
set_folder = u'settings/' # папка настроек
agestat = set_folder+u'agestat.db' # статистика возрастов
jidbase = set_folder+u'jidbase.db' # статистика jid'ов
talkers = set_folder+u'talkers.db' # статистика болтунов
wtfbase = set_folder+u'wtfbase.db' # определения
answers = set_folder+u'answers.db' # ответы бота
mainbase = set_folder+u'main.db' # основная база данных
print 'Updater for Isida Jabber Bot from 1.7 to 1.8'
print '(c) Disabler Production Lab.'
print 'Open main base'
mdb = sqlite3.connect(mainbase)
cu = mdb.cursor()
print 'Create new bases'
os.system('rm -rf '+agestat)
agest = sqlite3.connect(agestat)
cu_agest = agest.cursor()
cu_agest.execute('''create table age (room text, nick text, jid text, time integer, age integer, status integer, type text, message text)''')
tmp = cu.execute('select * from age').fetchall()
print 'Import age statistic ...', len(tmp)
for aa in tmp:
cu_agest.execute('insert into age values (?,?,?,?,?,?,?,?)', (aa[0],aa[1],aa[2],aa[3],aa[4],aa[5],aa[6],aa[7]))
agest.commit()
agest.close()
os.system('rm -rf '+jidbase)
jidst = sqlite3.connect(jidbase)
cu_jidst = jidst.cursor()
cu_jidst.execute('''create table jid (login text, server text, resourse text)''')
tmp = cu.execute('select * from jid').fetchall()
print 'Import jid base ...', len(tmp)
for aa in tmp:
cu_jidst.execute('insert into jid values (?,?,?)', (aa[0],aa[1],aa[2]))
jidst.commit()
jidst.close()
os.system('rm -rf '+talkers)
talkst = sqlite3.connect(talkers)
cu_talkst = talkst.cursor()
cu_talkst.execute('''create table talkers (room text, jid text, nick text, words integer, frases integer)''')
tmp = cu.execute('select * from talkers').fetchall()
print 'Import talkers base ...', len(tmp)
for aa in tmp:
cu_talkst.execute('insert into talkers values (?,?,?,?,?)', (aa[0],aa[1],aa[2],aa[3],aa[4]))
talkst.commit()
talkst.close()
os.system('rm -rf '+wtfbase)
wtfst = sqlite3.connect(wtfbase)
cu_wtfst = wtfst.cursor()
cu_wtfst.execute('''create table wtf (ind integer, room text, jid text, nick text, wtfword text, wtftext text, time text)''')
tmp = cu.execute('select * from wtf').fetchall()
cnt = 1
print 'Import wtf base ...', len(tmp)
for aa in tmp:
cu_wtfst.execute('insert into wtf values (?,?,?,?,?,?,?)', (cnt,aa[1],aa[2],aa[3],aa[4],aa[5],aa[6]))
cnt += 1
wtfst.commit()
wtfst.close()
os.system('rm -rf '+answers)
answst = sqlite3.connect(answers)
cu_answst = answst.cursor()
cu_answst.execute('''create table answer (ind integer, body text)''')
tmp = cu.execute('select * from answer').fetchall()
print 'Import auto-answer base ...', len(tmp)
cnt = 1
for aa in tmp:
cu_answst.execute('insert into answer values (?,?)', (cnt,aa[1]))
cnt += 1
answst.commit()
answst.close()
########################################
print 'Done'
mdb.close()
print 'Finished!'

View File

@@ -0,0 +1,53 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
# --------------------------------------------------------------------------- #
# #
# Update iSida Jabber Bot from version 1.9 to 2.00 #
# Copyright (C) 2011 diSabler <dsy@dsy.name> #
# #
# This program is free software: you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation, either version 3 of the License, or #
# (at your option) any later version. #
# #
# This program is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with this program. If not, see <http://www.gnu.org/licenses/>. #
# #
# --------------------------------------------------------------------------- #
import os, sys, sqlite3
set_folder = u'settings/' # папка настроек
wtfbase = set_folder+u'wtfbase.db' # старые определения
wtfbase2 = set_folder+u'wtfbase2.db' # новые определения
print 'Updater for Isida Jabber Bot from 1.8-1.91 to 2.00'
print '(c) Disabler Production Lab.'
os.system('rm -rf '+wtfbase2)
wtf1 = sqlite3.connect(wtfbase)
cu_wtf1 = wtf1.cursor()
wtf2 = sqlite3.connect(wtfbase2)
cu_wtf2 = wtf2.cursor()
cu_wtf2.execute('''create table wtf (ind integer, room text, jid text, nick text, wtfword text, wtftext text, time text, lim integer)''')
tmp = cu_wtf1.execute('select * from wtf').fetchall()
print 'Import wtf base ...', len(tmp)
for aa in tmp:
if aa[1] == 'global': aa += (5,)
else: aa += (0,)
cu_wtf2.execute('insert into wtf values (?,?,?,?,?,?,?,?)', aa)
wtf2.commit()
wtf2.close()
wtf1.close()
print 'Finished!'

View File

@@ -0,0 +1,86 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
# --------------------------------------------------------------------------- #
# #
# Update iSida Jabber Bot from version 2.0 to 2.1 #
# Copyright (C) 2011 diSabler <dsy@dsy.name> #
# #
# This program is free software: you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation, either version 3 of the License, or #
# (at your option) any later version. #
# #
# This program is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with this program. If not, see <http://www.gnu.org/licenses/>. #
# #
# --------------------------------------------------------------------------- #
import os
set_folder = 'settings/'
fld = set_folder+'flood'
preffile = set_folder+'prefix'
sml = set_folder+'smile'
cns = set_folder+'censors'
config = {}
print 'Updater for Isida Jabber Bot from 2.00 to 2.10'
print '(c) Disabler Production Lab.'
def readfile(filename): return file(filename).read()
def writefile(filename, data): file(filename, 'w').write(data)
def getFile(filename,default):
if os.path.isfile(filename):
try: filebody = eval(readfile(filename))
except:
if os.path.isfile(filename+'.back'):
while True:
try:
filebody = eval(readfile(filename+'.back'))
break
except: pass
else:
filebody = default
writefile(filename,str(default))
else:
filebody = default
writefile(filename,str(default))
writefile(filename+'.back',str(filebody))
return filebody
tempo = getFile(fld,[])
for tmp in tempo:
tname = 'flood'
try: t = config[tmp[0]]
except: config[tmp[0]] = {}
config[tmp[0]][tname] = tmp[1]
tempo = getFile(preffile,[])
for tmp in tempo:
tname = 'prefix'
try: t = config[tmp[0]]
except: config[tmp[0]] = {}
config[tmp[0]][tname] = tmp[1]
tempo = getFile(sml,[])
for tmp in tempo:
tname = 'smile'
try: t = config[tmp[0]]
except: config[tmp[0]] = {}
config[tmp[0]][tname] = tmp[1]
tempo = getFile(cns,[])
for tmp in tempo:
tname = 'censor'
try: t = config[tmp[0]]
except: config[tmp[0]] = {}
config[tmp[0]][tname] = tmp[1]
writefile(set_folder+'conference.config',str(config))

View File

@@ -0,0 +1,84 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
# --------------------------------------------------------------------------- #
# #
# Update iSida Jabber Bot from version 2.1 to 2.2 #
# Copyright (C) 2011 diSabler <dsy@dsy.name> #
# #
# This program is free software: you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation, either version 3 of the License, or #
# (at your option) any later version. #
# #
# This program is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with this program. If not, see <http://www.gnu.org/licenses/>. #
# #
# --------------------------------------------------------------------------- #
import os
update = '''
# --------------- Новое в версии 2.20 -----------------
ddos_limit = [1800,1800,1800,1800,1800,600,300,150,60,0] # Время игнора при ddos'е в зависимости от уровня доступа
ddos_diff = [30,30,30,30,20,20,15,10,5,0] # Промежуток между сообщениями для включения анти-ddos
amsg_limit = [86400,86400,86400,86400,86400,86400,43200,3600,1800,60] # лимит времени следующей посылки сообщения для команды msgtoadmin
karma_timeout = [86400,86400,86400,86400,86400,86400,43200,3600,1800,5] # время, через которое можно менять карму в зависимости от уровня доступа
#proxy = {'host':'localhost','port':3128,'user':'me','password':'secret'} # Прокси
#proxy = {'host':'127.0.0.1','port':3128,'user':'','password':''}
#proxy = {'host':'localhost','port':3128}
#server = ('allports.jabber.ru', 443) # Подключение минуя ресольвер
#secure = True # Включение ssl/tls
# --- Опции для поддержки muc-filter --- Работает в тестовом режиме!!! ---
censor_text = '[censored]' # Текст для закрытия мата
adblock_regexp = [u'([-0-9a-zA-Zа-яА-Я_+]+@c[-0-9a-zA-Z-.]+)', # Регекспы для блокиратора рекламы
u'зайди.*? .*?конф.*? .*?([-0-9a-zA-Zа-яА-Я_+]+@?)',
u'заходи.*? .*?конф.*? .*?([-0-9a-zA-Zа-яА-Я_+]+@?)',
u'зайди.*? .*?в.*? .*?([-0-9a-zA-Zа-яА-Я_+]+@?)',
u'заходи.*? .*?в.*? .*?([-0-9a-zA-Zа-яА-Я_+]+@?)',
u'конф.*? .*?([-0-9a-zA-Zа-яА-Я_+]+@?).*?зайди',
u'конф.*? .*?([-0-9a-zA-Zа-яА-Я_+]+@?).*?заходи'
u'все.*? .*?в.*? .*?([-0-9a-zA-Zа-яА-Я_+]+@?)']
muc_filter_large_message_size = 512 # Размер сообщения для фильтра
pastepath = 'paste/' # Путь для больших сообщений
pasteurl = 'http://isida-bot.com/paste/' # Url для сообщений
html_paste_enable = True # Тип True = html, False = text
paste_css_path = '.css/isida.css' # Путь к css
muc_filter_match_count = 3 # счётчик одинаковых слов
muc_filter_match_warning_match = 3 # привышение одинаковых слов
muc_filter_match_warning_space = 5 # привышение пустых частей
muc_filter_match_warning_nn = 3 # количество переводов строк
muc_filter_match_view = 512 # лимит размера сообщения на отработку
paranoia_mode = False
'''
def readfile(filename):
fp = file(filename)
data = fp.read()
fp.close()
return data
def writefile(filename, data):
fp = file(filename, 'w')
fp.write(data)
fp.close()
print 'Updater for Isida Jabber Bot from 2.10 to 2.20'
print '(c) Disabler Production Lab.'
config_path = 'settings/config.py'
tmp = readfile(config_path)
writefile(config_path,tmp+update)
print 'done!'