Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/alkorgun/blacksmith-2.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlKorgun@gmail.com <AlKorgun@gmail.com@94c44753-77e5-68b8-8764-2ca2b8acb85e>2011-11-16 07:41:43 +0400
committerAlKorgun@gmail.com <AlKorgun@gmail.com@94c44753-77e5-68b8-8764-2ca2b8acb85e>2011-11-16 07:41:43 +0400
commit11c01eb2311e9e9fafdc18629219802c0e97fa98 (patch)
tree60376f455fbfccdec29bb656f51209b501ca3a6a
parent7f9535384ffe39a8c18386ef0e9acdede8c3968c (diff)
some modifications; help files added
-rw-r--r--BlackSmith.py4
-rw-r--r--expansions/allweb/code.py11
-rw-r--r--expansions/allweb/insc.py6
-rw-r--r--expansions/info/chatslist.en2
-rw-r--r--expansions/info/chatslist.ru2
-rw-r--r--expansions/info/code.py10
-rw-r--r--expansions/info/inmuc.en2
-rw-r--r--expansions/info/inmuc.ru2
-rw-r--r--expansions/info/insc.py2
-rw-r--r--expansions/info/online.en2
-rw-r--r--expansions/info/online.ru2
-rw-r--r--expansions/info/search.en4
-rw-r--r--expansions/info/search.ru4
-rw-r--r--expansions/info/visitors.en10
-rw-r--r--expansions/info/visitors.ru10
-rw-r--r--expansions/user_stats/code.py132
-rw-r--r--librarys.zipbin79758 -> 79763 bytes
17 files changed, 137 insertions, 68 deletions
diff --git a/BlackSmith.py b/BlackSmith.py
index 0193893..4126e49 100644
--- a/BlackSmith.py
+++ b/BlackSmith.py
@@ -250,7 +250,7 @@ GenConFile = static % ("config.ini")
ConDispFile = static % ("clients.ini")
ChatsFile = dynamic % ("chats.db")
-(BsMark, BsVer, BsRev) = (2, 18, 0)
+(BsMark, BsVer, BsRev) = (2, 19, 0)
if os.access(SvnCache, os.R_OK):
BsRev = open(SvnCache).readlines()[3].strip()
@@ -660,6 +660,8 @@ class sConf:
return caps_add(stanza)
def join(self):
+ for sUser in self.get_users():
+ sUser.ishere = None
stanza = self.composePres()
self.sdate = time.time()
query = stanza.setTag("x", namespace = xmpp.NS_MUC)
diff --git a/expansions/allweb/code.py b/expansions/allweb/code.py
index cd76466..da9a6be 100644
--- a/expansions/allweb/code.py
+++ b/expansions/allweb/code.py
@@ -1,8 +1,8 @@
# coding: utf-8
# BlackSmith mark.2
-exp_name = "allweb" # /code.py v.x6
-# Id: 25~6a
+exp_name = "allweb" # /code.py v.x7
+# Id: 25~7a
# Code © (2011) by WitcherGeralt [WitcherGeralt@rocketmail.com]
expansion_register(exp_name)
@@ -11,7 +11,7 @@ import htmlentitydefs, json
UserAgent = ("User-Agent", "%s/%s" % (ProdName[:10], CapsVer))
-UserAgent_Moz = (UserAgent[0], "Mozilla/5.0 (X11; U; Linux i686; cs-CZ; rv:1.7.9) Gecko/20050929")
+UserAgent_Moz = (UserAgent[0], "Mozilla/5.0 (X11; U; Linux i686; {0}; rv:1.7.12) Gecko/20050929".format(UAL_desc.get(DefLANG, "en-US")))
edefs = dict()
@@ -361,7 +361,7 @@ def command_python(ltype, source, body, disp):
answer = AllwebAnsBase[0]
else:
data = data.decode("koi8-r")
- data = get_text(data, '<h2 class="news">', "</div>")
+ data = get_text(data, "<h2 class=\"news\">", "</div>")
if data:
data = decodeHTML(data)
ls = []
@@ -421,8 +421,9 @@ expansions[exp_name].ls.extend([
"UserAgent",
"UserAgent_Moz",
"edefs",
- "XML_ls",
+ "UAL_desc",
"REP_desc",
+ "XML_ls",
"compile_st",
"compile_ehtmls",
"gCache"
diff --git a/expansions/allweb/insc.py b/expansions/allweb/insc.py
index 9d01934..bd71ebc 100644
--- a/expansions/allweb/insc.py
+++ b/expansions/allweb/insc.py
@@ -1,5 +1,11 @@
# coding: utf-8
+UAL_desc = {
+ "RU": "ru-RU",
+ "UA": "ua-UA",
+ "EN": "en-US"
+ }
+
if DefLANG in ("RU", "UA"):
AllwebAnsBase = tuple([line.decode("utf-8") for line in (
"Не могу получить доступ к странице.", # 0
diff --git a/expansions/info/chatslist.en b/expansions/info/chatslist.en
new file mode 100644
index 0000000..34ee2d1
--- /dev/null
+++ b/expansions/info/chatslist.en
@@ -0,0 +1,2 @@
+bot shows a list of it's conferences
+chatslist \ No newline at end of file
diff --git a/expansions/info/chatslist.ru b/expansions/info/chatslist.ru
new file mode 100644
index 0000000..23c778b
--- /dev/null
+++ b/expansions/info/chatslist.ru
@@ -0,0 +1,2 @@
+бот покажет список конференций, которые он обслуживает
+чатлист \ No newline at end of file
diff --git a/expansions/info/code.py b/expansions/info/code.py
index a5089e2..b4e84df 100644
--- a/expansions/info/code.py
+++ b/expansions/info/code.py
@@ -1,8 +1,8 @@
# coding: utf-8
# BlackSmith mark.2
-exp_name = "info" # /code.py v.x3
-# Id: 11~2a
+exp_name = "info" # /code.py v.x4
+# Id: 11~3a
# Code © (2010-2011) by WitcherGeralt [WitcherGeralt@rocketmail.com]
expansion_register(exp_name)
@@ -137,7 +137,7 @@ def command_visitors(ltype, source, body, disp):
else:
Answer(AnsBase[0], ltype, source, disp)
-def command_where(ltype, source, body, disp):
+def command_search(ltype, source, body, disp):
if body:
list, Numb, acc = str(), itypes.Number(), enough_access(source[1], source[2], 7)
for conf in sorted(Chats.keys()):
@@ -161,11 +161,11 @@ def command_where(ltype, source, body, disp):
if locals().has_key(Types[12]):
Answer(answer, ltype, source, disp)
-expansions[exp_name].funcs_add([command_online, command_inchat, command_conflist, command_visitors, command_where])
+expansions[exp_name].funcs_add([command_online, command_inchat, command_conflist, command_visitors, command_search])
expansions[exp_name].ls.extend(["InfoAnsBase"])
command_handler(command_online, {"RU": "онлайн", "EN": "online"}, 7, exp_name)
command_handler(command_inchat, {"RU": "инмук", "EN": "inmuc"}, 2, exp_name)
command_handler(command_conflist, {"RU": "чатлист", "EN": "chatslist"}, 5, exp_name)
command_handler(command_visitors, {"RU": "ктобыл", "EN": "visitors"}, 4, exp_name)
-command_handler(command_where, {"RU": "где", "EN": "where"}, 2, exp_name)
+command_handler(command_search, {"RU": "где", "EN": "search"}, 2, exp_name)
diff --git a/expansions/info/inmuc.en b/expansions/info/inmuc.en
new file mode 100644
index 0000000..b812c14
--- /dev/null
+++ b/expansions/info/inmuc.en
@@ -0,0 +1,2 @@
+bot shows a list of users which presences in the conference
+inmuc \ No newline at end of file
diff --git a/expansions/info/inmuc.ru b/expansions/info/inmuc.ru
new file mode 100644
index 0000000..bf479fd
--- /dev/null
+++ b/expansions/info/inmuc.ru
@@ -0,0 +1,2 @@
+бот покажет список пользователей в конференции
+инмук \ No newline at end of file
diff --git a/expansions/info/insc.py b/expansions/info/insc.py
index ce08cf7..03010f6 100644
--- a/expansions/info/insc.py
+++ b/expansions/info/insc.py
@@ -26,5 +26,5 @@ else:
"[#][Client][Connected][isActive]", # 7
"List of users:", # 8
"Total %s similar users:%s", # 9
- "Don't know." # 10
+ "No result." # 10
) \ No newline at end of file
diff --git a/expansions/info/online.en b/expansions/info/online.en
new file mode 100644
index 0000000..3cdfb87
--- /dev/null
+++ b/expansions/info/online.en
@@ -0,0 +1,2 @@
+bot shows info about connection of it's jids
+online \ No newline at end of file
diff --git a/expansions/info/online.ru b/expansions/info/online.ru
new file mode 100644
index 0000000..c584c90
--- /dev/null
+++ b/expansions/info/online.ru
@@ -0,0 +1,2 @@
+бот покажет информацию о подключении своих jid'ов
+онлайн \ No newline at end of file
diff --git a/expansions/info/search.en b/expansions/info/search.en
new file mode 100644
index 0000000..2ff9647
--- /dev/null
+++ b/expansions/info/search.en
@@ -0,0 +1,4 @@
+bot searchs users in it's lists
+search [search key]
+*/search Masha
+bot would search Masha and tell you where is she \ No newline at end of file
diff --git a/expansions/info/search.ru b/expansions/info/search.ru
new file mode 100644
index 0000000..e64e2d4
--- /dev/null
+++ b/expansions/info/search.ru
@@ -0,0 +1,4 @@
+бот ищет пользователя в своих списках
+где [ключ поиска]
+*/где Маша
+бот поищет Машу в списках, и покажет в какой конференции она сидит \ No newline at end of file
diff --git a/expansions/info/visitors.en b/expansions/info/visitors.en
new file mode 100644
index 0000000..3df487c
--- /dev/null
+++ b/expansions/info/visitors.en
@@ -0,0 +1,10 @@
+bot shows the visitors of the conference
+visitors (today/dates/list)
+*/visitors
+bot would show all of the visitors
+*/visitors today
+bot would show all of the visitors, who joined today
+*/visitors dates
+bot would show all of the visitors, with dates of join
+*/visitors list
+bot would show shortlist of the visitors \ No newline at end of file
diff --git a/expansions/info/visitors.ru b/expansions/info/visitors.ru
new file mode 100644
index 0000000..1e81a44
--- /dev/null
+++ b/expansions/info/visitors.ru
@@ -0,0 +1,10 @@
+бот показывает список посетителей
+ктобыл (сегодня/даты/лист)
+*/ктобыл
+бот показыжет всех, кого он видел в текущей конференции
+*/ктобыл сегодня
+бот показыжет всех, кого он видел в текущей конференции сегодня
+*/ктобыл даты
+бот показыжет всех, кого он видел в текущей конференции с датами входа
+*/ктобыл лист
+бот показыжет ники всех, кого видел коротким списком \ No newline at end of file
diff --git a/expansions/user_stats/code.py b/expansions/user_stats/code.py
index 48c20d3..1bcc873 100644
--- a/expansions/user_stats/code.py
+++ b/expansions/user_stats/code.py
@@ -1,8 +1,8 @@
# coding: utf-8
# BlackSmith mark.2
-exp_name = "user_stats" # /code.py v.x3
-# Id: 17~2a
+exp_name = "user_stats" # /code.py v.x4
+# Id: 17~3a
# Code © (2010-2011) by WitcherGeralt [WitcherGeralt@rocketmail.com]
expansion_register(exp_name)
@@ -21,12 +21,12 @@ def command_user_stats(ltype, source, body, disp):
with UstatDesc[source[1]]:
with database(filename) as db:
db("select * from stat where jid=?", (body,))
- x = db.fetchone()
- if x:
- answer = UstatAnsBase[0] % (x[3], x[2], x[1])
- if x[3] >= 2 and x[4]:
- answer += UstatAnsBase[1] % (x[4], x[5])
- answer += UstatAnsBase[2] % (", ".join(sorted(x[6].split("-/-"))))
+ db_desc = db.fetchone()
+ if db_desc:
+ answer = UstatAnsBase[0] % (db_desc[3], db_desc[2], db_desc[1])
+ if db_desc[3] >= 2 and db_desc[4]:
+ answer += UstatAnsBase[1] % (db_desc[4], db_desc[5])
+ answer += UstatAnsBase[2] % (", ".join(sorted(db_desc[6].split("-/-"))))
else:
answer = UstatAnsBase[3]
else:
@@ -49,54 +49,71 @@ def command_here(ltype, source, nick, disp):
answer = AnsBase[0]
Answer(answer, ltype, source, disp)
-def calc_user_stat(stanza, disp):
- (source, conf, stype, nick) = sAttrs(stanza)
- if stype != Types[7] and nick != get_self_nick(conf):
- if not Chats[conf].isHere(nick):
- if stype == Types[4] and sCodes[1] == stanza.getStatusCode():
- nick = stanza.getNick()
- instance = get_source(conf, nick)
- if instance:
- nick = UnicodeType(nick).strip()
- filename = cefile(chat_file(conf, UstatFile))
- with UstatDesc[conf]:
- with database(filename) as db:
- db("select * from stat where jid=?", (instance,))
- db_desc = db.fetchone()
- if db_desc and nick not in db_desc[6].split("-/-"):
- db("update stat set nicks=? where jid=?", ("%s-/-%s" % (db_desc[6], nick), instance))
- db.commit()
- else:
- sUser = Chats[conf].get_user(nick)
- if getattr(sUser, "source", 0):
- filename = cefile(chat_file(conf, UstatFile))
- with UstatDesc[conf]:
- with database(filename) as db:
- db("select * from stat where jid=?", (sUser.source,))
- db_desc = db.fetchone()
- if db_desc:
- if stype == Types[4]:
- scode = stanza.getStatusCode()
- if scode == sCodes[0]:
- status = "banned:(%s)" % UnicodeType(stanza.getReason())
- elif scode == sCodes[2]:
- status = "kicked:(%s)" % UnicodeType(stanza.getReason())
- else:
- status = UnicodeType(stanza.getStatus())
- db("update stat set seen=?, leave=? where jid=?", (strTime(local = False), status, sUser.source))
- elif stype in (Types[3], None):
- if (time.time() - sUser.date[0]) <= 0.8:
- db("update stat set joined=?, joins=? where jid=?", (sUser.date[2], (db_desc[3] + 1), sUser.source))
- nick = nick.strip()
- if nick not in db_desc[6].split("-/-"):
- db("update stat set nicks=? where jid=?", ("%s-/-%s" % (db_desc[6], nick), sUser.source))
- arole = "%s/%s" % (sUser.role)
- if db_desc[1] != arole:
- db("update stat set arole=? where jid=?", (arole, sUser.source))
- else:
- db("insert into stat values (?,?,?,?,?,?,?)", (sUser.source, "%s/%s" % (sUser.role), sUser.date[2], 1, "", "", nick))
+def calc_stat_04eh(conf, nick, instance, role, stanza, disp):
+ if instance and nick != get_self_nick(conf):
+ date, filename = strTime(local = False), cefile(chat_file(conf, UstatFile))
+ with UstatDesc[conf]:
+ with database(filename) as db:
+ db("select * from stat where jid=?", (instance,))
+ db_desc = db.fetchone()
+ if db_desc:
+ db("update stat set joined=?, joins=? where jid=?", (date, (db_desc[3] + 1), instance))
+ if nick not in db_desc[6].split("-/-"):
+ db("update stat set nicks=? where jid=?", ("%s-/-%s" % (db_desc[6], nick), instance))
+ arole = "%s/%s" % (role)
+ if db_desc[1] != arole:
+ db("update stat set arole=? where jid=?", (arole, instance))
+ db.commit()
+ else:
+ db("insert into stat values (?,?,?,?,?,?,?)", (instance, "%s/%s" % (role), date, 1, "", "", nick))
+ db.commit()
+
+def calc_stat_05eh(conf, nick, sbody, scode, disp):
+ if nick != get_self_nick(conf):
+ source_ = get_source(conf, nick)
+ if source_:
+ sbody = UnicodeType(sbody)
+ if scode == sCodes[0]:
+ sbody = "banned:(%s)" % (sbody)
+ elif scode == sCodes[2]:
+ sbody = "kicked:(%s)" % (sbody)
+ date, filename = strTime(local = False), cefile(chat_file(conf, UstatFile))
+ with UstatDesc[conf]:
+ with database(filename) as db:
+ db("select * from stat where jid=?", (source_,))
+ db_desc = db.fetchone()
+ if db_desc:
+ db("update stat set seen=?, leave=? where jid=?", (date, sbody, source_))
db.commit()
+def calc_stat_06eh(conf, old_nick, nick, disp):
+ if nick != get_self_nick(conf):
+ source_ = get_source(conf, nick)
+ if source_:
+ filename = cefile(chat_file(conf, UstatFile))
+ with UstatDesc[conf]:
+ with database(filename) as db:
+ db("select * from stat where jid=?", (source_,))
+ db_desc = db.fetchone()
+ if db_desc and nick not in db_desc[6].split("-/-"):
+ db("update stat set nicks=? where jid=?", ("%s-/-%s" % (db_desc[6], nick), source_))
+ db.commit()
+
+def calc_stat_07eh(conf, nick, role, disp):
+ if nick != get_self_nick(conf):
+ source_ = get_source(conf, nick)
+ if source_:
+ filename = cefile(chat_file(conf, UstatFile))
+ with UstatDesc[conf]:
+ with database(filename) as db:
+ db("select * from stat where jid=?", (source_,))
+ db_desc = db.fetchone()
+ if db_desc:
+ arole = "%s/%s" % (role)
+ if db_desc[1] != arole:
+ db("update stat set arole=? where jid=?", (arole, source_))
+ db.commit()
+
def init_stat_base(conf):
filename = cefile(chat_file(conf, UstatFile))
if not os.path.isfile(filename):
@@ -108,7 +125,7 @@ def init_stat_base(conf):
def edit_stat_desc(conf):
del UstatDesc[conf]
-expansions[exp_name].funcs_add([command_user_stats, command_here, calc_user_stat, init_stat_base, edit_stat_desc])
+expansions[exp_name].funcs_add([command_user_stats, command_here, calc_stat_04eh, calc_stat_05eh, calc_stat_06eh, calc_stat_07eh, init_stat_base, edit_stat_desc])
expansions[exp_name].ls.extend(["UstatAnsBase", "UstatFile", "UstatDesc"])
command_handler(command_user_stats, {"RU": "юзерстат", "EN": "userstat"}, 2, exp_name)
@@ -116,4 +133,7 @@ command_handler(command_here, {"RU": "пребывание", "EN": "here"}, 1, e
handler_register(init_stat_base, "01si", exp_name)
handler_register(edit_stat_desc, "04si", exp_name)
-handler_register(calc_user_stat, "02eh", exp_name)
+handler_register(calc_stat_04eh, "04eh", exp_name)
+handler_register(calc_stat_05eh, "05eh", exp_name)
+handler_register(calc_stat_06eh, "06eh", exp_name)
+handler_register(calc_stat_07eh, "07eh", exp_name)
diff --git a/librarys.zip b/librarys.zip
index 611de22..056e7c7 100644
--- a/librarys.zip
+++ b/librarys.zip
Binary files differ