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:
authorAl Korgun <alkorgun@gmail.com>2012-11-22 08:32:08 +0400
committerAl Korgun <alkorgun@gmail.com>2012-11-22 08:32:08 +0400
commite72c9cd1854b8e6a48aa54eb945494b55f6e99b6 (patch)
tree9a19af77d0e7f8176bd9748dfcc93a2d477305ec
parenta3065ac48b232c846940ecb0bc51b7f85862ea63 (diff)
command "command" modified and renamed to "tumbler"; fixed IMDb; added expansion "search" (command "find")
-rw-r--r--BlackSmith.py2
-rw-r--r--expansions/allweb/code.py51
-rw-r--r--expansions/allweb/imdb.en4
-rw-r--r--expansions/allweb/insc.py2
-rw-r--r--expansions/cmd_control/taboo.en2
-rw-r--r--expansions/cmd_control/taboo.ru2
-rw-r--r--expansions/exp_control/code.py29
-rw-r--r--expansions/exp_control/command.en6
-rw-r--r--expansions/exp_control/command.name4
-rw-r--r--expansions/exp_control/command.ru6
-rw-r--r--expansions/exp_control/insc.py8
-rw-r--r--expansions/exp_control/tumbler.en10
-rw-r--r--expansions/exp_control/tumbler.name4
-rw-r--r--expansions/exp_control/tumbler.ru10
-rw-r--r--expansions/get_iq/code.py23
-rw-r--r--expansions/sheriff/code.py4
16 files changed, 85 insertions, 82 deletions
diff --git a/BlackSmith.py b/BlackSmith.py
index 0752c06..5355299 100644
--- a/BlackSmith.py
+++ b/BlackSmith.py
@@ -1116,7 +1116,7 @@ class Web:
if isNumber(size):
size = int(size)
else:
- raise SelfExc("no info about file size")
+ raise SelfExc("no info about file's size")
if not filename:
if info.has_key("Content-Disposition"):
disp = info.get("Content-Disposition")
diff --git a/expansions/allweb/code.py b/expansions/allweb/code.py
index 204a1a3..ee8b3ed 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.x18
-# Id: 25~18b
+exp_name = "allweb" # /code.py v.x20
+# Id: 25~20b
# Code © (2011-2012) by WitcherGeralt [alkorgun@gmail.com]
expansion_register(exp_name)
@@ -90,6 +90,7 @@ class expansion_temp(expansion):
except:
answer = self.AnsBase[0]
else:
+ data = data.decode("utf-8")
comp = compile__("<li>((?:.|\s)+?)</li>", 16)
list = comp.findall(data)
if list:
@@ -386,6 +387,7 @@ class expansion_temp(expansion):
except:
answer = self.AnsBase[0]
else:
+ data = data.decode("utf-8")
list = get_text(data, '<div id="main">', "</div>")
if list:
comp = compile__('<td align="center">%s((?:\d\.\d)+|\d+?)</font></td><td>%s<a href="/title/tt\d+?/">' \
@@ -417,7 +419,8 @@ class expansion_temp(expansion):
except:
answer = self.AnsBase[0]
else:
- Name = get_text(data, '<h1 class="header" itemprop="name">', "<span>")
+ data = data.decode("utf-8")
+ Name = get_text(data, '<h1 class="header" itemprop="name">', "<span.*?>")
if Name:
ls = ["\->"]
Year = get_text(data, '<a href="/year/\d+?/">', "</a>", "\d+")
@@ -427,38 +430,22 @@ class expansion_temp(expansion):
ls.append(Name)
desc = get_text(data, '<p itemprop="description">', "</p>")
if desc:
- ls.append(desc)
- desc = ls.index(desc)
- Numb = get_text(data, '<span itemprop="ratingValue">', "</span>")
- UsrV = get_text(data, '<span itemprop="ratingCount">', "</span>")
- if Numb:
- if UsrV:
- Numb = "%s (Votes: %s)" % (Numb, UsrV)
- ls.append("Rating: %s" % Numb)
- Ttls = (("Director", "\s*Director:\s*"),
- ("Stars", "\s*Stars:\s*"),
- ("Writers", "\s*Writers:\s*"), ("Writer", "\s*Writer:\s*"))
- for Title in Ttls:
- list = get_text(data, '<h4 class="inline">%s</h4>' % Title[1], "</div>")
+ ls.append(unichr(171) + self.decodeHTML(desc).strip() + unichr(187))
+ for Title in ("Director", "Star", "Writer"):
+ list = get_text(data, "<h4 class=\"inline\">\s*?%s[s]?:\s*?</h4>" % Title, "(?:<span>|</div>)")
if list:
comp = compile__(">(.+?)</a>")
list = comp.findall(list)
if list:
- ls.append("%s: %s" % (Title[0], str.join(", ", list)))
+ ls.append("%ss: %s" % (Title, str.join(", ", list)))
+ rValue = get_text(data, '<span itemprop="ratingValue">', "</span>")
+ if rValue:
+ rCount = get_text(data, '<span itemprop="ratingCount">', "</span>")
+ if rCount:
+ rValue = "%s (Votes: %s)" % (rValue, rCount)
+ ls.append("Rating: %s" % rValue)
if len(ls) >= 2:
- for ln in ls:
- data = self.decodeHTML(ln)
- lines = []
- for line in data.splitlines():
- line = line.strip()
- if line:
- lines.append(line)
- li = ls.index(ln)
- if li == desc:
- lines.append(chr(10))
- lines.insert(0, chr(10))
- ls[li] = str.join(chr(10), lines)
- answer = str.join(chr(10), ls)
+ answer = self.decodeHTML(str.join(chr(10), ls))
else:
answer = self.AnsBase[1]
else:
@@ -475,6 +462,7 @@ class expansion_temp(expansion):
except:
answer = self.AnsBase[0]
else:
+ data = data.decode("utf-8")
list = get_text(data, "<table>", "</table>")
if list:
comp = compile__("/find-title-\d+?/title_.+?/images/b.gif\?link=/title/tt(\d+?)/';\">(.+?)</a> (.+?)<", 16)
@@ -977,8 +965,7 @@ class expansion_temp(expansion):
answer = AnsBase[2]
else:
answer = AnsBase[1]
- if locals().has_key(Types[12]):
- Answer(answer, ltype, source, disp)
+ Answer(answer, ltype, source, disp)
commands = (
(command_jc, "jc", 2,),
diff --git a/expansions/allweb/imdb.en b/expansions/allweb/imdb.en
index 5c6bc62..ac6ac4e 100644
--- a/expansions/allweb/imdb.en
+++ b/expansions/allweb/imdb.en
@@ -1,5 +1,5 @@
info about movies (imdb.com)
-imdb [Name/*/id/top250] (Name/Mumber of points)
+imdb [Name/*/id/top250] (Name/Number of points)
*/imdb A Beautiful Mind
bot would search a movie with name "A Beautiful Mind"
*/imdb 530
@@ -9,4 +9,4 @@ bot would search a movie with name "2012"
*/imdb top250
bot would show IMDb Top 250 Movies
*/imdb top250 25
-bot would show the 1st 25 IMDb Top 250 Movies \ No newline at end of file
+bot would show the 1st 25 of IMDb Top 250 Movies \ No newline at end of file
diff --git a/expansions/allweb/insc.py b/expansions/allweb/insc.py
index f5d264c..15e45ca 100644
--- a/expansions/allweb/insc.py
+++ b/expansions/allweb/insc.py
@@ -19,7 +19,7 @@ if DefLANG in ("RU", "UA"):
"Поддерживаемые языки:\n", # 8
"Завершено - {0}%", # 9
"Начинается загрузка. Это может занять несколько минут...", # 10
- "Сейчас я занят другой загрузкой. Попробуй позже.", # 11
+ "Сейчас в процессе другая загрузка. Попробуй позже.", # 11
"\n* Погода предоставлена Gismeteo.ru", # -2
"Запрос блокирован Кинопоиском." # -1
)])
diff --git a/expansions/cmd_control/taboo.en b/expansions/cmd_control/taboo.en
index d3937ff..337c7ea 100644
--- a/expansions/cmd_control/taboo.en
+++ b/expansions/cmd_control/taboo.en
@@ -5,4 +5,4 @@ bot would show the list of forbidden commands
*/taboo bash
bot would forbid command "bash"
*/taboo bash
-bot would allow command "bash" \ No newline at end of file
+bot would allow command "bash" (if it is forbidden, of course) \ No newline at end of file
diff --git a/expansions/cmd_control/taboo.ru b/expansions/cmd_control/taboo.ru
index 6d505a4..b1bf32e 100644
--- a/expansions/cmd_control/taboo.ru
+++ b/expansions/cmd_control/taboo.ru
@@ -5,4 +5,4 @@
*/табу баш
бот запретит команду "баш"
*/табу баш
-бот снимет запрет на команду "баш" \ No newline at end of file
+бот снимет запрет на команду "баш" (в случае, если она запрещена, конечно) \ No newline at end of file
diff --git a/expansions/exp_control/code.py b/expansions/exp_control/code.py
index f984081..cd2ad11 100644
--- a/expansions/exp_control/code.py
+++ b/expansions/exp_control/code.py
@@ -1,8 +1,8 @@
# coding: utf-8
# BlackSmith mark.2
-exp_name = "exp_control" # /code.py v.x6
-# Id: 09~6b
+exp_name = "exp_control" # /code.py v.x7
+# Id: 09~7b
# Code © (2011-2012) by WitcherGeralt [alkorgun@gmail.com]
expansion_register(exp_name)
@@ -135,26 +135,27 @@ class expansion_temp(expansion):
answer = AnsBase[1]
Answer(answer, ltype, source, disp)
- def command_states(self, ltype, source, body, disp):
+ def command_tumbler(self, ltype, source, body, disp):
if body:
ls = body.split()
command = (ls.pop(0)).lower()
if Cmds.has_key(command):
+ obj = Cmds.get(command)
if ls:
body = (ls.pop(0)).lower()
if body in ("on", "вкл".decode("utf-8")):
- if not Cmds[command].isAvalable:
- if Cmds[command].handler:
- Cmds[command].isAvalable = True
+ if not obj.isAvalable:
+ if obj.handler:
+ obj.isAvalable = True
answer = AnsBase[4]
else:
answer = AnsBase[19] % (command)
else:
answer = self.AnsBase[16] % (command)
elif body in ("off", "выкл".decode("utf-8")):
- if Cmds[command].isAvalable:
- if Cmds[command].handler:
- Cmds[command].isAvalable = False
+ if obj.isAvalable:
+ if obj.handler:
+ obj.isAvalable = False
answer = AnsBase[4]
else:
answer = AnsBase[19] % (command)
@@ -163,16 +164,20 @@ class expansion_temp(expansion):
else:
answer = AnsBase[2]
else:
- answer = AnsBase[2]
+ answer = self.AnsBase[16 if obj.isAvalable else 17] % (command)
else:
answer = AnsBase[6]
else:
- answer = AnsBase[1]
+ oCmds = [cmd for cmd, obj in Cmds.iteritems() if not obj.isAvalable]
+ if oCmds:
+ answer = ", ".join(oCmds)
+ else:
+ answer = self.AnsBase[18]
Answer(answer, ltype, source, disp)
commands = (
(command_expinfo, "expinfo", 7,),
(command_expload, "expload", 8,),
(command_expunload, "expunload", 8,),
- (command_states, "command", 8,)
+ (command_tumbler, "tumbler", 8,)
)
diff --git a/expansions/exp_control/command.en b/expansions/exp_control/command.en
deleted file mode 100644
index 24241cd..0000000
--- a/expansions/exp_control/command.en
+++ /dev/null
@@ -1,6 +0,0 @@
-controller of the commands
-command [command] [on/off]
-*/command talkers off
-bot would disable command "talkers"
-*/command talkers on
-bot would turn on command \ No newline at end of file
diff --git a/expansions/exp_control/command.name b/expansions/exp_control/command.name
deleted file mode 100644
index c0c63ff..0000000
--- a/expansions/exp_control/command.name
+++ /dev/null
@@ -1,4 +0,0 @@
-{
- "RU": "команда",
- "UA": "команда"
-} \ No newline at end of file
diff --git a/expansions/exp_control/command.ru b/expansions/exp_control/command.ru
deleted file mode 100644
index 5c9483f..0000000
--- a/expansions/exp_control/command.ru
+++ /dev/null
@@ -1,6 +0,0 @@
-временное глобальное отключение/включение команд
-команда [команда] [вкл/выкл]
-*/команда трёп выкл
-бот отключит команду "трёп" до следующей перезагрузки
-*/команда трёп вкл
-обратно подключит команду \ No newline at end of file
diff --git a/expansions/exp_control/insc.py b/expansions/exp_control/insc.py
index e91bbf6..dc0c1a4 100644
--- a/expansions/exp_control/insc.py
+++ b/expansions/exp_control/insc.py
@@ -18,8 +18,9 @@ if DefLANG in ("RU", "UA"):
"%s написан некорректно. Загрузка отменена.", # 13
"Этой функции нет в списке зарегистрированных.\n## Список зареганных: %s", # 14
"В %s нет зарегистрированных функций.", # 15
- "Команда «%s» итак включена.", # 16
- "Команда «%s» итак отключена." # 17
+ "Команда «%s» включена.", # 16
+ "Команда «%s» отключена.", # 17
+ "Нет отключенных команд." # 18
)])
else:
AnsBase_temp = (
@@ -40,5 +41,6 @@ else:
"This func. isn't registered.\n## Function list: %s", # 14
"There is no registered functions in %s", # 15
"Command '%s' is on.", # 16
- "Command '%s' is off." # 17
+ "Command '%s' is off.", # 17
+ "No disabled commands." # 18
) \ No newline at end of file
diff --git a/expansions/exp_control/tumbler.en b/expansions/exp_control/tumbler.en
new file mode 100644
index 0000000..6ea4fdd
--- /dev/null
+++ b/expansions/exp_control/tumbler.en
@@ -0,0 +1,10 @@
+controller of the commands
+tumbler (command) (on/off)
+*/tumbler
+bot would show the list of disabled commands
+*/tumbler talkers
+bot would show the state of command "talkers"
+*/tumbler talkers off
+bot would disable command "talkers"
+*/tumbler talkers on
+bot would turn on command \ No newline at end of file
diff --git a/expansions/exp_control/tumbler.name b/expansions/exp_control/tumbler.name
new file mode 100644
index 0000000..7de3d67
--- /dev/null
+++ b/expansions/exp_control/tumbler.name
@@ -0,0 +1,4 @@
+{
+ "RU": "тумблер",
+ "UA": "тумблер"
+} \ No newline at end of file
diff --git a/expansions/exp_control/tumbler.ru b/expansions/exp_control/tumbler.ru
new file mode 100644
index 0000000..4bc0f20
--- /dev/null
+++ b/expansions/exp_control/tumbler.ru
@@ -0,0 +1,10 @@
+временное глобальное отключение/включение команд
+тумблер (команда) (вкл/выкл)
+*/тумблер
+бот покажет отключенные команды
+*/тумблер трёп
+бот покажет состояние команды "трёп"
+*/тумблер трёп выкл
+бот отключит команду "трёп" до следующей перезагрузки
+*/тумблер трёп вкл
+обратно подключит команду \ No newline at end of file
diff --git a/expansions/get_iq/code.py b/expansions/get_iq/code.py
index be02b2a..c9fce7c 100644
--- a/expansions/get_iq/code.py
+++ b/expansions/get_iq/code.py
@@ -229,18 +229,21 @@ class expansion_temp(expansion):
def answer_aflist_search(self, disp, stanza, desc, name, data):
if xmpp.isResultNode(stanza):
- matches = []
+ count = []
for node in stanza.getChildren():
for node in node.getChildren():
if node and node != "None":
jid = node.getAttr("jid")
if jid and jid.count(data):
- matches.append(jid)
- desc[name] = matches
+ signature = node.getTagData("reason")
+ if signature:
+ jid = "%s (%s)" % (jid, signature)
+ count.append(jid)
+ desc[name] = count
def answer_aflist(self, disp, stanza, ltype, source, Numb):
if xmpp.isResultNode(stanza):
- Number, answer = itypes.Number(), str()
+ ls, Number = [], itypes.Number()
for node in stanza.getChildren():
for node in node.getChildren():
if node and node != "None":
@@ -249,18 +252,16 @@ class expansion_temp(expansion):
if Numb and Numb <= Number._int():
Number.plus()
else:
- answer += "\n%d) %s" % (Number.plus(), jid)
signature = node.getTagData("reason")
if signature:
- answer += " [%s]" % (signature)
- if answer:
+ jid = "%s (%s)" % (jid, signature)
+ ls.append("%d) %s" % (Number.plus(), jid))
+ if ls:
if Numb and Numb < Number._int():
- answer += "\n...\nTotal: %s items." % (Number._str())
- Message(source[0], answer, disp)
+ ls.append("...\nTotal: %s items." % (Number._str()))
+ Message(source[0], str.join(chr(10), ls), disp)
if ltype == Types[1]:
answer = AnsBase[11]
- else:
- del answer
else:
answer = self.AnsBase[6]
else:
diff --git a/expansions/sheriff/code.py b/expansions/sheriff/code.py
index 1e616a9..a807f24 100644
--- a/expansions/sheriff/code.py
+++ b/expansions/sheriff/code.py
@@ -12,10 +12,10 @@ class expansion_temp(expansion):
def __init__(self, name):
expansion.__init__(self, name)
- GoodServers = ["jabber.ru", "xmpp.ru", "jabbers.ru", "xmpps.ru", "talkonaut.com", "jabber.org", "gtalk.com", "gmail.com", "jabberon.ru", "gajim.org", "jabbrik.ru", "worldskynet.net", "qip.ru", "blackfishka.ru", "ya.ru"]
+ GoodServers = ["jabber.ru", "xmpp.ru", "jabbers.ru", "xmpps.ru", "jabber.org", "xmpp.org", "gmail.com", "jabberon.ru", "talkonaut.com", "gajim.org", "jabbrik.ru", "qip.ru", "blackfishka.ru", "helldev.net", "ya.ru", "jabberworld.net"]
if (DefLANG != "RU"):
- GoodServers += ["jabber.com", "xmpp.com", "jabber.uk", "jabber.co.uk", "jabberworld.net"]
+ GoodServers += ["jabber.com", "xmpp.com", "jabber.co.uk", "xmpp.co.uk"]
LawsFile = "laws.db"