add: initial AI support
This commit is contained in:
484
scripts/mysql.schema
Normal file
484
scripts/mysql.schema
Normal file
@@ -0,0 +1,484 @@
|
||||
-- --------------------------------------------------------------------------- --
|
||||
-- --
|
||||
-- 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/>. --
|
||||
-- --
|
||||
-- --------------------------------------------------------------------------- --
|
||||
|
||||
-- --------------------------------------------------------------------------- --
|
||||
-- Create base
|
||||
--
|
||||
CREATE DATABASE isidabot DEFAULT CHARACTER SET 'utf8';
|
||||
USE isidabot;
|
||||
|
||||
|
||||
-- --------------------------------------------------------------------------- --
|
||||
-- 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(64),jid(64));
|
||||
|
||||
CREATE INDEX age_rnj ON age (room(64),nick(255),jid(64));
|
||||
|
||||
CREATE TABLE jid (
|
||||
login text,
|
||||
server text,
|
||||
resourse text
|
||||
);
|
||||
|
||||
CREATE INDEX jid_log ON jid (login(255));
|
||||
CREATE INDEX jid_srv ON jid (server(255));
|
||||
CREATE INDEX jid_res ON jid (resourse(255));
|
||||
|
||||
-- --------------------------------------------------------------------------- --
|
||||
-- Base of talkers
|
||||
--
|
||||
CREATE TABLE talkers (
|
||||
room text,
|
||||
jid text,
|
||||
nick text,
|
||||
words integer,
|
||||
frases integer
|
||||
);
|
||||
|
||||
CREATE INDEX talkers_rj ON talkers (room(64),jid(64));
|
||||
CREATE INDEX talkers_rjn ON talkers (room(64),jid(64),nick(255));
|
||||
|
||||
-- --------------------------------------------------------------------------- --
|
||||
-- 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(64));
|
||||
CREATE INDEX wtf_rj ON wtf (room(64),jid(64));
|
||||
CREATE INDEX wtf_rw ON wtf (room(64),wtfword(255));
|
||||
|
||||
-- --------------------------------------------------------------------------- --
|
||||
-- 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(64),jid(64));
|
||||
|
||||
-- --------------------------------------------------------------------------- --
|
||||
-- User distances for `Dist` plugin
|
||||
--
|
||||
CREATE TABLE dist (
|
||||
point text,
|
||||
latitude text,
|
||||
longtitude text
|
||||
);
|
||||
|
||||
CREATE INDEX dist_di ON dist (point(255));
|
||||
|
||||
CREATE TABLE dist_user (
|
||||
point text,
|
||||
latitude text,
|
||||
longtitude text
|
||||
);
|
||||
|
||||
CREATE INDEX dist_user_di ON dist_user (point(255));
|
||||
|
||||
-- --------------------------------------------------------------------------- --
|
||||
-- Karma base
|
||||
--
|
||||
CREATE TABLE karma (
|
||||
room text,
|
||||
jid text,
|
||||
karma int
|
||||
);
|
||||
|
||||
CREATE INDEX karma_krj ON karma (room(64),jid(64));
|
||||
CREATE INDEX karma_crjk ON karma (room(64),jid(64),karma);
|
||||
|
||||
CREATE TABLE karma_commiters (
|
||||
room text,
|
||||
jid text,
|
||||
karmajid text,
|
||||
last int
|
||||
);
|
||||
|
||||
CREATE INDEX karma_commiters_rjk ON karma_commiters (room(64),jid(64),karmajid(64));
|
||||
|
||||
CREATE TABLE karma_limits (
|
||||
room text,
|
||||
jid text,
|
||||
log text
|
||||
);
|
||||
|
||||
CREATE INDEX karma_limits_lrj ON karma_limits (room(64),jid(64));
|
||||
|
||||
-- --------------------------------------------------------------------------- --
|
||||
-- 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(64),action(255),type(255));
|
||||
|
||||
-- --------------------------------------------------------------------------- --
|
||||
-- Base for `GisMeteo` plugin
|
||||
--
|
||||
CREATE TABLE gis (
|
||||
code text,
|
||||
city text,
|
||||
lcity text
|
||||
);
|
||||
|
||||
CREATE INDEX gis_clcc ON gis (code(255),lcity(255),city(255));
|
||||
|
||||
-- --------------------------------------------------------------------------- --
|
||||
-- DEF-Codes
|
||||
--
|
||||
CREATE TABLE def_ru_stat (
|
||||
phone text,
|
||||
region text,
|
||||
city text
|
||||
);
|
||||
|
||||
CREATE INDEX def_ru_stat_ph ON def_ru_stat (phone(255),city(255));
|
||||
|
||||
CREATE TABLE def_ua_stat (
|
||||
phone text,
|
||||
region text,
|
||||
city text
|
||||
);
|
||||
|
||||
CREATE INDEX def_ua_stat_ph ON def_ua_stat (phone(255),city(255));
|
||||
|
||||
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(255),city(255),counry(255));
|
||||
|
||||
-- --------------------------------------------------------------------------- --
|
||||
-- Muc-filter lock base
|
||||
--
|
||||
CREATE TABLE muc_lock (
|
||||
room text,
|
||||
jid text
|
||||
);
|
||||
|
||||
CREATE INDEX muc_lock_rj ON muc_lock (room(64),jid(64));
|
||||
|
||||
-- --------------------------------------------------------------------------- --
|
||||
-- Versions base
|
||||
--
|
||||
CREATE TABLE versions (
|
||||
room text,
|
||||
jid text,
|
||||
client text,
|
||||
version text,
|
||||
os text,
|
||||
time integer
|
||||
);
|
||||
|
||||
CREATE INDEX versions_rj ON versions (room(64),jid(64));
|
||||
CREATE INDEX versions_cvo ON versions (client(255),version(255),os(255));
|
||||
CREATE INDEX versions_rjcvo ON versions (room(64),jid(64),client(255),version(255),os(255));
|
||||
|
||||
-- --------------------------------------------------------------------------- --
|
||||
-- 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(64),id);
|
||||
CREATE INDEX issues_d ON issues (room(64),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(64));
|
||||
CREATE INDEX cron_rt ON cron (room(64),time);
|
||||
CREATE INDEX cron_rtr ON cron (room(64),time,`repeat`(255));
|
||||
|
||||
-- --------------------------------------------------------------------------- --
|
||||
-- Conference config
|
||||
--
|
||||
CREATE TABLE config_conf (
|
||||
room text,
|
||||
`option` text,
|
||||
value text
|
||||
);
|
||||
|
||||
CREATE INDEX config_conf_r ON config_conf (room(64));
|
||||
CREATE INDEX config_conf_ro ON config_conf (room(64),`option`(255));
|
||||
|
||||
-- --------------------------------------------------------------------------- --
|
||||
-- Owner config
|
||||
--
|
||||
CREATE TABLE config_owner (
|
||||
`option` varchar(255) unique,
|
||||
value text
|
||||
);
|
||||
|
||||
CREATE INDEX config_owner_o ON config_owner (`option`(255));
|
||||
|
||||
-- --------------------------------------------------------------------------- --
|
||||
-- Top command
|
||||
--
|
||||
CREATE TABLE top (
|
||||
room varchar(255) unique,
|
||||
`count` integer,
|
||||
time integer
|
||||
);
|
||||
|
||||
CREATE INDEX top_r ON top (room(64));
|
||||
CREATE INDEX top_rc ON top (room(64),count);
|
||||
|
||||
-- --------------------------------------------------------------------------- --
|
||||
-- Aliases
|
||||
--
|
||||
CREATE TABLE alias (
|
||||
room text,
|
||||
`match` text,
|
||||
cmd text
|
||||
);
|
||||
|
||||
CREATE INDEX alias_r ON alias (room(64));
|
||||
CREATE INDEX alias_rm ON alias (room(64),`match`(255));
|
||||
|
||||
-- --------------------------------------------------------------------------- --
|
||||
-- Blacklist for rooms
|
||||
--
|
||||
CREATE TABLE blacklist (
|
||||
room varchar(255) unique
|
||||
);
|
||||
|
||||
-- --------------------------------------------------------------------------- --
|
||||
-- Comm ON/OFF
|
||||
--
|
||||
CREATE TABLE commonoff (
|
||||
room text,
|
||||
cmd text
|
||||
);
|
||||
|
||||
CREATE INDEX commonoff_r ON commonoff (room(64));
|
||||
CREATE INDEX commonoff_rm ON commonoff (room(64),cmd(255));
|
||||
|
||||
-- --------------------------------------------------------------------------- --
|
||||
-- Rooms list
|
||||
--
|
||||
CREATE TABLE conference (
|
||||
room varchar(255) unique,
|
||||
passwd text
|
||||
);
|
||||
|
||||
-- --------------------------------------------------------------------------- --
|
||||
-- Feeds
|
||||
--
|
||||
CREATE TABLE feed (
|
||||
url text,
|
||||
`update` varchar(255),
|
||||
type text,
|
||||
time integer,
|
||||
room text,
|
||||
hash text,
|
||||
changed text
|
||||
);
|
||||
|
||||
CREATE INDEX feed_r ON feed (room(64));
|
||||
CREATE INDEX feed_rt ON feed (room(64),time);
|
||||
|
||||
-- --------------------------------------------------------------------------- --
|
||||
-- Hiden rooms
|
||||
--
|
||||
CREATE TABLE hiden_rooms (
|
||||
room varchar(255) unique
|
||||
);
|
||||
|
||||
-- --------------------------------------------------------------------------- --
|
||||
-- Bot Ignore
|
||||
--
|
||||
CREATE TABLE bot_ignore (
|
||||
pattern varchar(255) unique
|
||||
);
|
||||
|
||||
CREATE INDEX bot_ignore_p ON bot_ignore (pattern(255));
|
||||
|
||||
-- --------------------------------------------------------------------------- --
|
||||
-- Bot Owner
|
||||
--
|
||||
CREATE TABLE bot_owner (
|
||||
jid varchar(255) unique
|
||||
);
|
||||
|
||||
CREATE INDEX bot_owner_j ON bot_owner (jid(64));
|
||||
|
||||
-- --------------------------------------------------------------------------- --
|
||||
-- Logs in rooms
|
||||
--
|
||||
CREATE TABLE log_rooms (
|
||||
room varchar(255) unique
|
||||
);
|
||||
|
||||
CREATE INDEX log_rooms_r ON log_rooms (room(64));
|
||||
|
||||
-- --------------------------------------------------------------------------- --
|
||||
-- Spy for activity
|
||||
--
|
||||
CREATE TABLE spy (
|
||||
room varchar(255) unique,
|
||||
time integer,
|
||||
participant integer,
|
||||
message integer,
|
||||
pattern text
|
||||
);
|
||||
|
||||
CREATE INDEX spy_r ON spy (room(64));
|
||||
CREATE INDEX spy_rt ON spy (room(64),time);
|
||||
|
||||
-- --------------------------------------------------------------------------- --
|
||||
-- Temporary ban
|
||||
--
|
||||
CREATE TABLE tmp_ban (
|
||||
room text,
|
||||
jid text,
|
||||
time integer
|
||||
);
|
||||
|
||||
CREATE INDEX tmp_ban_r ON tmp_ban (room(64));
|
||||
CREATE INDEX tmp_ban_rt ON tmp_ban (room(64),time);
|
||||
|
||||
-- --------------------------------------------------------------------------- --
|
||||
-- Say to owner
|
||||
--
|
||||
CREATE TABLE saytoowner (
|
||||
jid varchar(255) unique,
|
||||
time integer
|
||||
);
|
||||
|
||||
-- --------------------------------------------------------------------------- --
|
||||
-- Ignore ban for global_ban
|
||||
--
|
||||
CREATE TABLE ignore_ban (
|
||||
room varchar(255) unique
|
||||
);
|
||||
|
||||
-- --------------------------------------------------------------------------- --
|
||||
-- First join time
|
||||
--
|
||||
CREATE TABLE first_join (
|
||||
room text,
|
||||
jid text,
|
||||
time integer
|
||||
);
|
||||
|
||||
CREATE INDEX join_rj ON first_join (room(64),jid(64));
|
||||
|
||||
-- --------------------------------------------------------------------------- --
|
||||
-- URL Storage
|
||||
--
|
||||
CREATE TABLE url (
|
||||
room text,
|
||||
jid text,
|
||||
nick text,
|
||||
time integer,
|
||||
url text,
|
||||
title text);
|
||||
|
||||
CREATE INDEX url_r ON url (room(64));
|
||||
CREATE INDEX url_rj ON url (room(64),jid(64));
|
||||
CREATE INDEX url_rjn ON url (room(64),jid(64),nick(255));
|
||||
CREATE INDEX url_rt ON url (room(64),time);
|
||||
|
||||
-- --------------------------------------------------------------------------- --
|
||||
-- THE END
|
||||
-- --------------------------------------------------------------------------- --
|
||||
98
scripts/old/create_databases.py
Normal file
98
scripts/old/create_databases.py
Normal 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
165
scripts/old/feed_update.py
Normal 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('<br>','\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!
|
||||
171
scripts/old/indexate_databases.py
Normal file
171
scripts/old/indexate_databases.py
Normal 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
319
scripts/old/pgsql3.0.schema
Normal 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
|
||||
--
|
||||
103
scripts/old/update1_6to1_7.py
Normal file
103
scripts/old/update1_6to1_7.py
Normal 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!'
|
||||
110
scripts/old/update1_7to1_8.py
Normal file
110
scripts/old/update1_7to1_8.py
Normal 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!'
|
||||
53
scripts/old/update1_91to2_00.py
Normal file
53
scripts/old/update1_91to2_00.py
Normal 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!'
|
||||
86
scripts/old/update2_0to2_1.py
Normal file
86
scripts/old/update2_0to2_1.py
Normal 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))
|
||||
84
scripts/old/update2_1to2_2.py
Normal file
84
scripts/old/update2_1to2_2.py
Normal 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!'
|
||||
477
scripts/pgsql.schema
Normal file
477
scripts/pgsql.schema
Normal file
@@ -0,0 +1,477 @@
|
||||
-- --------------------------------------------------------------------------- --
|
||||
-- --
|
||||
-- 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);
|
||||
|
||||
-- --------------------------------------------------------------------------- --
|
||||
-- Conference config
|
||||
--
|
||||
CREATE TABLE config_conf (
|
||||
room text,
|
||||
option text,
|
||||
value text
|
||||
);
|
||||
|
||||
CREATE INDEX config_conf_r ON config_conf (room);
|
||||
CREATE INDEX config_conf_ro ON config_conf (room,option);
|
||||
|
||||
-- --------------------------------------------------------------------------- --
|
||||
-- Owner config
|
||||
--
|
||||
CREATE TABLE config_owner (
|
||||
option text unique,
|
||||
value text
|
||||
);
|
||||
|
||||
CREATE INDEX config_owner_o ON config_owner (option);
|
||||
|
||||
-- --------------------------------------------------------------------------- --
|
||||
-- Top command
|
||||
--
|
||||
CREATE TABLE top (
|
||||
room text unique,
|
||||
count integer,
|
||||
time integer
|
||||
);
|
||||
|
||||
CREATE INDEX top_r ON top (room);
|
||||
CREATE INDEX top_rc ON top (room,count);
|
||||
|
||||
-- --------------------------------------------------------------------------- --
|
||||
-- Aliases
|
||||
--
|
||||
CREATE TABLE alias (
|
||||
room text,
|
||||
match text,
|
||||
cmd text
|
||||
);
|
||||
|
||||
CREATE INDEX alias_r ON alias (room);
|
||||
CREATE INDEX alias_rm ON alias (room,match);
|
||||
|
||||
-- --------------------------------------------------------------------------- --
|
||||
-- Blacklist for rooms
|
||||
--
|
||||
CREATE TABLE blacklist (
|
||||
room text unique
|
||||
);
|
||||
|
||||
-- --------------------------------------------------------------------------- --
|
||||
-- Comm ON/OFF
|
||||
--
|
||||
CREATE TABLE commonoff (
|
||||
room text,
|
||||
cmd text
|
||||
);
|
||||
|
||||
CREATE INDEX commonoff_r ON commonoff (room);
|
||||
CREATE INDEX commonoff_rm ON commonoff (room,cmd);
|
||||
|
||||
-- --------------------------------------------------------------------------- --
|
||||
-- Rooms list
|
||||
--
|
||||
CREATE TABLE conference (
|
||||
room text unique,
|
||||
passwd text
|
||||
);
|
||||
|
||||
-- --------------------------------------------------------------------------- --
|
||||
-- Feeds
|
||||
--
|
||||
CREATE TABLE feed (
|
||||
url text,
|
||||
update text,
|
||||
type text,
|
||||
time integer,
|
||||
room text,
|
||||
hash text array[10],
|
||||
changed text
|
||||
);
|
||||
|
||||
CREATE INDEX feed_r ON feed (room);
|
||||
CREATE INDEX feed_rt ON feed (room,time);
|
||||
|
||||
-- --------------------------------------------------------------------------- --
|
||||
-- Hiden rooms
|
||||
--
|
||||
CREATE TABLE hiden_rooms (
|
||||
room text unique
|
||||
);
|
||||
|
||||
-- --------------------------------------------------------------------------- --
|
||||
-- Bot Ignore
|
||||
--
|
||||
CREATE TABLE bot_ignore (
|
||||
pattern text unique
|
||||
);
|
||||
|
||||
CREATE INDEX bot_ignore_p ON bot_ignore (pattern);
|
||||
|
||||
-- --------------------------------------------------------------------------- --
|
||||
-- Bot Owner
|
||||
--
|
||||
CREATE TABLE bot_owner (
|
||||
jid text unique
|
||||
);
|
||||
|
||||
CREATE INDEX bot_owner_j ON bot_owner (jid);
|
||||
|
||||
-- --------------------------------------------------------------------------- --
|
||||
-- Logs in rooms
|
||||
--
|
||||
CREATE TABLE log_rooms (
|
||||
room text unique
|
||||
);
|
||||
|
||||
CREATE INDEX log_rooms_r ON log_rooms (room);
|
||||
|
||||
-- --------------------------------------------------------------------------- --
|
||||
-- Spy for activity
|
||||
--
|
||||
CREATE TABLE spy (
|
||||
room text unique,
|
||||
time integer,
|
||||
participant integer,
|
||||
message integer,
|
||||
pattern text
|
||||
);
|
||||
|
||||
CREATE INDEX spy_r ON spy (room);
|
||||
CREATE INDEX spy_rt ON spy (room,time);
|
||||
|
||||
-- --------------------------------------------------------------------------- --
|
||||
-- Temporary ban
|
||||
--
|
||||
CREATE TABLE tmp_ban (
|
||||
room text,
|
||||
jid text,
|
||||
time integer
|
||||
);
|
||||
|
||||
CREATE INDEX tmp_ban_r ON tmp_ban (room);
|
||||
CREATE INDEX tmp_ban_rt ON tmp_ban (room,time);
|
||||
|
||||
-- --------------------------------------------------------------------------- --
|
||||
-- Say to owner
|
||||
--
|
||||
CREATE TABLE saytoowner (
|
||||
jid text unique,
|
||||
time integer
|
||||
);
|
||||
|
||||
-- --------------------------------------------------------------------------- --
|
||||
-- Ignore ban for global_ban
|
||||
--
|
||||
CREATE TABLE ignore_ban (
|
||||
room text unique
|
||||
);
|
||||
|
||||
-- --------------------------------------------------------------------------- --
|
||||
-- First join time
|
||||
--
|
||||
CREATE TABLE first_join (
|
||||
room text,
|
||||
jid text,
|
||||
time integer
|
||||
);
|
||||
|
||||
CREATE INDEX join_rj ON first_join (room,jid);
|
||||
|
||||
-- --------------------------------------------------------------------------- --
|
||||
-- URL Storage
|
||||
--
|
||||
CREATE TABLE url (
|
||||
room text,
|
||||
jid text,
|
||||
nick text,
|
||||
time integer,
|
||||
url text,
|
||||
title text);
|
||||
|
||||
CREATE INDEX url_r ON url (room);
|
||||
CREATE INDEX url_rj ON url (room,jid);
|
||||
CREATE INDEX url_rjn ON url (room,jid,nick);
|
||||
CREATE INDEX url_rt ON url (room,time);
|
||||
|
||||
-- --------------------------------------------------------------------------- --
|
||||
-- THE END
|
||||
-- --------------------------------------------------------------------------- --
|
||||
196
scripts/pgsql3.1.schema
Normal file
196
scripts/pgsql3.1.schema
Normal file
@@ -0,0 +1,196 @@
|
||||
-- --------------------------------------------------------------------------- --
|
||||
-- --
|
||||
-- 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/>. --
|
||||
-- --
|
||||
-- --------------------------------------------------------------------------- --
|
||||
|
||||
-- --------------------------------------------------------------------------- --
|
||||
-- Conference config
|
||||
--
|
||||
CREATE TABLE config_conf (
|
||||
room text,
|
||||
option text,
|
||||
value text
|
||||
);
|
||||
|
||||
CREATE INDEX config_conf_r ON config_conf (room);
|
||||
CREATE INDEX config_conf_ro ON config_conf (room,option);
|
||||
|
||||
-- --------------------------------------------------------------------------- --
|
||||
-- Owner config
|
||||
--
|
||||
CREATE TABLE config_owner (
|
||||
option text unique,
|
||||
value text
|
||||
);
|
||||
|
||||
CREATE INDEX config_owner_o ON config_owner (option);
|
||||
|
||||
-- --------------------------------------------------------------------------- --
|
||||
-- Top command
|
||||
--
|
||||
CREATE TABLE top (
|
||||
room text unique,
|
||||
count integer,
|
||||
time integer
|
||||
);
|
||||
|
||||
CREATE INDEX top_r ON top (room);
|
||||
CREATE INDEX top_rc ON top (room,count);
|
||||
|
||||
-- --------------------------------------------------------------------------- --
|
||||
-- Aliases
|
||||
--
|
||||
CREATE TABLE alias (
|
||||
room text,
|
||||
match text,
|
||||
cmd text
|
||||
);
|
||||
|
||||
CREATE INDEX alias_r ON alias (room);
|
||||
CREATE INDEX alias_rm ON alias (room,match);
|
||||
|
||||
-- --------------------------------------------------------------------------- --
|
||||
-- Blacklist for rooms
|
||||
--
|
||||
CREATE TABLE blacklist (
|
||||
room text unique
|
||||
);
|
||||
|
||||
-- --------------------------------------------------------------------------- --
|
||||
-- Comm ON/OFF
|
||||
--
|
||||
CREATE TABLE commonoff (
|
||||
room text,
|
||||
cmd text
|
||||
);
|
||||
|
||||
CREATE INDEX commonoff_r ON commonoff (room);
|
||||
CREATE INDEX commonoff_rm ON commonoff (room,cmd);
|
||||
|
||||
-- --------------------------------------------------------------------------- --
|
||||
-- Rooms list
|
||||
--
|
||||
CREATE TABLE conference (
|
||||
room text unique,
|
||||
passwd text
|
||||
);
|
||||
|
||||
-- --------------------------------------------------------------------------- --
|
||||
-- Feeds
|
||||
--
|
||||
CREATE TABLE feed (
|
||||
url text,
|
||||
update text,
|
||||
type text,
|
||||
time integer,
|
||||
room text,
|
||||
hash text array[10]
|
||||
);
|
||||
|
||||
CREATE INDEX feed_r ON feed (room);
|
||||
CREATE INDEX feed_rt ON feed (room,time);
|
||||
|
||||
-- --------------------------------------------------------------------------- --
|
||||
-- Hiden rooms
|
||||
--
|
||||
CREATE TABLE hiden_rooms (
|
||||
room text unique
|
||||
);
|
||||
|
||||
-- --------------------------------------------------------------------------- --
|
||||
-- Bot Ignore
|
||||
--
|
||||
CREATE TABLE bot_ignore (
|
||||
pattern text unique
|
||||
);
|
||||
|
||||
CREATE INDEX bot_ignore_p ON bot_ignore (pattern);
|
||||
|
||||
-- --------------------------------------------------------------------------- --
|
||||
-- Bot Owner
|
||||
--
|
||||
CREATE TABLE bot_owner (
|
||||
jid text unique
|
||||
);
|
||||
|
||||
CREATE INDEX bot_owner_j ON bot_owner (jid);
|
||||
|
||||
-- --------------------------------------------------------------------------- --
|
||||
-- Logs in rooms
|
||||
--
|
||||
CREATE TABLE log_rooms (
|
||||
room text unique
|
||||
);
|
||||
|
||||
CREATE INDEX log_rooms_r ON log_rooms (room);
|
||||
|
||||
-- --------------------------------------------------------------------------- --
|
||||
-- Spy for activity
|
||||
--
|
||||
CREATE TABLE spy (
|
||||
room text unique,
|
||||
time integer,
|
||||
participant integer,
|
||||
message integer,
|
||||
pattern text
|
||||
);
|
||||
|
||||
CREATE INDEX spy_r ON spy (room);
|
||||
CREATE INDEX spy_rt ON spy (room,time);
|
||||
|
||||
-- --------------------------------------------------------------------------- --
|
||||
-- Temporary ban
|
||||
--
|
||||
CREATE TABLE tmp_ban (
|
||||
room text,
|
||||
jid text,
|
||||
time integer
|
||||
);
|
||||
|
||||
CREATE INDEX tmp_ban_r ON tmp_ban (room);
|
||||
CREATE INDEX tmp_ban_rt ON tmp_ban (room,time);
|
||||
|
||||
-- --------------------------------------------------------------------------- --
|
||||
-- Say to owner
|
||||
--
|
||||
CREATE TABLE saytoowner (
|
||||
jid text unique,
|
||||
time integer
|
||||
);
|
||||
|
||||
-- --------------------------------------------------------------------------- --
|
||||
-- Ignore ban for global_ban
|
||||
--
|
||||
CREATE TABLE ignore_ban (
|
||||
room text unique
|
||||
);
|
||||
|
||||
-- --------------------------------------------------------------------------- --
|
||||
-- First join time
|
||||
--
|
||||
CREATE TABLE first_join (
|
||||
room text,
|
||||
jid text,
|
||||
time integer
|
||||
);
|
||||
|
||||
CREATE INDEX join_rj ON first_join (room,jid);
|
||||
|
||||
-- --------------------------------------------------------------------------- --
|
||||
-- THE END
|
||||
-- --------------------------------------------------------------------------- --
|
||||
39
scripts/pgsql3.2.schema
Normal file
39
scripts/pgsql3.2.schema
Normal file
@@ -0,0 +1,39 @@
|
||||
-- --------------------------------------------------------------------------- --
|
||||
-- --
|
||||
-- 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/>. --
|
||||
-- --
|
||||
-- --------------------------------------------------------------------------- --
|
||||
|
||||
-- --------------------------------------------------------------------------- --
|
||||
-- URL Storage
|
||||
--
|
||||
CREATE TABLE url (
|
||||
room text,
|
||||
jid text,
|
||||
nick text,
|
||||
time integer,
|
||||
url text,
|
||||
title text);
|
||||
|
||||
CREATE INDEX url_r ON url (room);
|
||||
CREATE INDEX url_rj ON url (room,jid);
|
||||
CREATE INDEX url_rjn ON url (room,jid,nick);
|
||||
CREATE INDEX url_rt ON url (room,time);
|
||||
|
||||
-- --------------------------------------------------------------------------- --
|
||||
-- THE END
|
||||
-- --------------------------------------------------------------------------- --
|
||||
452
scripts/pgsql_remove_duplicates.schema
Normal file
452
scripts/pgsql_remove_duplicates.schema
Normal file
@@ -0,0 +1,452 @@
|
||||
-- --------------------------------------------------------------------------- --
|
||||
-- --
|
||||
-- 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 tmp (
|
||||
room text,
|
||||
nick text,
|
||||
jid text,
|
||||
time integer,
|
||||
age integer,
|
||||
status integer,
|
||||
type text,
|
||||
message text,
|
||||
no_case_nick text
|
||||
);
|
||||
|
||||
INSERT INTO tmp SELECT DISTINCT * FROM age;
|
||||
DROP TABLE age;
|
||||
ALTER TABLE tmp RENAME TO age;
|
||||
|
||||
CREATE INDEX age_rj ON age (room,jid);
|
||||
|
||||
CREATE INDEX age_rnj ON age (room,nick,jid);
|
||||
|
||||
CREATE TABLE tmp (
|
||||
login text,
|
||||
server text,
|
||||
resourse text
|
||||
);
|
||||
|
||||
INSERT INTO tmp SELECT DISTINCT * FROM jid;
|
||||
DROP TABLE jid;
|
||||
ALTER TABLE tmp RENAME TO jid;
|
||||
|
||||
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 tmp (
|
||||
room text,
|
||||
jid text,
|
||||
nick text,
|
||||
words integer,
|
||||
frases integer
|
||||
);
|
||||
|
||||
INSERT INTO tmp SELECT DISTINCT * FROM talkers;
|
||||
DROP TABLE talkers;
|
||||
ALTER TABLE tmp RENAME TO talkers;
|
||||
|
||||
CREATE INDEX talkers_rj ON talkers (room,jid);
|
||||
CREATE INDEX talkers_rjn ON talkers (room,jid,nick);
|
||||
|
||||
-- --------------------------------------------------------------------------- --
|
||||
-- Base for `WTF` commands
|
||||
--
|
||||
CREATE TABLE tmp (
|
||||
ind integer,
|
||||
room text,
|
||||
jid text,
|
||||
nick text,
|
||||
wtfword text,
|
||||
wtftext text,
|
||||
time integer,
|
||||
lim integer
|
||||
);
|
||||
|
||||
INSERT INTO tmp SELECT DISTINCT * FROM wtf;
|
||||
DROP TABLE wtf;
|
||||
ALTER TABLE tmp RENAME TO wtf;
|
||||
|
||||
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 tmp (
|
||||
ind integer,
|
||||
body text
|
||||
);
|
||||
|
||||
INSERT INTO tmp SELECT DISTINCT * FROM answer;
|
||||
DROP TABLE answer;
|
||||
ALTER TABLE tmp RENAME TO answer;
|
||||
|
||||
-- INSERT INTO answer VALUES(1,';-)');
|
||||
-- INSERT INTO answer VALUES(2,'Hi!');
|
||||
CREATE INDEX answer_id ON answer (ind);
|
||||
|
||||
-- --------------------------------------------------------------------------- --
|
||||
-- Base for `SayTo` plugin
|
||||
--
|
||||
CREATE TABLE tmp (
|
||||
who text,
|
||||
room text,
|
||||
jid text,
|
||||
message text
|
||||
);
|
||||
|
||||
INSERT INTO tmp SELECT DISTINCT * FROM sayto;
|
||||
DROP TABLE sayto;
|
||||
ALTER TABLE tmp RENAME TO sayto;
|
||||
|
||||
CREATE INDEX sayto_rj ON sayto (room,jid);
|
||||
|
||||
-- --------------------------------------------------------------------------- --
|
||||
-- User distances for `Dist` plugin
|
||||
--
|
||||
CREATE TABLE tmp (
|
||||
point text,
|
||||
latitude text,
|
||||
longtitude text
|
||||
);
|
||||
|
||||
INSERT INTO tmp SELECT DISTINCT * FROM dist;
|
||||
DROP TABLE dist;
|
||||
ALTER TABLE tmp RENAME TO dist;
|
||||
|
||||
CREATE INDEX dist_di ON dist (point);
|
||||
|
||||
CREATE TABLE tmp (
|
||||
point text,
|
||||
latitude text,
|
||||
longtitude text
|
||||
);
|
||||
|
||||
INSERT INTO tmp SELECT DISTINCT * FROM dist_user;
|
||||
DROP TABLE dist_user;
|
||||
ALTER TABLE tmp RENAME TO dist_user;
|
||||
|
||||
CREATE INDEX dist_user_di ON dist_user (point);
|
||||
|
||||
-- --------------------------------------------------------------------------- --
|
||||
-- Karma base
|
||||
--
|
||||
CREATE TABLE tmp (
|
||||
room text,
|
||||
jid text,
|
||||
karma int
|
||||
);
|
||||
|
||||
INSERT INTO tmp SELECT DISTINCT * FROM karma;
|
||||
DROP TABLE karma;
|
||||
ALTER TABLE tmp RENAME TO karma;
|
||||
|
||||
CREATE INDEX karma_krj ON karma (room,jid);
|
||||
CREATE INDEX karma_crjk ON karma (room,jid,karma);
|
||||
|
||||
CREATE TABLE tmp (
|
||||
room text,
|
||||
jid text,
|
||||
karmajid text,
|
||||
last int
|
||||
);
|
||||
|
||||
INSERT INTO tmp SELECT DISTINCT * FROM karma_commiters;
|
||||
DROP TABLE karma_commiters;
|
||||
ALTER TABLE tmp RENAME TO karma_commiters;
|
||||
|
||||
CREATE INDEX karma_commiters_rjk on karma_commiters (room,jid,karmajid);
|
||||
|
||||
CREATE TABLE tmp (
|
||||
room text,
|
||||
jid text,
|
||||
log text
|
||||
);
|
||||
|
||||
INSERT INTO tmp SELECT DISTINCT * FROM karma_limits;
|
||||
DROP TABLE karma_limits;
|
||||
ALTER TABLE tmp RENAME TO karma_limits;
|
||||
|
||||
CREATE INDEX karma_limits_lrj ON karma_limits (room,jid);
|
||||
|
||||
-- --------------------------------------------------------------------------- --
|
||||
-- Action list base
|
||||
--
|
||||
CREATE TABLE tmp (
|
||||
jid text,
|
||||
action text,
|
||||
type text,
|
||||
text text,
|
||||
command text,
|
||||
time int,
|
||||
level int default 9
|
||||
);
|
||||
|
||||
INSERT INTO tmp SELECT DISTINCT * FROM acl;
|
||||
DROP TABLE acl;
|
||||
ALTER TABLE tmp RENAME TO acl;
|
||||
|
||||
CREATE INDEX acl_jid ON acl (jid,action,type);
|
||||
|
||||
-- --------------------------------------------------------------------------- --
|
||||
-- Base for `GisMeteo` plugin
|
||||
--
|
||||
CREATE TABLE tmp (
|
||||
code text,
|
||||
city text,
|
||||
lcity text
|
||||
);
|
||||
|
||||
INSERT INTO tmp SELECT DISTINCT * FROM gis;
|
||||
DROP TABLE gis;
|
||||
ALTER TABLE tmp RENAME TO gis;
|
||||
|
||||
CREATE INDEX gis_clcc ON gis (code,lcity,city);
|
||||
|
||||
-- --------------------------------------------------------------------------- --
|
||||
-- DEF-Codes
|
||||
--
|
||||
CREATE TABLE tmp (
|
||||
phone text,
|
||||
region text,
|
||||
city text
|
||||
);
|
||||
|
||||
INSERT INTO tmp SELECT DISTINCT * FROM def_ru_stat;
|
||||
DROP TABLE def_ru_stat;
|
||||
ALTER TABLE tmp RENAME TO def_ru_stat;
|
||||
|
||||
CREATE INDEX def_ru_stat_ph ON def_ru_stat (phone,city);
|
||||
|
||||
CREATE TABLE tmp (
|
||||
phone text,
|
||||
region text,
|
||||
city text
|
||||
);
|
||||
|
||||
INSERT INTO tmp SELECT DISTINCT * FROM def_ua_stat;
|
||||
DROP TABLE def_ua_stat;
|
||||
ALTER TABLE tmp RENAME TO def_ua_stat;
|
||||
|
||||
CREATE INDEX def_ua_stat_ph ON def_ua_stat (phone,city);
|
||||
|
||||
CREATE TABLE tmp (
|
||||
provider text,
|
||||
region text,
|
||||
def integer,
|
||||
defbegin integer,
|
||||
defend integer,
|
||||
date text
|
||||
);
|
||||
|
||||
INSERT INTO tmp SELECT DISTINCT * FROM def_ru_mobile;
|
||||
DROP TABLE def_ru_mobile;
|
||||
ALTER TABLE tmp RENAME TO def_ru_mobile;
|
||||
|
||||
CREATE INDEX def_ru_mobile_ph ON def_ru_mobile (def,defbegin,defend);
|
||||
|
||||
-- --------------------------------------------------------------------------- --
|
||||
-- WZ Weather base
|
||||
--
|
||||
CREATE TABLE tmp (
|
||||
code text,
|
||||
city text,
|
||||
counry text
|
||||
);
|
||||
|
||||
INSERT INTO tmp SELECT DISTINCT * FROM wz;
|
||||
DROP TABLE wz;
|
||||
ALTER TABLE tmp RENAME TO wz;
|
||||
|
||||
CREATE INDEX wz_ccc ON wz (code,city,counry);
|
||||
|
||||
-- --------------------------------------------------------------------------- --
|
||||
-- Muc-filter lock base
|
||||
--
|
||||
CREATE TABLE tmp (
|
||||
room text,
|
||||
jid text
|
||||
);
|
||||
|
||||
INSERT INTO tmp SELECT DISTINCT * FROM muc_lock;
|
||||
DROP TABLE muc_lock;
|
||||
ALTER TABLE tmp RENAME TO muc_lock;
|
||||
|
||||
CREATE INDEX muc_lock_rj ON muc_lock (room,jid);
|
||||
|
||||
-- --------------------------------------------------------------------------- --
|
||||
-- Versions base
|
||||
--
|
||||
CREATE TABLE tmp (
|
||||
room text,
|
||||
jid text,
|
||||
client text,
|
||||
version text,
|
||||
os text,
|
||||
time integer
|
||||
);
|
||||
|
||||
INSERT INTO tmp SELECT DISTINCT * FROM versions;
|
||||
DROP TABLE versions;
|
||||
ALTER TABLE tmp RENAME TO versions;
|
||||
|
||||
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 tmp (
|
||||
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
|
||||
);
|
||||
INSERT INTO tmp SELECT DISTINCT * FROM issues;
|
||||
DROP TABLE issues;
|
||||
ALTER TABLE tmp RENAME TO issues;
|
||||
|
||||
CREATE INDEX issues_r ON issues (room,id);
|
||||
CREATE INDEX issues_d ON issues (room,date);
|
||||
|
||||
-- --------------------------------------------------------------------------- --
|
||||
-- Cron base
|
||||
--
|
||||
CREATE TABLE tmp (
|
||||
room text,
|
||||
jid text,
|
||||
nick text,
|
||||
time integer,
|
||||
repeat text,
|
||||
command text,
|
||||
level integer
|
||||
);
|
||||
|
||||
INSERT INTO tmp SELECT DISTINCT * FROM cron;
|
||||
DROP TABLE cron;
|
||||
ALTER TABLE tmp RENAME TO cron;
|
||||
|
||||
CREATE INDEX cron_r ON cron (room);
|
||||
CREATE INDEX cron_rt ON cron (room,time);
|
||||
CREATE INDEX cron_rtr ON cron (room,time,repeat);
|
||||
|
||||
-- --------------------------------------------------------------------------- --
|
||||
-- Conference config
|
||||
--
|
||||
CREATE TABLE tmp (
|
||||
room text,
|
||||
option text,
|
||||
value text
|
||||
);
|
||||
|
||||
INSERT INTO tmp SELECT DISTINCT * FROM config_conf;
|
||||
DROP TABLE config_conf;
|
||||
ALTER TABLE tmp RENAME TO config_conf;
|
||||
|
||||
CREATE INDEX config_conf_r ON config_conf (room);
|
||||
CREATE INDEX config_conf_ro ON config_conf (room,option);
|
||||
|
||||
-- --------------------------------------------------------------------------- --
|
||||
-- Aliases
|
||||
--
|
||||
CREATE TABLE tmp (
|
||||
room text,
|
||||
match text,
|
||||
cmd text
|
||||
);
|
||||
|
||||
INSERT INTO tmp SELECT DISTINCT * FROM alias;
|
||||
DROP TABLE alias;
|
||||
ALTER TABLE tmp RENAME TO alias;
|
||||
|
||||
CREATE INDEX alias_r ON alias (room);
|
||||
CREATE INDEX alias_rm ON alias (room,match);
|
||||
|
||||
-- --------------------------------------------------------------------------- --
|
||||
-- Comm ON/OFF
|
||||
--
|
||||
CREATE TABLE tmp (
|
||||
room text,
|
||||
cmd text
|
||||
);
|
||||
|
||||
INSERT INTO tmp SELECT DISTINCT * FROM commonoff;
|
||||
DROP TABLE commonoff;
|
||||
ALTER TABLE tmp RENAME TO commonoff;
|
||||
|
||||
CREATE INDEX commonoff_r ON commonoff (room);
|
||||
CREATE INDEX commonoff_rm ON commonoff (room,cmd);
|
||||
|
||||
-- --------------------------------------------------------------------------- --
|
||||
-- Feeds
|
||||
--
|
||||
CREATE TABLE tmp (
|
||||
url text,
|
||||
update text,
|
||||
type text,
|
||||
time integer,
|
||||
room text,
|
||||
hash text array[10]
|
||||
);
|
||||
|
||||
INSERT INTO tmp SELECT DISTINCT * FROM feed;
|
||||
DROP TABLE feed;
|
||||
ALTER TABLE tmp RENAME TO feed;
|
||||
|
||||
CREATE INDEX feed_r ON feed (room);
|
||||
CREATE INDEX feed_rt ON feed (room,time);
|
||||
|
||||
-- --------------------------------------------------------------------------- --
|
||||
-- Temporary ban
|
||||
--
|
||||
CREATE TABLE tmp (
|
||||
room text,
|
||||
jid text,
|
||||
time integer
|
||||
);
|
||||
|
||||
INSERT INTO tmp SELECT DISTINCT * FROM tmp_ban;
|
||||
DROP TABLE tmp_ban;
|
||||
ALTER TABLE tmp RENAME TO tmp_ban;
|
||||
|
||||
CREATE INDEX tmp_ban_r ON tmp_ban (room);
|
||||
CREATE INDEX tmp_ban_rt ON tmp_ban (room,time);
|
||||
|
||||
-- --------------------------------------------------------------------------- --
|
||||
-- THE END
|
||||
-- --------------------------------------------------------------------------- --
|
||||
477
scripts/sqlite3.schema
Normal file
477
scripts/sqlite3.schema
Normal file
@@ -0,0 +1,477 @@
|
||||
-- --------------------------------------------------------------------------- --
|
||||
-- --
|
||||
-- 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);
|
||||
|
||||
-- --------------------------------------------------------------------------- --
|
||||
-- Conference config
|
||||
--
|
||||
CREATE TABLE config_conf (
|
||||
room text,
|
||||
option text,
|
||||
value text
|
||||
);
|
||||
|
||||
CREATE INDEX config_conf_r ON config_conf (room);
|
||||
CREATE INDEX config_conf_ro ON config_conf (room,option);
|
||||
|
||||
-- --------------------------------------------------------------------------- --
|
||||
-- Owner config
|
||||
--
|
||||
CREATE TABLE config_owner (
|
||||
option text unique,
|
||||
value text
|
||||
);
|
||||
|
||||
CREATE INDEX config_owner_o ON config_owner (option);
|
||||
|
||||
-- --------------------------------------------------------------------------- --
|
||||
-- Top command
|
||||
--
|
||||
CREATE TABLE top (
|
||||
room text unique,
|
||||
count integer,
|
||||
time integer
|
||||
);
|
||||
|
||||
CREATE INDEX top_r ON top (room);
|
||||
CREATE INDEX top_rc ON top (room,count);
|
||||
|
||||
-- --------------------------------------------------------------------------- --
|
||||
-- Aliases
|
||||
--
|
||||
CREATE TABLE alias (
|
||||
room text,
|
||||
match text,
|
||||
cmd text
|
||||
);
|
||||
|
||||
CREATE INDEX alias_r ON alias (room);
|
||||
CREATE INDEX alias_rm ON alias (room,match);
|
||||
|
||||
-- --------------------------------------------------------------------------- --
|
||||
-- Blacklist for rooms
|
||||
--
|
||||
CREATE TABLE blacklist (
|
||||
room text unique
|
||||
);
|
||||
|
||||
-- --------------------------------------------------------------------------- --
|
||||
-- Comm ON/OFF
|
||||
--
|
||||
CREATE TABLE commonoff (
|
||||
room text,
|
||||
cmd text
|
||||
);
|
||||
|
||||
CREATE INDEX commonoff_r ON commonoff (room);
|
||||
CREATE INDEX commonoff_rm ON commonoff (room,cmd);
|
||||
|
||||
-- --------------------------------------------------------------------------- --
|
||||
-- Rooms list
|
||||
--
|
||||
CREATE TABLE conference (
|
||||
room text unique,
|
||||
passwd text
|
||||
);
|
||||
|
||||
-- --------------------------------------------------------------------------- --
|
||||
-- Feeds
|
||||
--
|
||||
CREATE TABLE feed (
|
||||
url text,
|
||||
'update' text,
|
||||
type text,
|
||||
time integer,
|
||||
room text,
|
||||
hash text,
|
||||
changed text
|
||||
);
|
||||
|
||||
CREATE INDEX feed_r ON feed (room);
|
||||
CREATE INDEX feed_rt ON feed (room,time);
|
||||
|
||||
-- --------------------------------------------------------------------------- --
|
||||
-- Hiden rooms
|
||||
--
|
||||
CREATE TABLE hiden_rooms (
|
||||
room text unique
|
||||
);
|
||||
|
||||
-- --------------------------------------------------------------------------- --
|
||||
-- Bot Ignore
|
||||
--
|
||||
CREATE TABLE bot_ignore (
|
||||
pattern text unique
|
||||
);
|
||||
|
||||
CREATE INDEX bot_ignore_p ON bot_ignore (pattern);
|
||||
|
||||
-- --------------------------------------------------------------------------- --
|
||||
-- Bot Owner
|
||||
--
|
||||
CREATE TABLE bot_owner (
|
||||
jid text unique
|
||||
);
|
||||
|
||||
CREATE INDEX bot_owner_j ON bot_owner (jid);
|
||||
|
||||
-- --------------------------------------------------------------------------- --
|
||||
-- Logs in rooms
|
||||
--
|
||||
CREATE TABLE log_rooms (
|
||||
room text unique
|
||||
);
|
||||
|
||||
CREATE INDEX log_rooms_r ON log_rooms (room);
|
||||
|
||||
-- --------------------------------------------------------------------------- --
|
||||
-- Spy for activity
|
||||
--
|
||||
CREATE TABLE spy (
|
||||
room text unique,
|
||||
time integer,
|
||||
participant integer,
|
||||
message integer,
|
||||
pattern text
|
||||
);
|
||||
|
||||
CREATE INDEX spy_r ON spy (room);
|
||||
CREATE INDEX spy_rt ON spy (room,time);
|
||||
|
||||
-- --------------------------------------------------------------------------- --
|
||||
-- Temporary ban
|
||||
--
|
||||
CREATE TABLE tmp_ban (
|
||||
room text,
|
||||
jid text,
|
||||
time integer
|
||||
);
|
||||
|
||||
CREATE INDEX tmp_ban_r ON tmp_ban (room);
|
||||
CREATE INDEX tmp_ban_rt ON tmp_ban (room,time);
|
||||
|
||||
-- --------------------------------------------------------------------------- --
|
||||
-- Say to owner
|
||||
--
|
||||
CREATE TABLE saytoowner (
|
||||
jid text unique,
|
||||
time integer
|
||||
);
|
||||
|
||||
-- --------------------------------------------------------------------------- --
|
||||
-- Ignore ban for global_ban
|
||||
--
|
||||
CREATE TABLE ignore_ban (
|
||||
room text unique
|
||||
);
|
||||
|
||||
-- --------------------------------------------------------------------------- --
|
||||
-- First join time
|
||||
--
|
||||
CREATE TABLE first_join (
|
||||
room text,
|
||||
jid text,
|
||||
time integer
|
||||
);
|
||||
|
||||
CREATE INDEX join_rj ON first_join (room,jid);
|
||||
|
||||
-- --------------------------------------------------------------------------- --
|
||||
-- URL Storage
|
||||
--
|
||||
CREATE TABLE url (
|
||||
room text,
|
||||
jid text,
|
||||
nick text,
|
||||
time integer,
|
||||
url text,
|
||||
title text);
|
||||
|
||||
CREATE INDEX url_r ON url (room);
|
||||
CREATE INDEX url_rj ON url (room,jid);
|
||||
CREATE INDEX url_rjn ON url (room,jid,nick);
|
||||
CREATE INDEX url_rt ON url (room,time);
|
||||
|
||||
-- --------------------------------------------------------------------------- --
|
||||
-- THE END
|
||||
-- --------------------------------------------------------------------------- --
|
||||
31
scripts/update
Normal file
31
scripts/update
Normal file
@@ -0,0 +1,31 @@
|
||||
#!/bin/sh
|
||||
|
||||
# --------------------------------------------------------------------------- #
|
||||
# #
|
||||
# Update iSida Jabber Bot from version 3.0 to 3.1 #
|
||||
# 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/>. #
|
||||
# #
|
||||
# --------------------------------------------------------------------------- #
|
||||
|
||||
#su postgres
|
||||
#createuser -P isidabot
|
||||
#createdb isidabot -E UTF8 -T template0
|
||||
#psql -U isidabot isidabot -f pgsql3.1.schema
|
||||
|
||||
|
||||
#python update_to3.py
|
||||
|
||||
echo Not available now! Wait!
|
||||
180
scripts/update2_xto3_0.py
Normal file
180
scripts/update2_xto3_0.py
Normal file
@@ -0,0 +1,180 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# --------------------------------------------------------------------------- #
|
||||
# #
|
||||
# Update iSida Jabber Bot from version 2.x to 3.x #
|
||||
# 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/>. #
|
||||
# #
|
||||
# --------------------------------------------------------------------------- #
|
||||
|
||||
import os, sys, sqlite3, psycopg2, re, time
|
||||
|
||||
os.chdir('..')
|
||||
|
||||
set_folder = u'settings/%s'
|
||||
|
||||
agestat = set_folder % 'agestat.db'
|
||||
jidbase = set_folder % 'jidbase.db'
|
||||
talkers = set_folder % 'talkers.db'
|
||||
wtfbase = set_folder % 'wtfbase2.db'
|
||||
answers = set_folder %'answers.db'
|
||||
saytobase = set_folder % 'sayto.db'
|
||||
distbase = set_folder % 'dist.db'
|
||||
distbase_user = set_folder % 'dist_user.db'
|
||||
karmabase = set_folder % 'karma.db'
|
||||
acl_base = set_folder %'acl.db'
|
||||
wzbase = set_folder % 'wz.db'
|
||||
gisbase = set_folder % 'gis.db'
|
||||
def_phone_base = set_folder % 'defcodes.db'
|
||||
muc_lock_base = set_folder % 'muclock.db'
|
||||
|
||||
configname = 'settings/config.py'
|
||||
|
||||
def convert_base(filename,from_base,to_base):
|
||||
global conn
|
||||
if os.path.isfile(filename):
|
||||
s_conn = sqlite3.connect(filename)
|
||||
s_cur = s_conn.cursor()
|
||||
tmp = s_cur.execute('select * from %s' % from_base).fetchall()
|
||||
print 'Import %s, Base %s->%s, %s records' % (filename, from_base, to_base, len(tmp))
|
||||
s_conn.close()
|
||||
if tmp:
|
||||
for t in tmp:
|
||||
req = 'insert into %s values(%s);' % (to_base,','.join(['%'+a for a in 's'*len(t)]))
|
||||
cur.execute(req,t)
|
||||
conn.commit()
|
||||
|
||||
def errorHandler(text):
|
||||
print text
|
||||
sys.exit()
|
||||
|
||||
print 'Updater for Isida Jabber Bot from 2.x to 3.x'
|
||||
print '(c) Disabler Production Lab.'
|
||||
|
||||
base_charset, base_type = 'utf8', 'pgsql'
|
||||
|
||||
if os.path.isfile(configname): execfile(configname)
|
||||
else: errorHandler('%s is missed.' % configname)
|
||||
|
||||
try: _,_,_,_,_ = base_name,base_user,base_host,base_pass,base_port
|
||||
except: errorHandler('Missed settings for SQL DB!')
|
||||
|
||||
if base_type == 'pgsql':
|
||||
import psycopg2
|
||||
import psycopg2.extensions
|
||||
conn = psycopg2.connect(database=base_name, user=base_user, host=base_host, password=base_pass, port=base_port)
|
||||
elif base_type == 'mysql':
|
||||
import MySQLdb
|
||||
conn = MySQLdb.connect(db=base_name, user=base_user, host=base_host, passwd=base_pass, port=int(base_port), charset=base_charset)
|
||||
else: errorHandler('Unknown database backend!')
|
||||
|
||||
print 'Base type: %s' % base_type
|
||||
|
||||
cur = conn.cursor()
|
||||
|
||||
al = [t.lower() for t in sys.argv]
|
||||
|
||||
if '/wtf_update' in al:
|
||||
print 'Update `wtf` base'
|
||||
cur.execute('select * from wtf;')
|
||||
w = cur.fetchall()
|
||||
cur.execute('drop table wtf;')
|
||||
cur.execute('CREATE TABLE wtf (\
|
||||
ind integer,\
|
||||
room text,\
|
||||
jid text,\
|
||||
nick text,\
|
||||
wtfword text,\
|
||||
wtftext text,\
|
||||
time integer,\
|
||||
lim integer);')
|
||||
for tmp in w:
|
||||
try: tm = time.mktime([[int(t) for t in tmp[6].replace('.',' ').replace(':',' ').split()][t1] for t1 in [2,1,0,3,4,5]]+[0,0,0])
|
||||
except: tm = 0
|
||||
r = tmp[:6]+(tm,)+tmp[7:]
|
||||
req = 'insert into wtf values(%s);' % (','.join(['%'+a for a in 's'*len(r)]))
|
||||
cur.execute(req,r)
|
||||
print 'Updated %s record(s)' % len(w)
|
||||
print 'Finished!'
|
||||
|
||||
elif '/gis_update' in al:
|
||||
print 'Update `gis` base'
|
||||
cur.execute('delete from gis;')
|
||||
from_base = to_base = 'gis'
|
||||
s_conn = sqlite3.connect(gisbase)
|
||||
s_cur = s_conn.cursor()
|
||||
tmp = s_cur.execute('select * from %s' % from_base).fetchall()
|
||||
print 'Import %s, Base %s->%s, %s records' % (gisbase, from_base, to_base, len(tmp))
|
||||
s_conn.close()
|
||||
|
||||
if tmp:
|
||||
for t in tmp:
|
||||
req = 'insert into gis values(%s);' % (','.join(['%'+a for a in 's'*len(t)]))
|
||||
cur.execute(req,t)
|
||||
print 'Updated %s record(s)' % len(tmp)
|
||||
else: 'Update failed! `gis` base not found or empty!'
|
||||
print 'Finished!'
|
||||
|
||||
elif '/h' in al or '/help' in al or '--help' in al:
|
||||
print '\
|
||||
Usage: python %s [/h|/wtf_update|/gis_update]\n\n\
|
||||
/h - this help\n\
|
||||
/wtf_update - update number format in `wtf` base for enable history of words definitions\n\
|
||||
' % al[0]
|
||||
elif len(al) > 1: print 'Use: python %s /h for short help' % al[0]
|
||||
else:
|
||||
bases_arr = [[jidbase,'jid','jid'],[talkers,'talkers','talkers'],
|
||||
[answers,'answer','answer'],[saytobase,'st','sayto'],[distbase,'dist','dist'],[distbase_user,'dist','dist_user'],
|
||||
[karmabase,'karma','karma'],[karmabase,'commiters','karma_commiters'],[karmabase,'limits','karma_limits'],
|
||||
[acl_base,'acl','acl'],[wzbase,'wz','wz'],[gisbase,'gis','gis'],[def_phone_base,'ru_stat','def_ru_stat'],
|
||||
[def_phone_base,'ua_stat','def_ua_stat'],[def_phone_base,'ru_mobile','def_ru_mobile'],[muc_lock_base,'muc','muc_lock']]
|
||||
|
||||
from_base = to_base = 'age'
|
||||
if os.path.isfile(agestat):
|
||||
s_conn = sqlite3.connect(agestat)
|
||||
s_cur = s_conn.cursor()
|
||||
tmp = s_cur.execute('select * from %s' % from_base).fetchall()
|
||||
print 'Import %s, Base %s->%s, %s records' % (agestat, from_base, to_base, len(tmp))
|
||||
s_conn.close()
|
||||
if tmp:
|
||||
for t in tmp:
|
||||
req = 'insert into %s values(%s);' % (to_base,','.join(['%'+a for a in 's'*9]))
|
||||
cur.execute(req,list(t)+[t[1].lower()])
|
||||
conn.commit()
|
||||
|
||||
from_base = to_base = 'wtf'
|
||||
if os.path.isfile(wtfbase):
|
||||
s_conn = sqlite3.connect(wtfbase)
|
||||
s_cur = s_conn.cursor()
|
||||
tmp = s_cur.execute('select * from %s' % from_base).fetchall()
|
||||
print 'Import %s, Base %s->%s, %s records' % (wtfbase, from_base, to_base, len(tmp))
|
||||
s_conn.close()
|
||||
if tmp:
|
||||
for t in tmp:
|
||||
try: tm = time.mktime([[int(t2) for t2 in t[6].replace('.',' ').replace(':',' ').split()][t1] for t1 in [2,1,0,3,4,5]]+[0,0,0])
|
||||
except: tm = 0
|
||||
r = t[:6]+(tm,)+t[7:]
|
||||
req = 'insert into %s values(%s);' % (to_base,','.join(['%'+a for a in 's'*len(r)]))
|
||||
cur.execute(req,r)
|
||||
conn.commit()
|
||||
|
||||
for t in bases_arr: convert_base(t[0],t[1],t[2])
|
||||
print 'Finished!'
|
||||
|
||||
cur.close()
|
||||
conn.commit()
|
||||
conn.close()
|
||||
195
scripts/update3_0to3_1.py
Normal file
195
scripts/update3_0to3_1.py
Normal file
@@ -0,0 +1,195 @@
|
||||
import os, sys
|
||||
|
||||
global clean, rename, cur, conn
|
||||
|
||||
os.chdir('..')
|
||||
settings_folder = 'settings/%s'
|
||||
conference_config_path = settings_folder % 'conference.config'
|
||||
owner_config_path = settings_folder % 'owner.config'
|
||||
configname = settings_folder % 'config.py'
|
||||
topbase_path = settings_folder % 'topbase.db'
|
||||
aliases_path = settings_folder % 'aliases'
|
||||
blacklist_path = settings_folder % 'blacklist.db'
|
||||
conoff_path = settings_folder % 'commonoff'
|
||||
conf_path = settings_folder % 'conf'
|
||||
feed_path = settings_folder % 'feed'
|
||||
hidenrooms_path = settings_folder % 'hidenroom.db'
|
||||
botignore_path = settings_folder % 'ignore'
|
||||
botowner_path = settings_folder % 'owner'
|
||||
locale_path = settings_folder % 'locale'
|
||||
logroom_path = settings_folder % 'logroom.db'
|
||||
spy_path = settings_folder % 'spy.db'
|
||||
tban_path = settings_folder % 'temporary.ban'
|
||||
saytoowner_path = settings_folder % 'saytoowner.db'
|
||||
ignoreban_path = settings_folder % 'ignoreban.db'
|
||||
|
||||
ar = {'--help':'This page',
|
||||
'--all':'Import all files',
|
||||
'--owner-config':'Import owners config',
|
||||
'--conference-config':'Import conference config',
|
||||
'--top':'Import statictic for `top` command',
|
||||
'--alias':'Import aliases',
|
||||
'--blacklist':'Import blacklist of rooms',
|
||||
'--comm':'Import list of disabled commands',
|
||||
'--rooms':'Import list of bot\'s rooms',
|
||||
'--rss':'Import RSS/ATOM feeds',
|
||||
'--hiden-rooms':'Import list of hiden rooms',
|
||||
'--bot-ignore':'Import patterns for bot ignore',
|
||||
'--locale':'Import current locale name',
|
||||
'--logs':'Import rooms with enabled logs',
|
||||
'--bot-owner':'Import list of bot owners',
|
||||
'--spy':'Import spy for room activity',
|
||||
'--tban':'Import list of temporary bans',
|
||||
'--say-to-owner':'Import base for `msgtoadmin` command',
|
||||
'--ignore-ban':'Import list of rooms with ignore global ban',
|
||||
'--clean':'Remove source file(s) after import',
|
||||
'--rename':'Rename source file(s) after import'
|
||||
}
|
||||
|
||||
|
||||
def readfile(filename):
|
||||
fp = file(filename)
|
||||
data = fp.read()
|
||||
fp.close()
|
||||
return data
|
||||
|
||||
def errorHandler(text):
|
||||
print text
|
||||
sys.exit()
|
||||
|
||||
def mv(file):
|
||||
newfile = file.split('/')
|
||||
newfile = '/'.join(newfile[:-1]+['_%s' % newfile[-1]])
|
||||
os.system('mv %s %s' % (file,newfile))
|
||||
|
||||
def remove(file):
|
||||
try: os.remove(file)
|
||||
except: pass
|
||||
|
||||
def import_file(filename,basename,eval_for,eval_string):
|
||||
try:
|
||||
print 'Import: %s' % filename
|
||||
c = eval(readfile(filename))
|
||||
cnt = 0
|
||||
for t in eval(eval_for):
|
||||
r = eval(eval_string)
|
||||
req = 'insert into %s values(%s);' % (basename,','.join(['%'+a for a in 's'*len(r)]))
|
||||
cnt += 1
|
||||
cur.execute(req,r)
|
||||
print '\t%s record(s)' % cnt
|
||||
conn.commit()
|
||||
if rename: mv(filename)
|
||||
elif clean: remove(filename)
|
||||
except Exception, SM: print 'Error [%s] while proceed file %s' % (str(SM),filename)
|
||||
|
||||
print 'Updater for Isida Jabber Bot from 3.0 to 3.1'
|
||||
print '(c) Disabler Production Lab.'
|
||||
|
||||
base_charset, base_type = 'utf8', 'pgsql'
|
||||
|
||||
if os.path.isfile(configname): execfile(configname)
|
||||
else: errorHandler('%s is missed.' % configname)
|
||||
|
||||
try: _,_,_,_,_ = base_name,base_user,base_host,base_pass,base_port
|
||||
except: errorHandler('Missed settings for SQL DB!')
|
||||
|
||||
arg = sys.argv[1:]
|
||||
|
||||
if arg:
|
||||
clean = '--clean' in arg
|
||||
rename = '--rename' in arg
|
||||
all = '--all' in arg
|
||||
if '--help' in arg:
|
||||
ark = ar.keys()
|
||||
ark.sort()
|
||||
print 'Usage:\n%s' % '\n'.join(['%-32s%s' % (t,ar[t]) for t in ark])
|
||||
else:
|
||||
for t in arg:
|
||||
if t not in ar.keys():
|
||||
print 'Unknown option: %s\nUse `--help` option' % t
|
||||
os._exit(0)
|
||||
if base_type == 'pgsql':
|
||||
import psycopg2
|
||||
conn = psycopg2.connect(database=base_name, user=base_user, host=base_host, password=base_pass, port=base_port)
|
||||
elif base_type == 'mysql':
|
||||
import MySQLdb
|
||||
conn = MySQLdb.connect(db=base_name, user=base_user, host=base_host, passwd=base_pass, port=int(base_port), charset=base_charset)
|
||||
else: errorHandler('Unknown database backend!')
|
||||
|
||||
print 'Base type: %s' % base_type
|
||||
cur = conn.cursor()
|
||||
|
||||
# --------- Conference config --------- #
|
||||
if '--conference-config' in arg or all:
|
||||
try:
|
||||
print 'Import: %s' % conference_config_path
|
||||
c = eval(readfile(conference_config_path))
|
||||
to_base,cnt = 'config_conf',0
|
||||
for t in c.keys():
|
||||
for tmp in c[t].keys():
|
||||
r = (t,tmp,unicode(c[t][tmp]))
|
||||
req = 'insert into %s values(%s);' % (to_base,','.join(['%'+a for a in 's'*len(r)]))
|
||||
cnt += 1
|
||||
cur.execute(req,r)
|
||||
print '\t%s record(s)' % cnt
|
||||
conn.commit()
|
||||
if rename: mv(conference_config_path)
|
||||
elif clean: remove(conference_config_path)
|
||||
except Exception, SM: print 'Error [%s] while proceed file %s' % (str(SM),conference_config_path)
|
||||
|
||||
# --------- Owner config --------- #
|
||||
if '--owner-config' in arg or all: import_file(owner_config_path,'config_owner','c.keys()','(t,unicode(c[t]))')
|
||||
|
||||
# --------- Top command --------- #
|
||||
if '--top' in arg or all: import_file(topbase_path,'top','c','t')
|
||||
|
||||
# --------- Aliases --------- #
|
||||
if '--alias' in arg or all: import_file(aliases_path,'alias','c','t')
|
||||
|
||||
# --------- Blacklist of rooms --------- #
|
||||
if '--blacklist' in arg or all: import_file(blacklist_path,'blacklist','c','(t,)')
|
||||
|
||||
# --------- Comm ON/OFF --------- #
|
||||
if '--comm' in arg or all: import_file(conoff_path,'commonoff','c','t')
|
||||
|
||||
# --------- Conferences list --------- #
|
||||
if '--rooms' in arg or all: import_file(conf_path,'conference','c',"list(t.split('\\n',1)+[''])[:2]")
|
||||
|
||||
# --------- Feeds --------- #
|
||||
if '--rss' in arg or all: import_file(feed_path,'feed','c','t')
|
||||
|
||||
# --------- Hiden rooms --------- #
|
||||
if '--hiden-rooms' in arg or all: import_file(hidenrooms_path,'hiden_rooms','c','(t,)')
|
||||
|
||||
# --------- Bot Ignore --------- #
|
||||
if '--bot-ignore' in arg or all: import_file(botignore_path,'bot_ignore','c',"[('%%%s%%' % t,),(t,)]['@' in t]")
|
||||
|
||||
# --------- Bot Locale --------- #
|
||||
if '--locale' in arg or all: import_file(locale_path,'config_owner','range(0,1)',"('bot_locale',c)")
|
||||
|
||||
# --------- Logs in rooms --------- #
|
||||
if '--logs' in arg or all: import_file(logroom_path,'log_rooms','c','(t,)')
|
||||
|
||||
# --------- Bot owners --------- #
|
||||
if '--bot-owner' in arg or all: import_file(botowner_path,'bot_owner','c','(t,)')
|
||||
|
||||
# --------- Spy for rooms activity --------- #
|
||||
if '--spy' in arg or all: import_file(spy_path,'spy','c','t')
|
||||
|
||||
# --------- Temporary ban --------- #
|
||||
if '--tban' in arg or all: import_file(tban_path,'tmp_ban','c','t')
|
||||
|
||||
# --------- Say to owner --------- #
|
||||
if '--say-to-owner' in arg or all: import_file(saytoowner_path,'saytoowner','c.keys()','(t,c[t])')
|
||||
|
||||
# --------- Ignore ban --------- #
|
||||
if '--ignore-ban' in arg or all: import_file(ignoreban_path,'ignore_ban','c','(t,)')
|
||||
|
||||
print 'Finished!'
|
||||
cur.close()
|
||||
conn.commit()
|
||||
conn.close()
|
||||
|
||||
else: print 'use `--help` option'
|
||||
|
||||
# The end is near!
|
||||
Reference in New Issue
Block a user