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-30 12:59:57 +0400
committerAl Korgun <alkorgun@gmail.com>2012-11-30 12:59:57 +0400
commita709c32f6bc941225cbe3e2307cfb6a97915f575 (patch)
tree888dd49ed680ddd70c00d990da0945a0e7866d11
parent239c9783d602b52d08d83c4ac60bde2c521ddbba (diff)
commands "disco" and "dns" added
-rw-r--r--expansions/dns/code.py28
-rw-r--r--expansions/dns/dns.en5
-rw-r--r--expansions/dns/dns.name4
-rw-r--r--expansions/dns/dns.ru5
-rw-r--r--expansions/get_iq/code.py109
-rw-r--r--expansions/get_iq/disco.en10
-rw-r--r--expansions/get_iq/disco.name4
-rw-r--r--expansions/get_iq/disco.ru10
-rw-r--r--expansions/get_iq/insc.py10
-rw-r--r--expansions/get_iq/list.en2
10 files changed, 174 insertions, 13 deletions
diff --git a/expansions/dns/code.py b/expansions/dns/code.py
new file mode 100644
index 0000000..c9b27cb
--- /dev/null
+++ b/expansions/dns/code.py
@@ -0,0 +1,28 @@
+# coding: utf-8
+
+# BlackSmith mark.2
+# exp_name = "dns" # /code.py v.x1
+# Id: 34~1c
+# Code © (2012) by WitcherGeralt [alkorgun@gmail.com]
+
+class expansion_temp(expansion):
+
+ def __init__(self, name):
+ expansion.__init__(self, name)
+
+ import socket
+
+ def command_dns(self, stype, source, adress, disp):
+ if adress:
+ try:
+ name, alias, addrs = self.socket.gethostbyaddr(adress.encode("idna"))
+ except self.socket.error:
+ answer = AnsBase[7]
+ else:
+ addrs.insert(0, name)
+ answer = ", ".join(addrs)
+ else:
+ answer = AnsBase[1]
+ Answer(answer, stype, source, disp)
+
+ commands = ((command_dns, "dns", 1,),)
diff --git a/expansions/dns/dns.en b/expansions/dns/dns.en
new file mode 100644
index 0000000..84a21ae
--- /dev/null
+++ b/expansions/dns/dns.en
@@ -0,0 +1,5 @@
+Domain Name System
+dns [domain/ip_address]
+*/dns google.com
+*/dns 2a00:1450:4001:c02::64
+*/dns 72.21.210.29 \ No newline at end of file
diff --git a/expansions/dns/dns.name b/expansions/dns/dns.name
new file mode 100644
index 0000000..7628b32
--- /dev/null
+++ b/expansions/dns/dns.name
@@ -0,0 +1,4 @@
+{
+ "RU": "днс",
+ "UA": "днс"
+} \ No newline at end of file
diff --git a/expansions/dns/dns.ru b/expansions/dns/dns.ru
new file mode 100644
index 0000000..b88e97c
--- /dev/null
+++ b/expansions/dns/dns.ru
@@ -0,0 +1,5 @@
+Domain Name System
+dns [домен/ip_адрес]
+*/dns google.com
+*/dns 2a00:1450:4001:c02::64
+*/dns 72.21.210.29 \ No newline at end of file
diff --git a/expansions/get_iq/code.py b/expansions/get_iq/code.py
index 6a1d03f..b11b60f 100644
--- a/expansions/get_iq/code.py
+++ b/expansions/get_iq/code.py
@@ -1,8 +1,8 @@
# coding: utf-8
# BlackSmith mark.2
-# exp_name = "get_iq" # /code.py v.x7
-# Id: 13~6c
+# exp_name = "get_iq" # /code.py v.x8
+# Id: 13~7c
# Code © (2010-2012) by WitcherGeralt [alkorgun@gmail.com]
class expansion_temp(expansion):
@@ -298,11 +298,11 @@ class expansion_temp(expansion):
def get_req(body):
if DefLANG in ("RU", "UA"):
- affsRU = ["овнер", "админ", "мембер", "бан"]
- for name in affsRU:
- if body.count(name.decode("utf-8")):
- return self.affs[affsRU.index(name)]
- return (body if self.affs.count(body) else None)
+ for numb, name in enumerate(("овнер", "админ", "мембер", "бан")):
+ name = name.decode("utf-8")
+ if name in body:
+ return self.affs[numb]
+ return (body if body in self.affs else None)
if Chats.has_key(source[1]):
if body:
@@ -442,6 +442,98 @@ class expansion_temp(expansion):
answer = self.AnsBase[6]
Answer(answer, stype, source, disp)
+ XEPs.add(xmpp.NS_DISCO_ITEMS)
+
+ def command_disco(self, stype, source, body, disp):
+ if body:
+ desc = {"stype": stype, "source": source, "body": None, "limit": 16}
+ ls = body.split(None, 2)
+ server = (ls.pop(0)).lower()
+ if ls:
+ limit = ls.pop(0)
+ if isNumber(limit):
+ limit = int(limit)
+ if limit > 2:
+ if stype == Types[0]:
+ if limit > 256:
+ limit = 256
+ elif limit > 24:
+ limit = 24
+ desc["limit"] = limit
+ if ls:
+ desc["body"] = ls.pop(0)
+ else:
+ desc["body"] = body[len(server):].strip()
+ iq = xmpp.Iq(to = server, typ = Types[10])
+ iq.addChild(Types[18], namespace = xmpp.NS_DISCO_ITEMS)
+ iq.setID("Bs-i%d" % Info["outiq"].plus())
+ CallForResponse(disp, iq, self.answer_disco, desc)
+ else:
+ Answer(AnsBase[1], stype, source, disp)
+
+ compile_disco = compile__("^(.+?)\((\d+?)\)$", 16)
+
+ def answer_disco(self, disp, stanza, stype, source, body, limit):
+ if xmpp.isResultNode(stanza):
+ confs, ls = [], []
+ for node in stanza.getQueryChildren():
+ if node and node != "None":
+ jid = str(node.getAttr("jid"))
+ name = node.getAttr("name")
+ node = node.getAttr("node")
+ if name:
+ if body and not (body in jid or body in name):
+ continue
+ data = self.compile_disco.search(name)
+ if data:
+ name, numb = data.groups()
+ confs.append((int(numb), jid, name[:48].strip()))
+ continue
+ if node:
+ items = (jid, name[:48].strip(), node)
+ elif jid.endswith(name):
+ items = (name[:48].strip(),)
+ else:
+ items = (jid, name[:48].strip())
+ elif node:
+ if body and body not in jid:
+ continue
+ items = (jid, node)
+ else:
+ if body and body not in jid:
+ continue
+ items = (jid,)
+ ls.append(items)
+ if confs or ls:
+ confs.sort()
+ confs.reverse()
+ ls.sort()
+ number = itypes.Number()
+ result = []
+ for numb, jid, name in confs:
+ if number.plus() > limit:
+ break
+ result.append("%s (%d) [%s]" % (name, numb, jid))
+ for items in ls:
+ if number.plus() > limit:
+ break
+ ln = len(items)
+ if ln == 3:
+ result.append("%s - %s (%s)" % items)
+ elif ln == 2:
+ result.append("%s - %s" % items)
+ else:
+ result.append(items[0])
+ answer = "\->\n" + enumerated_list(result)
+ res_ln = len(ls) + len(confs)
+ if res_ln:
+ answer += self.AnsBase[11] % (res_ln)
+ else:
+ answer = self.AnsBase[4]
+ else:
+ answer = self.AnsBase[6]
+ Answer(answer, stype, source, disp)
+
commands = (
(command_ping, "ping", 1,),
(command_ping_stats, "pstat", 1,),
@@ -451,5 +543,6 @@ class expansion_temp(expansion):
(command_uptime, "uptime", 1,),
(command_idle, "idle", 1,),
(command_aflist, "list", 4,),
- (command_server_stats, "servstat", 1,)
+ (command_server_stats, "servstat", 1,),
+ (command_disco, "disco", 2,)
)
diff --git a/expansions/get_iq/disco.en b/expansions/get_iq/disco.en
new file mode 100644
index 0000000..7becfc3
--- /dev/null
+++ b/expansions/get_iq/disco.en
@@ -0,0 +1,10 @@
+xmpp disco
+disco [jid] (result's_number) (search_query)
+*/disco jabber.ru
+bot would show the list of services of jabber.ru
+*/disco conference.jabber.ru 10 witcher
+bot would search "witcher" on conference.jabber.ru & show up to 10 results (max 24 results in chat, max 256 in private, 16 default)
+*/disco conference.jabber.ru 20
+bot would show top 20 conferences with max users of jabber.ru
+*/disco example@conference.jabber.ru
+bot would show the list of online users of example@conference.jabber.ru \ No newline at end of file
diff --git a/expansions/get_iq/disco.name b/expansions/get_iq/disco.name
new file mode 100644
index 0000000..02db4ea
--- /dev/null
+++ b/expansions/get_iq/disco.name
@@ -0,0 +1,4 @@
+{
+ "RU": "диско",
+ "UA": "диско"
+} \ No newline at end of file
diff --git a/expansions/get_iq/disco.ru b/expansions/get_iq/disco.ru
new file mode 100644
index 0000000..15fd618
--- /dev/null
+++ b/expansions/get_iq/disco.ru
@@ -0,0 +1,10 @@
+xmpp disco
+диско [jid] (число_результатов) (поисковый_ключ)
+*/диско jabber.ru
+бот покажет сервисы jabber.ru
+*/диско conference.jabber.ru 10 witcher
+бот покажет до 10ти результатов по запросу "witcher" (в чате максимум 24, в привате марсимум 256, дефолт 16)
+*/диско conference.jabber.ru 20
+бот покажет 20 конференций с наибольшим количеством пользователей онлайн
+*/диско example@conference.jabber.ru
+бот покажет список ников пользователей в example@conference.jabber.ru \ No newline at end of file
diff --git a/expansions/get_iq/insc.py b/expansions/get_iq/insc.py
index 60ffeb2..08fe9f2 100644
--- a/expansions/get_iq/insc.py
+++ b/expansions/get_iq/insc.py
@@ -6,13 +6,14 @@ if DefLANG in ("RU", "UA"):
"Понга нет. Ответ на версию (%s) за %s секунд.", # 1
"Ни пинга, ни версии...", # 2
"\nСтатистика пинга (всего %s):\nСамый быстрый пинг - %s\nСамый медленный пинг - %s\nСреднее время пинга - %s", # 3
- "Нет статистики.", # 4
+ "Нет результата.", # 4
"«%s» - сейчас нет в чате.", # 5
"Нет ответа.", # 6
"Время работы «%s» - %s.", # 7
"Послеедняя активность «%s» - %s назад.", # 8
"Нет cовпадений.", # 9
- "Вкард не заполнен." # 10
+ "Вкард не заполнен.", # 10
+ "\n\n** Всего %d пунктов." # 11
)])
else:
AnsBase_temp = (
@@ -20,11 +21,12 @@ else:
"No pong. Answer for version (%s) in %s sec.", # 1
"No pong, no version...", # 2
"\nPing statistics (total %s):\nFastest - %s\nSlowest - %s\nAverage time - %s", # 3
- "No statistics.", # 4
+ "No result.", # 4
"«%s» - isn't here now.", # 5
"No answer.", # 6
"%s's uptime is %s.", # 7
"%s's last activity was %s ago.", # 8
"No matches.", # 9
- "The vCard is empty." # 10
+ "The vCard is empty.", # 10
+ "\n\n** Total %d results." # 11
) \ No newline at end of file
diff --git a/expansions/get_iq/list.en b/expansions/get_iq/list.en
index 46a2d3e..5851e97 100644
--- a/expansions/get_iq/list.en
+++ b/expansions/get_iq/list.en
@@ -1,6 +1,6 @@
affiliation lists
list [owner/admin/member/outcast]/[[search] [text]]
*/list owner
-bot would show list of conference's owners
+bot would show the list of conference's owners
*/list search dude
bot would search "dude" in chat's affiliation lists \ No newline at end of file