diff options
author | Al Korgun <alkorgun@gmail.com> | 2012-11-10 19:27:25 +0400 |
---|---|---|
committer | Al Korgun <alkorgun@gmail.com> | 2012-11-10 19:27:25 +0400 |
commit | c37dd976d68a5a1b1285655723739251f78e5ff2 (patch) | |
tree | dffea7d654762e509894413bc2d35530bf91cf3f | |
parent | 42fbc2afbed93b497ee9ab8b7f485fe032d940db (diff) |
commands added: chuck (english version), bash, tr (google translate); fullban/unban refactored
44 files changed, 561 insertions, 254 deletions
diff --git a/BlackSmith.py b/BlackSmith.py index c62b96b..0728523 100644 --- a/BlackSmith.py +++ b/BlackSmith.py @@ -10,7 +10,7 @@ from types import NoneType, UnicodeType, InstanceType from traceback import print_exc as exc_info__ -from random import shuffle, randint, choice +from random import shuffle, randrange, choice from re import compile as compile__ import sys, os, gc, time, ConfigParser @@ -146,7 +146,7 @@ aFeatures = Features + [ xmpp.NS_RECEIPTS ] -IsJID = compile__(".+?@\w+?\.\w+?", 32) +IsJID = compile__(".+?@[\w-]+?\.[\w-]+?", 32) VarCache = { "idle": 0.24, @@ -255,7 +255,7 @@ else: static = "static/%s" dynamic = "current/%s" ExpsDir = "expansions" -FeilDir = "feillog" +FailDir = "exceptions" PidFile = "sessions.db" GenCrash = "dispatcher.crash" SvnCache = ".svn/entries" @@ -264,7 +264,7 @@ GenConFile = static % ("config.ini") ConDispFile = static % ("clients.ini") ChatsFile = dynamic % ("chats.db") -(BsMark, BsVer, BsRev) = (2, 31, 0) +(BsMark, BsVer, BsRev) = (2, 32, 0) if os.access(SvnCache, os.R_OK): Cache = open(SvnCache).readlines() @@ -320,7 +320,7 @@ try: Disp, Instance = client_config(ConDisp, Block) InstansesDesc[Disp] = Instance except: - Exit("\n\nOne of config files is corrupted!", 1, 30) + Exit("\n\nOne of the configuration files is corrupted!", 1, 30) del Instance @@ -329,7 +329,7 @@ MaxMemory = (32768 if (MaxMemory and MaxMemory <= 32768) else MaxMemory) try: execfile(GenInscFile) except: - Exit("\n\nError: inscript is damaged!", 1, 30) + Exit("\n\nError: general inscript is damaged!", 1, 30) if oSlist[0]: os.system(sys_cmds[2]) @@ -339,7 +339,7 @@ if oSlist[0]: expansions = {} Cmds = {} -cPrefs = ("!","@","#",".","*") +cPrefs = ("!", "@", "#", ".", "*") sCmds = [] Chats = {} Flood = {} @@ -594,7 +594,7 @@ def command_handler(exp_link, handler, name, access, pfx = True): # Chats, Users & Other -class sUser: +class sUser(object): def __init__(self, nick, role, source, access = None): self.nick = nick @@ -615,7 +615,7 @@ class sUser: def calc_acc(self): self.access = (aDesc.get(self.role[0], 0) + aDesc.get(self.role[1], 0)) -class sConf: +class sConf(object): def __init__(self, name, disp, code = None, cPref = None, nick = DefNick, added = False): self.name = name @@ -740,7 +740,7 @@ class sConf: else: delivery(self.name) - def iq_sender(self, attr, data, afrls, role, text = str(), source = ()): + def iq_sender(self, attr, data, afrls, role, text = str(), handler = None): stanza = xmpp.Iq(to = self.name, typ = Types[9]) stanza.setID("Bs-i%d" % Info["outiq"].plus()) query = xmpp.Node(Types[18]) @@ -749,37 +749,41 @@ class sConf: if text: arole.setTagData("reason", text) stanza.addChild(node = query) - if not source: + if not handler: self.csend(stanza) else: - CallForResponse(self.disp, stanza, Handle_Answer, {"source": source}) + handler, kdesc = handler + if not handler: + handler = HandleResponse + kdesc = {"source": kdesc} + CallForResponse(self.disp, stanza, handler, kdesc) - def outcast(self, jid, text = str(), source = ()): - self.iq_sender(Types[19], jid, AflRoles[0], AflRoles[1], text, source) + def outcast(self, jid, text = str(), handler = ()): + self.iq_sender(Types[19], jid, AflRoles[0], AflRoles[1], text, handler) - def none(self, jid, text = str(), source = ()): - self.iq_sender(Types[19], jid, AflRoles[0], AflRoles[2], text, source) + def none(self, jid, text = str(), handler = ()): + self.iq_sender(Types[19], jid, AflRoles[0], AflRoles[2], text, handler) - def member(self, jid, text = str(), source = ()): - self.iq_sender(Types[19], jid, AflRoles[0], AflRoles[3], text, source) + def member(self, jid, text = str(), handler = ()): + self.iq_sender(Types[19], jid, AflRoles[0], AflRoles[3], text, handler) - def admin(self, jid, text = str(), source = ()): - self.iq_sender(Types[19], jid, AflRoles[0], AflRoles[4], text, source) + def admin(self, jid, text = str(), handler = ()): + self.iq_sender(Types[19], jid, AflRoles[0], AflRoles[4], text, handler) - def owner(self, jid, text = str(), source = ()): - self.iq_sender(Types[19], jid, AflRoles[0], AflRoles[5], text, source) + def owner(self, jid, text = str(), handler = ()): + self.iq_sender(Types[19], jid, AflRoles[0], AflRoles[5], text, handler) - def kick(self, nick, text = str(), source = ()): - self.iq_sender(Types[20], nick, AflRoles[6], AflRoles[2], text, source) + def kick(self, nick, text = str(), handler = ()): + self.iq_sender(Types[20], nick, AflRoles[6], AflRoles[2], text, handler) - def visitor(self, nick, text = str(), source = ()): - self.iq_sender(Types[20], nick, AflRoles[6], AflRoles[7], text, source) + def visitor(self, nick, text = str(), handler = ()): + self.iq_sender(Types[20], nick, AflRoles[6], AflRoles[7], text, handler) - def participant(self, nick, text = str(), source = ()): - self.iq_sender(Types[20], nick, AflRoles[6], AflRoles[8], text, source) + def participant(self, nick, text = str(), handler = ()): + self.iq_sender(Types[20], nick, AflRoles[6], AflRoles[8], text, handler) - def moder(self, nick, text = str(), source = ()): - self.iq_sender(Types[20], nick, AflRoles[6], AflRoles[9], text, source) + def moder(self, nick, text = str(), handler = ()): + self.iq_sender(Types[20], nick, AflRoles[6], AflRoles[9], text, handler) def get_source(source, nick): if Chats.has_key(source): @@ -822,7 +826,7 @@ def delivery(body): except: exc_info_() -def Msend(instance, body, disp = None): +def Message(instance, body, disp = None): body = object_encode(body) if Chats.has_key(instance): ltype = Types[1] @@ -858,9 +862,9 @@ def Answer(body, ltyp, source, disp = None): body = object_encode(body) if ltyp == Types[1]: body = "%s: %s" % (source[2], body) - Msend(source[1], body, disp) + Message(source[1], body, disp) elif ltyp == Types[0]: - Msend(source[0], body, disp) + Message(source[0], body, disp) def CheckFlood(disp): disp = get_disp(disp) @@ -934,7 +938,7 @@ def ResponseChecker(disp, stanza): sThread(handler.func_name, exec_bsExp, (handler, disp, stanza, keywords)) xmpp_raise() -def Handle_Answer(disp, stanza, source): +def HandleResponse(disp, stanza, source): if xmpp.isResultNode(stanza): Answer(AnsBase[4], source[0], source[1], disp) else: @@ -1023,10 +1027,10 @@ def collectExc(instance, command = None): delivery(AnsBase[15] % exception) else: Print("\n\nError: can't execute '%s'!" % (instance), color2) - filename = "%s/error[%d]%s.crash" % (FeilDir, (Info["cfw"]._int() + 1), strTime("[%H.%M.%S][%d.%m.%Y]")) + filename = "%s/error[%d]%s.crash" % (FailDir, (Info["cfw"]._int() + 1), strTime("[%H.%M.%S][%d.%m.%Y]")) try: - if not os.path.exists(FeilDir): - os.mkdir(FeilDir, 0755) + if not os.path.exists(FailDir): + os.mkdir(FailDir, 0755) crashfile = open(filename, "wb") Info["cfw"].plus() exc_info_(crashfile) @@ -1037,7 +1041,7 @@ def collectExc(instance, command = None): else: delivery(AnsBase[17] % (Number, filename)) else: - Print("\n\nCrash file --> %s\nError number --> %d" % (filename, Number), color2) + Print("\n\nCrash file --> %s\nError's number --> %d" % (filename, Number), color2) except: exc_info_() if GetExc and online(Gen_disp): @@ -1076,7 +1080,7 @@ def get_pipe(command): data = "(...)" return data -class Web: +class Web(object): import urllib as One, urllib2 as Two @@ -1197,9 +1201,9 @@ def enumerated_list(list): ls.append(AnsBase[12] % (Numb.plus(), line)) return str.join(chr(10), ls) -isNumber = lambda objt: (None if exec_(int, (objt,)) is None else True) +isNumber = lambda obj: (None if exec_(int, (obj,)) is None else True) -isSource = lambda data: IsJID.match(data) +isSource = lambda jid: IsJID.match(jid) def calculate(Numb = int()): if oSlist[0]: @@ -1207,7 +1211,7 @@ def calculate(Numb = int()): if len(lines) >= 3: list = lines[3].split() if len(list) >= 6: - Numb = "%s%s" % (list[4], list[5]) + Numb = (list[4] + list[5]) else: lines = get_pipe(sys_cmds[0] % (BsPid)).splitlines() if len(lines) >= 2: @@ -1256,7 +1260,7 @@ def join_chats(): else: Print("\nI'll join %s then %s would be connected..." % (conf, Chats[conf].disp), color1) else: - Print("\n\nError: unable to create chatrooms list file!", color2) + Print("\n\nError: unable to create the conferences-list file!", color2) # Presence Handler @@ -1310,7 +1314,7 @@ def Xmpp_Presence_Cb(disp, stanza): Chats[conf].isModer = False if not Mserve: Chats[conf].change_status(AnsBase[23], sList[2]) - Msend(conf, AnsBase[24], disp) + Message(conf, AnsBase[24], disp) xmpp_raise() elif not Mserve: xmpp_raise() @@ -1453,7 +1457,7 @@ def Xmpp_Message_Cb(disp, stanza): xmpp_raise() Chats[instance].join() time.sleep(0.6) - Msend(source, body) + Message(source, body) xmpp_raise() if Subject: call_efunctions("09eh", (instance, nick, Subject, body, disp,)) @@ -1466,7 +1470,7 @@ def Xmpp_Message_Cb(disp, stanza): answer.setID(stanza.getID()) Sender(disp, answer) stype = Types[0] - for app in ["%s%s" % (BotNick, Key) for Key in (":",",",">")]: + for app in [(BotNick + Key) for Key in (":", ",", ">")]: if Copy.startswith(app): Copy, isToBs = Copy[len(app):].lstrip(), True break @@ -1503,12 +1507,12 @@ def connect_client(source, InstanceAttrs): if ConType: ConType = ConType.upper() if ConTls and ConType != "TLS": - Print("\n'%s' was connected, but connection isn't secure." % (source), color1) + Print("\n'%s' was connected, but a connection isn't secure." % (source), color1) else: Print("\n'%s' was successfully connected!" % (source), color3) Print("\n'%s' using - '%s'" % (source, ConType), color4) else: - Print("\n'%s' can't connect to '%s' (Port: %s). I will retry later..." % (source, server.upper(), str(cport)), color2) + Print("\n'%s' can't connect to '%s' (Port: %s). I'll retry later..." % (source, server.upper(), str(cport)), color2) return (False, False) Print("\n'%s' authenticating..." % (source), color4) try: @@ -1523,7 +1527,7 @@ def connect_client(source, InstanceAttrs): if Auth == "sasl": Print("\n'%s' was successfully authenticated!" % (source), color3) else: - Print("\n'%s' was authenticated, but old auth method was used...", color1) + Print("\n'%s' was authenticated, but old auth method is used...", color1) else: eBody = str(disp.lastErr) eCode = str(disp.lastErrCode) @@ -1562,7 +1566,7 @@ def connect_clients(): if not conn[0]: if conn[1] and conn[1] == eCodes[2]: continue - composeTimer(60, connectAndDispatch, "%s%s" % (Types[13], Inctance), (Inctance,)).start() + composeTimer(60, connectAndDispatch, (Types[13] + Inctance), (Inctance,)).start() def Reverse_disp(disp, chats_ = True): Iters = itypes.Number() @@ -1624,7 +1628,7 @@ def load_mark2(): Print("\n\n%s is ready to serve!\n\n" % (ProdName), color3) call_sfunctions("02si") for disp in Clients.keys(): - ThrName = "%s%s" % (Types[13], disp) + ThrName = (Types[13] + disp) if ThrName not in iThr.ThrNames(): composeThr(Dispatch_handler, ThrName, (disp,)).start() while VarCache["alive"]: @@ -1634,7 +1638,7 @@ def load_mark2(): if Name.startswith(Types[13]): Cls.plus() if 0 is Cls._int(): - sys_exit("All clients was fallen!") + sys_exit("All of the clients now fallen!") sys.exc_clear() gc.collect() if MaxMemory and MaxMemory <= calculate(): @@ -1657,6 +1661,6 @@ if __name__ == "__main__": sys_exit("Interrupt (Ctrl+C)") except: collectExc(load_mark2) - sys_exit("Critical Feil!") + sys_exit("Critical Fail!") # The End is Near =>
\ No newline at end of file diff --git a/expansions/access/code.py b/expansions/access/code.py index 61d1101..e1d6b50 100644 --- a/expansions/access/code.py +++ b/expansions/access/code.py @@ -55,7 +55,7 @@ class expansion_temp(expansion): answer, Numb = self.AnsBase[5], itypes.Number() for x in list: answer += "%d) %s - %d\n" % (Numb.plus(), x[1], x[0]) - Msend(source[0], answer, disp) + Message(source[0], answer, disp) else: Answer(self.AnsBase[3], ltype, source, disp) @@ -72,7 +72,7 @@ class expansion_temp(expansion): answer, Numb = self.AnsBase[5], itypes.Number() for x in list: answer += "%d) %s - %d\n" % (Numb.plus(), x[1], x[0]) - Msend(source[0], answer, disp) + Message(source[0], answer, disp) else: answer = self.AnsBase[4] else: diff --git a/expansions/access/insc.py b/expansions/access/insc.py index 9a07f06..f4a4dd5 100644 --- a/expansions/access/insc.py +++ b/expansions/access/insc.py @@ -18,11 +18,11 @@ else: AnsBase_temp = ( "Your access = %s", # 0 "%s's access = %s", # 1 - "I have not information about '%s'.", # 2 + "I have no information about '%s'.", # 2 "No global accesses.", # 3 "No local accesses.", # 4 "Access list:\n", # 5 - "So, '%s' has not access.", # 6 + "So, '%s' has no access.", # 6 "You can't give access < -1 & > 8.", # 7 "You can't give local access < 0 & > 6.", # 8 "'%s' has global access.", # 9 diff --git a/expansions/alive_keeper/code.py b/expansions/alive_keeper/code.py index 2343285..e020a7c 100644 --- a/expansions/alive_keeper/code.py +++ b/expansions/alive_keeper/code.py @@ -26,7 +26,7 @@ class expansion_temp(expansion): Clients[disp].aKeeper = itypes.Number() if Clients[disp].aKeeper._int() >= 3: Clients[disp].aKeeper = itypes.Number() - ThrName = "%s%s" % (Types[13], disp) + ThrName = (Types[13] + disp) if ThrName in ThrIds: for Thr in iThr.enumerate(): if Thr._Thread__name == ThrName: diff --git a/expansions/allweb/bash.en b/expansions/allweb/bash.en new file mode 100644 index 0000000..be5b839 --- /dev/null +++ b/expansions/allweb/bash.en @@ -0,0 +1,6 @@ +quotes from bash.org
+bash (quotes'_number)
+*/bash
+bot would show a random quote
+*/bash 30456
+bot would show a quote with number 30456
\ No newline at end of file diff --git a/expansions/allweb/bash.name b/expansions/allweb/bash.name new file mode 100644 index 0000000..e3a39d9 --- /dev/null +++ b/expansions/allweb/bash.name @@ -0,0 +1,4 @@ +{
+ "RU": "баш",
+ "UA": "баш"
+}
\ No newline at end of file diff --git a/expansions/allweb/bash.ru b/expansions/allweb/bash.ru new file mode 100644 index 0000000..41f1a57 --- /dev/null +++ b/expansions/allweb/bash.ru @@ -0,0 +1,6 @@ +граббер цитат с bash.im
+баш (номер_цитаты)
+*/баш
+бот покажет случайную цитату
+*/баш 30456
+бот покажет цитату под номером 30456
\ No newline at end of file diff --git a/expansions/allweb/chuck.en b/expansions/allweb/chuck.en new file mode 100644 index 0000000..ef0df71 --- /dev/null +++ b/expansions/allweb/chuck.en @@ -0,0 +1,2 @@ +Chuck Norris "Facts" from chucknorrisfacts.com
+chuck
\ No newline at end of file diff --git a/expansions/allweb/code.py b/expansions/allweb/code.py index daefe28..80a4042 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.x14 -# Id: 25~14b +exp_name = "allweb" # /code.py v.x15 +# Id: 25~15b # Code © (2011-2012) by WitcherGeralt [alkorgun@gmail.com] expansion_register(exp_name) @@ -85,6 +85,8 @@ class expansion_temp(expansion): Req = Web("http://jc.jabber.ru/search.html?", [("search", cName.encode("utf-8"))]) try: data = Req.get_page(self.UserAgent) + except Web.Two.HTTPError, exc: + answer = str(exc) except: answer = self.AnsBase[0] else: @@ -105,12 +107,17 @@ class expansion_temp(expansion): gCache = [] + sMark = 1 + tMark = 2 + def command_google(self, ltype, source, body, disp): if body: if (chr(42) != body): Req = Web("http://ajax.googleapis.com/ajax/services/search/web?", [("v", "1.0"), ("q", body.encode("utf-8"))]) try: data = Req.get_page(self.UserAgent) + except Web.Two.HTTPError, exc: + answer = str(exc) except: answer = self.AnsBase[0] else: @@ -119,9 +126,11 @@ class expansion_temp(expansion): except: answer = self.AnsBase[1] else: - data = data.get("responseData", {"results": []}) - list = data.get("results", []) - if list: + try: + list = data["responseData"]["results"] + except KeyError: + answer = self.AnsBase[5] + else: desc = list.pop(0) ls = [] ls.append(desc.get("title", "")) @@ -132,23 +141,21 @@ class expansion_temp(expansion): source_ = get_source(source[1], source[2]) if source_: for ls in self.gCache: - if ls[0] == source_: + if ls[:2] == (source_, self.sMark): self.gCache.pop(self.gCache.index(ls)) break - Numb = (len(Clients.keys())*4) + Numb = (len(Clients.keys())*8) while len(self.gCache) >= Numb: self.gCache.pop(0) - self.gCache.append((source_, list)) + self.gCache.append((source_, self.sMark, list)) answer += self.AnsBase[4] % len(list) - else: - answer = self.AnsBase[5] else: source_ = get_source(source[1], source[2]) if source_: list = [] for ls in self.gCache: - if ls[0] == source_: - list = self.gCache.pop(self.gCache.index(ls))[1] + if ls[:2] == (source_, self.sMark): + list = self.gCache.pop(self.gCache.index(ls))[2] break if list: desc = list.pop(0) @@ -158,7 +165,7 @@ class expansion_temp(expansion): ls.append(desc.get("unescapedUrl", "")) answer = self.decodeHTML(str.join(chr(10), ls)) if list: - self.gCache.append((source_, list)) + self.gCache.append((source_, self.sMark, list)) answer += self.AnsBase[4] % len(list) else: answer = self.AnsBase[2] @@ -168,11 +175,98 @@ class expansion_temp(expansion): answer = AnsBase[1] Answer(answer, ltype, source, disp) + def command_google_translate(self, ltype, source, body, disp): + if body: + if (chr(42) != body): + body = body.split(None, 2) + if len(body) == 3: + lang0, langX, body = body + if langX in LangMap and (lang0 in LangMap or lang0 == "auto"): + desc = (("client", "bs-2"), + ("sl", lang0), + ("tl", langX), + ("text", body.encode("utf-8"))) + Req = Web("http://translate.google.com/translate_a/t?", desc, {"Accept-Charset": "utf-8"}) + try: + data = Req.get_page(self.UserAgent_Moz) + except Web.Two.HTTPError, exc: + answer = str(exc) + except: + answer = self.AnsBase[0] + else: + try: + data = self.json.loads(data) + except: + answer = self.AnsBase[1] + else: + try: + body = data["sentences"][0]["trans"] + except LookupError: + answer = self.AnsBase[1] + else: + if lang0 == "auto": + try: + lang0 = data["src"] + except KeyError: + pass + answer = "%s -> %s:\n%s" % (lang0, langX, body) + try: + list = data["dict"][0]["terms"] + except LookupError: + pass + else: + source_ = get_source(source[1], source[2]) + if source_: + if body in list: + list.pop(list.index(body)) + if list: + for ls in self.gCache: + if ls[:2] == (source_, self.tMark): + self.gCache.pop(self.gCache.index(ls)) + break + Numb = (len(Clients.keys())*8) + while len(self.gCache) >= Numb: + self.gCache.pop(0) + self.gCache.append((source_, self.tMark, list)) + answer += self.AnsBase[7] % len(list) + else: + answer = self.AnsBase[6] + else: + answer = AnsBase[2] + else: + source_ = get_source(source[1], source[2]) + if source_: + list = [] + for ls in self.gCache: + if ls[:2] == (source_, self.tMark): + list = self.gCache.pop(self.gCache.index(ls))[2] + break + if list: + answer = self.decodeHTML(list.pop(0)) + if list: + self.gCache.append((source_, self.tMark, list)) + answer += self.AnsBase[7] % len(list) + else: + answer = self.AnsBase[2] + else: + answer = self.AnsBase[3] + else: + answer = self.AnsBase[8] + str.join(chr(10), ["%s - %s" % (k, l) for k, l in sorted(LangMap.items())]) + Answer(answer, ltype, source, disp) + + kinoHeaders = { + "Host": "www.kinopoisk.ru", + "Accept": "text/html", + "Accept-Charset": "cp1251", + "Accept-Language": "ru" + } + + C3oP = "СЗоР" + def command_kino(self, ltype, source, body, disp): if body: ls = body.split() c1st = (ls.pop(0)).lower() - c3op = "СЗоР" if c1st in ("top250", "топ250".decode("utf-8")): if ls: limit = exec_(int, (ls.pop(0),)) @@ -180,9 +274,11 @@ class expansion_temp(expansion): limit = 5 else: limit = None - Req = Web("http://www.kinopoisk.ru/level/20/") + Req = Web("http://www.kinopoisk.ru/level/20/", headers = self.kinoHeaders) try: data = Req.get_page(self.UserAgent_Moz) + except Web.Two.HTTPError, exc: + answer = str(exc) except: answer = self.AnsBase[0] else: @@ -203,17 +299,19 @@ class expansion_temp(expansion): if ltype == Types[1]: Answer(AnsBase[11], ltype, source, disp) Top250 = str.join(chr(10), ls) - Msend(source[0], Top250, disp) + Message(source[0], Top250, disp) else: answer = str.join(chr(10), ls) - elif data.count(c3op): + elif data.count(self.C3oP): answer = self.AnsBase[-1] else: answer = self.AnsBase[1] elif isNumber(body): - Req = Web("http://m.kinopoisk.ru/movie/%s" % (body)) + Req = Web("http://m.kinopoisk.ru/movie/%s" % (body), headers = self.kinoHeaders) try: data = Req.get_page(self.UserAgent_Moz) + except Web.Two.HTTPError, exc: + answer = str(exc) except: answer = self.AnsBase[0] else: @@ -229,16 +327,18 @@ class expansion_temp(expansion): line = "{1}{0}".format(line[1:], line[0].upper()) ls.append(line) answer = str.join(chr(10), ls) - elif data.count(c3op): + elif data.count(self.C3oP): answer = self.AnsBase[-1] else: answer = self.AnsBase[5] else: Req = (body if chr(42) != c1st else body[2:].strip()) Req = Req.encode("cp1251") - Req = Web("http://m.kinopoisk.ru/search/%s" % Web.One.quote_plus(Req)) + Req = Web("http://m.kinopoisk.ru/search/%s" % Web.One.quote_plus(Req), headers = self.kinoHeaders) try: data = Req.get_page(self.UserAgent_Moz) + except Web.Two.HTTPError, exc: + answer = str(exc) except: answer = self.AnsBase[0] else: @@ -251,7 +351,7 @@ class expansion_temp(expansion): for Numb, Name in list: ls.append("%d) %s (#%s)" % (Number.plus(), self.sub_ehtmls(Name), Numb)) answer = str.join(chr(10), ls) - elif data.count(c3op): + elif data.count(self.C3oP): answer = self.AnsBase[-1] else: answer = self.AnsBase[5] @@ -260,6 +360,8 @@ class expansion_temp(expansion): if locals().has_key(Types[12]): Answer(answer, ltype, source, disp) + IMDbHeaders = {"Accept-Language": "%s,en" % DefLANG.lower()} + def command_imdb(self, ltype, source, body, disp): if body: ls = body.split() @@ -271,9 +373,11 @@ class expansion_temp(expansion): limit = 5 else: limit = None - Req = Web("http://www.imdb.com/chart/top") + Req = Web("http://www.imdb.com/chart/top", headers = self.IMDbHeaders) try: data = Req.get_page(self.UserAgent_Moz) + except Web.Two.HTTPError, exc: + answer = str(exc) except: answer = self.AnsBase[0] else: @@ -294,15 +398,17 @@ class expansion_temp(expansion): if ltype == Types[1]: Answer(AnsBase[11], ltype, source, disp) Top250 = str.join(chr(10), ls) - Msend(source[0], Top250, disp) + Message(source[0], Top250, disp) else: answer = str.join(chr(10), ls) else: answer = self.AnsBase[1] elif isNumber(body): - Req = Web("http://www.imdb.com/title/tt%s/" % (body)) + Req = Web("http://www.imdb.com/title/tt%s/" % (body), headers = self.IMDbHeaders) try: data = Req.get_page(self.UserAgent_Moz) + except Web.Two.HTTPError, exc: + answer = str(exc) except: answer = self.AnsBase[0] else: @@ -323,7 +429,7 @@ class expansion_temp(expansion): if Numb: if UsrV: Numb = "%s (Votes: %s)" % (Numb, UsrV) - ls.append("Raiting: %s" % Numb) + ls.append("Rating: %s" % Numb) Ttls = (("Director", "\s*Director:\s*"), ("Stars", "\s*Stars:\s*"), ("Writers", "\s*Writers:\s*"), ("Writer", "\s*Writer:\s*")) @@ -355,9 +461,11 @@ class expansion_temp(expansion): else: Req = (body if chr(42) != c1st else body[2:].strip()) Req = Req.encode("utf-8") - Req = Web("http://www.imdb.com/find?", [("s", "tt"), ("q", Req)]) + Req = Web("http://www.imdb.com/find?", [("s", "tt"), ("q", Req)], self.IMDbHeaders) try: data = Req.get_page(self.UserAgent_Moz) + except Web.Two.HTTPError, exc: + answer = str(exc) except: answer = self.AnsBase[0] else: @@ -382,6 +490,8 @@ class expansion_temp(expansion): Req = Web("http://python.org/") try: data = Req.get_page(self.UserAgent) + except Web.Two.HTTPError, exc: + answer = str(exc) except: answer = self.AnsBase[0] else: @@ -398,6 +508,91 @@ class expansion_temp(expansion): answer = self.AnsBase[1] Answer(answer, ltype, source, disp) + if DefLANG in ("RU", "UA"): + + def command_chuck(self, ltype, source, body, disp): + if body and isNumber(body): + Req = Web("http://chucknorrisfacts.ru/quote/%d" % int(body)) + else: + Req = Web("http://chucknorrisfacts.ru/random") + try: + data = Req.get_page(self.UserAgent) + except Web.Two.HTTPError, exc: + answer = str(exc) + except: + answer = self.AnsBase[0] + else: + data = data.decode("cp1251") + comp = compile__("<a href=/quote/(\d+?)>.+?<blockquote>(.+?)</blockquote>", 16) + data = comp.search(data) + if data: + answer = self.decodeHTML("Fact: #%s\n%s" % data.groups()) + else: + answer = self.AnsBase[1] + Answer(answer, ltype, source, disp) + + def command_bash(self, ltype, source, body, disp): + if body and isNumber(body): + Req = Web("http://bash.im/quote/%d" % int(body)) + else: + Req = Web("http://bash.im/random") + try: + data = Req.get_page(self.UserAgent) + except Web.Two.HTTPError, exc: + answer = str(exc) + except: + answer = self.AnsBase[0] + else: + data = data.decode("cp1251") + comp = compile__('<span id="v\d+?" class="rating">(.+?)</span>(?:.|\s)+?<a href="/quote/\d+?" class="id">#(\d+?)</a>\s*?</div>\s+?<div class="text">(.+?)</div>', 16) + data = comp.search(data) + if data: + answer = self.decodeHTML("#{1} +[{0}]-\n{2}".format(*data.groups())) + else: + answer = self.AnsBase[1] + Answer(answer, ltype, source, disp) + + else: + + def command_chuck(self, ltype, source, body, disp): + Req = Web("http://www.chucknorrisfacts.com/all-chuck-norris-facts?page=%d" % randrange(974)) # 04:12 09.11.2012 by UTC number of pages was 974 + try: + data = Req.get_page(self.UserAgent) + except Web.Two.HTTPError, exc: + answer = str(exc) + except: + answer = self.AnsBase[0] + else: + data = data.decode("utf-8") + comp = compile__("<span class=\"field-content\"><a.*?>(.+?)</a></span>", 16) + list = comp.findall(data) + if list: + answer = self.decodeHTML(choice(list)) + else: + answer = self.AnsBase[1] + Answer(answer, ltype, source, disp) + + def command_bash(self, ltype, source, body, disp): + if body and isNumber(body): + Req = Web("http://bash.org/?%d" % int(body)) + else: + Req = Web("http://bash.org/?random") + try: + data = Req.get_page(self.UserAgent) + except Web.Two.HTTPError, exc: + answer = str(exc) + except: + answer = self.AnsBase[0] + else: + data = data.decode("iso-8859-1") + comp = compile__('<b>#(\d+?)</b></a>\s<a.*?>\+</a>\((.+?)\)<a.*?>-</a>\s<a.*?>\[X\]</a></p><p class="qt">(.+?)</p>', 16) + data = comp.search(data) + if data: + answer = self.decodeHTML("#%s +[%s]-\n%s" % data.groups()) + else: + answer = self.AnsBase[1] + Answer(answer, ltype, source, disp) + def command_currency(self, ltype, source, body, disp): if body: ls = body.split() @@ -415,7 +610,7 @@ class expansion_temp(expansion): if ltype == Types[1]: Answer(AnsBase[11], ltype, source, disp) Curls = ["\->"] + ["%s: %s" % desc for desc in sorted(self.Currency_desc.items())] - Msend(source[0], str.join(chr(10), Curls), disp) + Message(source[0], str.join(chr(10), Curls), disp) elif Code in ("calc", "перевести".decode("utf-8")): if len(ls) >= 2: Number = ls.pop(0) @@ -428,6 +623,8 @@ class expansion_temp(expansion): Req = Web("http://www.cbr.ru/scripts/XML_daily.asp") try: data = Req.get_page(self.UserAgent) + except Web.Two.HTTPError, exc: + answer = str(exc) except: answer = self.AnsBase[0] else: @@ -458,6 +655,8 @@ class expansion_temp(expansion): Req = Web("http://www.cbr.ru/scripts/XML_daily.asp") try: data = Req.get_page(self.UserAgent) + except Web.Two.HTTPError, exc: + answer = str(exc) except: answer = self.AnsBase[0] else: @@ -477,6 +676,8 @@ class expansion_temp(expansion): Req = Web("http://www.cbr.ru/scripts/XML_daily.asp") try: data = Req.get_page(self.UserAgent) + except Web.Two.HTTPError, exc: + answer = str(exc) except: answer = self.AnsBase[0] else: @@ -490,7 +691,7 @@ class expansion_temp(expansion): if ltype == Types[1]: Answer(AnsBase[11], ltype, source, disp) Curls = str.join(chr(10), ls) - Msend(source[0], Curls, disp) + Message(source[0], Curls, disp) else: answer = self.AnsBase[1] if locals().has_key(Types[12]): @@ -503,6 +704,8 @@ class expansion_temp(expansion): Req = Web("http://jabber-quotes.ru/api/read/?id=random") try: data = Req.get_page(self.UserAgent) + except Web.Two.HTTPError, exc: + answer = str(exc) except: answer = self.AnsBase[0] else: @@ -519,25 +722,6 @@ class expansion_temp(expansion): answer = self.AnsBase[1] Answer(answer, ltype, source, disp) - def command_chuck(self, ltype, source, body, disp): - if body and isNumber(body): - Req = Web("http://chucknorrisfacts.ru/quote/%d" % int(body)) - else: - Req = Web("http://chucknorrisfacts.ru/random") - try: - data = Req.get_page(self.UserAgent) - except: - answer = self.AnsBase[0] - else: - data = data.decode("cp1251") - comp = compile__("<a href=/quote/(\d+?)>.+?<blockquote>(.+?)</blockquote>", 16) - data = comp.search(data) - if data: - answer = self.decodeHTML("Fact: #%s\n%s" % data.groups()) - else: - answer = self.AnsBase[1] - Answer(answer, ltype, source, disp) - def command_ithappens(self, ltype, source, body, disp): if body and isNumber(body): Req = Web("http://ithappens.ru/story/%d" % int(body)) @@ -545,6 +729,8 @@ class expansion_temp(expansion): Req = Web("http://ithappens.ru/random") try: data = Req.get_page(self.UserAgent) + except Web.Two.HTTPError, exc: + answer = str(exc) except: answer = self.AnsBase[0] else: @@ -570,6 +756,8 @@ class expansion_temp(expansion): Req = Web("http://m.gismeteo.ru/citysearch/by_name/?", [("gis_search", City.encode("utf-8"))]) try: data = Req.get_page(self.UserAgent) + except Web.Two.HTTPError, exc: + answer = str(exc) except: answer = self.AnsBase[0] else: @@ -581,6 +769,8 @@ class expansion_temp(expansion): Req = Web("http://m.gismeteo.ru/weather/%s/" % data) try: data = Req.get_page(self.UserAgent) + except Web.Two.HTTPError, exc: + answer = str(exc) except: answer = self.AnsBase[0] else: @@ -619,8 +809,11 @@ class expansion_temp(expansion): commands = ( (command_jc, "jc", 2,), (command_google, "google", 2,), + (command_google_translate, "tr", 2,), (command_imdb, "imdb", 2,), - (command_python, "python", 2,) + (command_python, "python", 2,), + (command_chuck, "chuck", 2,), + (command_bash, "bash", 2,) ) if DefLANG in ("RU", "UA"): @@ -628,13 +821,12 @@ class expansion_temp(expansion): (command_kino, "kino", 2,), (command_currency, "currency", 2,), (command_jquote, "jquote", 2,), - (command_chuck, "chuck", 2,), (command_ithappens, "ithappens", 2,), (command_gismeteo, "gismeteo", 2,) )) Currency_desc = Currency_desc else: - del command_kino, command_currency, command_jquote, command_chuck, command_ithappens, command_gismeteo + del kinoHeaders, C3oP, command_kino, command_currency, command_jquote, command_ithappens, command_gismeteo if DefLANG in ("RU", "UA"): del Currency_desc diff --git a/expansions/allweb/insc.py b/expansions/allweb/insc.py index e157a94..e91ddfa 100644 --- a/expansions/allweb/insc.py +++ b/expansions/allweb/insc.py @@ -14,10 +14,33 @@ if DefLANG in ("RU", "UA"): "Не вижу твоего JID'а, поэтому не могу найти твоих запросов в базе.", # 3 "\n\n** Ещё %d результатов (командуй «гугл *»).", # 4 "Ничего не найдено...", # 5 + "Этот язык не поддерживается.", # 6 + "\n\n** Ещё %d вариантов перевода (командуй «перевод *»).", # 7 + "Поддерживаемые языки:\n", # 8 "\n* Погода предоставлена Gismeteo.ru", # -2 "Запрос блокирован Кинопоиском." # -1 )]) + LangMap = { + "af": "Африкаанс", "ar": "Арабский", "be": "Белорусский", + "bg": "Болгарский", "ca": "Каталанский", "cs": "Чешский", + "cy": "Валлийский", "da": "Датский", "de": "Немецкий", + "el": "Греческий", "en": "Английский", "es": "Испанский", + "et": "Эстонский", "fa": "Персидский", "fi": "Финский", + "fr": "Французский", "ga": "Ирландский", "gl": "Галисийский", + "hi": "Хинди", "hr": "Хорватский", "hu": "Венгерский", + "id": "Индонезийский", "is": "Исландский", "it": "Итальянский", + "iw": "Иврит", "ja": "Японский", "ko": "Корейский", + "la": "Латынь", "lt": "Литовский", "lv": "Латышский", + "mk": "Македонский", "mt": "Мальтийский", "nl": "Голландский", + "no": "Норвежский", "pl": "Польский", "pt": "Португальский", + "ro": "Румынский", "ru": "Русский", "sk": "Словацкий", + "sl": "Словенский", "sq": "Албанский", "sr": "Сербский", + "sv": "Шведский", "sw": "Суахили", "th": "Тайский", + "tl": "Тагальский", "tr": "Турецкий", "uk": "Украинский", + "vi": "Вьетнамский", "yi": "Идиш", "zh-CN": "Китайский" + } + Currency_desc = { "AMD": "Армянский драм", "AUD": "Австралийский доллар ($)", @@ -60,8 +83,31 @@ else: AnsBase_temp = ( "No access to the page.", # 0 "Trouble with the marking...", # 1 - "There are no your requests in cache.", # 2 - "I can't find your requests in cache, because I don't know your JID.", # 3 + "There are no your requests in the cache.", # 2 + "I can't find your requests in the cache, because I don't know your JID.", # 3 '\n\n** There are %d another results (type "google *").', # 4 - "No result..." # 5 - )
\ No newline at end of file + "No result...", # 5 + "This language is not supported.", # 6 + '\n\n** There are %d another translations (type "tr *").', # 7 + "Supported languages:\n" # 8 + ) + + LangMap = { + "af": "Afrikaans", "ar": "Arabic", "be": "Byelorussian", + "bg": "Bulgarian", "ca": "Catalan", "cs": "Czech", + "cy": "Welsh", "da": "Danish", "de": "German", + "el": "Greek", "en": "English", "es": "Spanish", + "et": "Estonian", "fa": "Persian", "fi": "Finnish", + "fr": "French", "ga": "Irish", "gl": "Galician", + "hi": "Hindi", "hr": "Croatian", "hu": "Hungarian", + "id": "Indonesian", "is": "Icelandic", "it": "Italian", + "iw": "Hebrew", "ja": "Japanese", "ko": "Korean", + "la": "Latin", "lt": "Lithuanian", "lv": "Latvian", + "mk": "Macedonian", "mt": "Maltese", "nl": "Dutch", + "no": "Norwegian", "pl": "Polish", "pt": "Portuguese", + "ro": "Romanian", "ru": "Russian", "sk": "Slovak", + "sl": "Slovenian", "sq": "Albanian", "sr": "Serbian", + "sv": "Swedish", "sw": "Swahili", "th": "Thai", + "tl": "Tagalog", "tr": "Turkish", "uk": "Ukrainian", + "vi": "Vietnamese", "yi": "Yiddish", "zh-CN": "Chinese" + }
\ No newline at end of file diff --git a/expansions/allweb/jc.en b/expansions/allweb/jc.en index 6476517..3cd2d6b 100644 --- a/expansions/allweb/jc.en +++ b/expansions/allweb/jc.en @@ -1,6 +1,6 @@ -chat's raiting from jc.jabber.ru
+chat's rating from jc.jabber.ru
jc (conference)
*/jc
-bot would show raiting of current chatroom
+bot would show rating of current chatroom
*/jc support
-bot would show support's raiting
\ No newline at end of file +bot would show support's rating
\ No newline at end of file diff --git a/expansions/allweb/tr.en b/expansions/allweb/tr.en new file mode 100644 index 0000000..1fed702 --- /dev/null +++ b/expansions/allweb/tr.en @@ -0,0 +1,10 @@ +google translate
+tr (lang_from/auto/*) (lang_to) (text)
+*/tr
+bot would show supported languages
+*/tr en ru hello world
+bot would translate "hello world" to russian
+*/tr auto ru hello world
+lang_from would detected automatically
+*/tr *
+bot would show next translation
\ No newline at end of file diff --git a/expansions/allweb/tr.name b/expansions/allweb/tr.name new file mode 100644 index 0000000..763cff5 --- /dev/null +++ b/expansions/allweb/tr.name @@ -0,0 +1,4 @@ +{
+ "RU": "перевод",
+ "UA": "перевод"
+}
\ No newline at end of file diff --git a/expansions/allweb/tr.ru b/expansions/allweb/tr.ru new file mode 100644 index 0000000..c1897fe --- /dev/null +++ b/expansions/allweb/tr.ru @@ -0,0 +1,10 @@ +перевод с помощью google
+перевод (язык_оригинала/auto/*) (язык_перевода) (текст)
+*/перевод
+бот покажет поддерживаемые языки
+*/перевод ru en привет мир
+бот переведёт "привет мир" на английский
+*/перевод auto ru привет мир
+язык оригинала будет определён автоматически
+*/перевод *
+бот покажет следующий вариант перевода
\ No newline at end of file diff --git a/expansions/basic_control/code.py b/expansions/basic_control/code.py index 8e2c7f2..53e96d1 100644 --- a/expansions/basic_control/code.py +++ b/expansions/basic_control/code.py @@ -69,7 +69,7 @@ class expansion_temp(expansion): Chats[conf].join() self.Chat_check(conf) if Chats.has_key(conf) and Chats[conf].IamHere: - Msend(conf, self.AnsBase[7] % (ProdName, source[2]), disp_) + Message(conf, self.AnsBase[7] % (ProdName, source[2]), disp_) answer = self.AnsBase[2] % (conf) else: answer = self.AnsBase[3] % (conf) @@ -118,7 +118,7 @@ class expansion_temp(expansion): if GodName != source_: delivery(self.AnsBase[4] % (source[2], source_, conf)) info = self.AnsBase[9] % (source[2]) - Msend(conf, info, Chats[conf].disp) + Message(conf, info, Chats[conf].disp) time.sleep(2) Chats[conf].full_leave(info) if conf != source[1]: @@ -169,7 +169,7 @@ class expansion_temp(expansion): if body: exit_desclr += self.AnsBase[1] % (body) for conf in Chats.keys(): - Msend(conf, exit_desclr, Chats[conf].disp) + Message(conf, exit_desclr, Chats[conf].disp) time.sleep(6) VarCache["alive"] = False iThr.Threads_kill() @@ -184,7 +184,7 @@ class expansion_temp(expansion): if body: exit_desclr += self.AnsBase[1] % (body) for conf in Chats.keys(): - Msend(conf, exit_desclr, Chats[conf].disp) + Message(conf, exit_desclr, Chats[conf].disp) time.sleep(6) VarCache["alive"] = False iThr.Threads_kill() diff --git a/expansions/basic_control/insc.py b/expansions/basic_control/insc.py index 139d198..3cf4537 100644 --- a/expansions/basic_control/insc.py +++ b/expansions/basic_control/insc.py @@ -36,9 +36,9 @@ else: "I came out from -> '%s'", # 10 "Restart by command from %s", # 11 "Shutdown by command from %s", # 12 - "I added this conference in to chat-list and I'll retry to join it. If you not sure that this server exists - you should to type leave command.", # 13 + "I added this conference in to chats-list and I'll retry to join it. If you not sure that this server exists - you should to type leave-command.", # 13 "I can't. Client which assigned to this conference - currently offline.", # 14 - "Unable to create directory, probably '%s' contains invalid characters. Accordingly, I can't serve this conference.", # 15 + "Unable to create a directory, probably '%s' contains an invalid characters. Accordingly, I can't serve this conference.", # 15 "The system can not allocate resources to another client.", # 16 - "'%s' not in clients list." # 17 + "'%s' not in the clients-list." # 17 )
\ No newline at end of file diff --git a/expansions/books/code.py b/expansions/books/code.py index b1e5b8e..df89245 100644 --- a/expansions/books/code.py +++ b/expansions/books/code.py @@ -175,7 +175,7 @@ class expansion_temp(expansion): ls.append("Link: %s" % (link)) if Annt: ls.append("Annotation:\n\t%s" % (Annt)) - ls.append("\nAdded by: %s (Last Up.: %s)" % (Nick, Date)) + ls.append("\nAdded by: %s (The Last Upd.: %s)" % (Nick, Date)) answer = str.join(chr(10), ls) else: answer = self.AnsBase[3] @@ -224,7 +224,7 @@ class expansion_temp(expansion): if data: if ltype == Types[1]: answer = AnsBase[11] - Msend(source[0], data[0], disp) + Message(source[0], data[0], disp) if jid: with database(self.ReadersFile) as db: db("select * from readers where jid=?", (jid,)) diff --git a/expansions/books/insc.py b/expansions/books/insc.py index 4bb71e2..005f447 100644 --- a/expansions/books/insc.py +++ b/expansions/books/insc.py @@ -29,11 +29,11 @@ else: "I can't find your bookmark, because I don't know your JID.", # 5 "The last page is %d.", # 6 "The book is empty.", # 7 - "There are %d books in library.", # 8 + "There are %d books in the library.", # 8 "File is not exist.", # 9 "Already in.", # 10 "Added with id='%s'.", # 11 - "No such data field in base.", # 12 + "No such data field in the base.", # 12 "Incorrect page number.", # 13 "No such page.", # 14 "Incorrect name." # 15 diff --git a/expansions/bot_sends/code.py b/expansions/bot_sends/code.py index d3b153d..808e9be 100644 --- a/expansions/bot_sends/code.py +++ b/expansions/bot_sends/code.py @@ -50,7 +50,7 @@ class expansion_temp(expansion): def command_sendall(self, ltype, source, body, disp): if body: for conf in Chats.keys(): - Msend(conf, self.AnsBase[5] % (source[2], body)) + Message(conf, self.AnsBase[5] % (source[2], body)) answer = AnsBase[4] else: answer = AnsBase[1] @@ -61,7 +61,7 @@ class expansion_temp(expansion): if Chats[source[1]].more: body = "[&&] %s" % (Chats[source[1]].more) Chats[source[1]].more = "" - Msend(source[1], body, disp) + Message(source[1], body, disp) else: Answer(AnsBase[0], ltype, source, disp) @@ -73,7 +73,7 @@ class expansion_temp(expansion): if isSource(sTo): conf = (sTo.split(chr(47)))[0].lower() if Chats.has_key(conf) or not conf.count("@conf"): - Msend(sTo, self.AnsBase[5] % (source[2], body[(body.find(sTo) + len(sTo)):].strip())) + Message(sTo, self.AnsBase[5] % (source[2], body[(body.find(sTo) + len(sTo)):].strip())) answer = AnsBase[4] else: answer = AnsBase[8] @@ -100,9 +100,9 @@ class expansion_temp(expansion): def command_say(self, ltype, source, body, disp): if body: if ConfLimit >= len(body): - Msend(source[1], body, disp) + Message(source[1], body, disp) else: - Msend(source[1], body[:ConfLimit], disp) + Message(source[1], body[:ConfLimit], disp) else: Answer(AnsBase[1], ltype, source, disp) diff --git a/expansions/bot_sends/insc.py b/expansions/bot_sends/insc.py index e5ede13..955d628 100644 --- a/expansions/bot_sends/insc.py +++ b/expansions/bot_sends/insc.py @@ -18,8 +18,8 @@ else: "cleaning conference...", # 0 "I am okay! (0 errors)", # 1 "Private %s is seriously injured, but I have the rotation! (%d errors)", # 2 - "I am dead man, brother, escape, I will delay them... (%d errors)", # 3 - "At these addresses, I can not send messages.", # 4 + "I am a dead man, brother, you should escape, I'll delay them... (%d errors)", # 3 + "At these target, I can't send messages.", # 4 "Message from %s:\n%s", # 5 "'%s' is here now.", # 6 "Unknown target.", # 7 diff --git a/expansions/bot_sends/send.en b/expansions/bot_sends/send.en index aac3490..0abe27a 100644 --- a/expansions/bot_sends/send.en +++ b/expansions/bot_sends/send.en @@ -1,4 +1,4 @@ bot sends message in to specified jid
send [jid] [text]
*/send chel@jabber.com AAA!!
-bot would send "!!" to chel@jabber.com as: [Message from <your nick/resource>:][new line][!!]
\ No newline at end of file +bot would send "AAA!!" to chel@jabber.com as: [Message from <your nick/resource>:][new line][AAA!!]
\ No newline at end of file diff --git a/expansions/config/code.py b/expansions/config/code.py index 434b930..f9db272 100644 --- a/expansions/config/code.py +++ b/expansions/config/code.py @@ -59,7 +59,7 @@ class expansion_temp(expansion): else: if ltype == Types[1]: Answer(AnsBase[11], ltype, source, disp) - Msend(source[0], self.get_config(GenCon, self.AnsBase[2]), disp) + Message(source[0], self.get_config(GenCon, self.AnsBase[2]), disp) if locals().has_key(Types[12]): Answer(answer, ltype, source, disp) @@ -102,7 +102,7 @@ class expansion_temp(expansion): for conf in Chats.keys(): if Chats[conf].disp == Name: if online(Name): - Msend(conf, self.AnsBase[4], Name) + Message(conf, self.AnsBase[4], Name) time.sleep(0.2) Chats[conf].leave(self.AnsBase[5]) Chats[conf].disp = IdleClient() @@ -225,7 +225,7 @@ class expansion_temp(expansion): else: if ltype == Types[1]: Answer(AnsBase[11], ltype, source, disp) - Msend(source[0], self.get_config(ConDisp, self.AnsBase[2]), disp) + Message(source[0], self.get_config(ConDisp, self.AnsBase[2]), disp) if locals().has_key(Types[12]): Answer(answer, ltype, source) diff --git a/expansions/config/insc.py b/expansions/config/insc.py index 67840ff..6cd2a38 100644 --- a/expansions/config/insc.py +++ b/expansions/config/insc.py @@ -21,12 +21,12 @@ else: "Parameters are incorrect.", # 1 "Config:\n", # 2 "Config is empty.", # 3 - "Attention! Current jid deleting, now. I'll rejoin with new.", # 4 + "Attention! Current jid deleting now. I'll rejoin with new.", # 4 "jid change", # 5 - "'%s' - my main JID, now.", # 6 + "'%s' - my main JID now.", # 6 "Forbidden!", # 7 "The system can not allocate resources to another client.", # 8 "No connection.", # 9 "This jid is already in list.", # 10 - "'%s' not in clients list." # 11 + "'%s' not in clients-list." # 11 )
\ No newline at end of file diff --git a/expansions/cron/insc.py b/expansions/cron/insc.py index 9bf70a0..f1d2b5a 100644 --- a/expansions/cron/insc.py +++ b/expansions/cron/insc.py @@ -24,5 +24,5 @@ else: "It will be executed at %s.", # 6 "There are no tasks.", # 7 "\n[#][ID][Command][Deadline]\n%s", # 8 - "Date/Time are incorrect." # 9 + "Date/Time is incorrect." # 9 )
\ No newline at end of file diff --git a/expansions/exp_control/insc.py b/expansions/exp_control/insc.py index 2454dc9..e91bbf6 100644 --- a/expansions/exp_control/insc.py +++ b/expansions/exp_control/insc.py @@ -30,15 +30,15 @@ else: "\nCommands: %s", # 4 "\nHandlers: %s", # 5 "not loaded", # 6 - "Also, this expansion isn't exists.", # 7 + "Also, this expansion isn't exist.", # 7 "\n[#][Name][codefile][langfile]", # 8 "\n\n## Not loaded (%d) ->\n\n%s", # 9 "%s - successfully loaded!", # 10 "Can't load - %s!%s", # 11 - "Somebody deleted codefile!", # 12 + "Somebody deleted code-file!", # 12 "%s was coded incorrectly. Loading aborted.", # 13 - "This func. isn't registred.\n## Function list: %s", # 14 - "There is no registred functions in %s", # 15 + "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 )
\ No newline at end of file diff --git a/expansions/get_iq/code.py b/expansions/get_iq/code.py index 8d5bf8f..51105b2 100644 --- a/expansions/get_iq/code.py +++ b/expansions/get_iq/code.py @@ -71,9 +71,7 @@ class expansion_temp(expansion): else: source_ = get_source(source[1], source[2]) if source_ and self.PingStat.has_key(source_): - Number = 0.0 - for x in self.PingStat[source_]: - Number += x + Number = float(sum(self.PingStat[source_])) len_ = len(self.PingStat[source_]) max_ = max(self.PingStat[source_]) min_ = min(self.PingStat[source_]) @@ -196,30 +194,27 @@ class expansion_temp(expansion): def answer_afls(self, disp, stanza, ltype, source, Numb): if xmpp.isResultNode(stanza): - list = stanza.getChildren() - if list: - Number, answer = itypes.Number(), str() - for child in list[0].getChildren(): - if child and child != "None": - jid = child.getAttr("jid") + Number, answer = itypes.Number(), str() + for node in stanza.getChildren(): + for node in node.getChildren(): + if node and node != "None": + jid = node.getAttr("jid") if jid: if Numb and Numb <= Number._int(): Number.plus() else: answer += "\n%d) %s" % (Number.plus(), jid) - signature = child.getTagData("reason") + signature = node.getTagData("reason") if signature: answer += " [%s]" % (signature) - if answer: - if Numb and Numb < Number._int(): - answer += "\n...\nTotal: %s items." % (Number._str()) - Msend(source[0], answer, disp) - if ltype == Types[1]: - answer = AnsBase[11] - else: - del answer + if answer: + if Numb and Numb < Number._int(): + answer += "\n...\nTotal: %s items." % (Number._str()) + Message(source[0], answer, disp) + if ltype == Types[1]: + answer = AnsBase[11] else: - answer = self.AnsBase[6] + del answer else: answer = self.AnsBase[6] else: diff --git a/expansions/help/code.py b/expansions/help/code.py index fba4ab0..934a8cd 100644 --- a/expansions/help/code.py +++ b/expansions/help/code.py @@ -102,7 +102,7 @@ class expansion_temp(expansion): answer += self.AnsBase[16] % (access) if ltype == Types[1]: Answer(AnsBase[11], ltype, source, disp) - Msend(source[0], answer, disp) + Message(source[0], answer, disp) commands = ( (command_location, "location", 1,), diff --git a/expansions/help/insc.py b/expansions/help/insc.py index 42d0205..ff5b105 100644 --- a/expansions/help/insc.py +++ b/expansions/help/insc.py @@ -23,13 +23,13 @@ if DefLANG in ("RU", "UA"): )]) else: AnsBase_temp = ( - "Command '%s' located in expansion %s", # 0 + "Command '%s' is located in expansion %s", # 0 "%s's access - %d.", # 1 "\n%s\nSyntax:\n*** %s", # 2 "\nExamples:", # 3 - "Help-file for this command isn't exists...", # 4 - "Type 'commands' for a complete list of commands, type 'help [command]', to know how it works.", # 5 - "Full command list%s", # 6 + "Help-file for this command isn't exist...", # 4 + "Type 'commands' to get the complete list of commands, type 'help [command]', to know how it works.", # 5 + "Full commands-list%s", # 6 " (Command prefix - '%s'):", # 7 "\n\n# Superadmin's commands [access 8] - %s:\n%s", # 8 "\n\n# Global Admin's commands [access 7] - %s:\n%s", # 9 diff --git a/expansions/info/code.py b/expansions/info/code.py index b1e8568..2613654 100644 --- a/expansions/info/code.py +++ b/expansions/info/code.py @@ -21,7 +21,7 @@ class expansion_temp(expansion): list += "\n%d) %s - %s - %s" % (Numb.plus(), disp_, str(connect), alive) if ltype == Types[1]: Answer(AnsBase[11], ltype, source, disp) - Msend(source[0], list, disp) + Message(source[0], list, disp) def command_inchat(self, ltype, source, body, disp): if Chats.has_key(source[1]): @@ -58,7 +58,7 @@ class expansion_temp(expansion): list += "\n%d) %s" % (Numb.plus(), x) if ltype == Types[1]: Answer(AnsBase[11], ltype, source, disp) - Msend(source[0], list, disp) + Message(source[0], list, disp) else: Answer(AnsBase[0], ltype, source, disp) @@ -78,7 +78,7 @@ class expansion_temp(expansion): if Numb._int(): if ltype == Types[1]: Answer(AnsBase[11], ltype, source, disp) - Msend(source[0], answer, disp) + Message(source[0], answer, disp) else: Answer(self.AnsBase[6], ltype, source, disp) @@ -105,7 +105,7 @@ class expansion_temp(expansion): if Numb._int(): if ltype == Types[1]: Answer(AnsBase[11], ltype, source, disp) - Msend(source[0], self.AnsBase[0] % (Numb._str(), list, Numb2._str()), disp) + Message(source[0], self.AnsBase[0] % (Numb._str(), list, Numb2._str()), disp) else: Answer(self.AnsBase[1], ltype, source, disp) elif Var in ("dates", "даты".decode("utf-8")): @@ -115,12 +115,12 @@ class expansion_temp(expansion): list += "\n%d. %s\t\t%s" % (Numb.plus(), nick.nick, nick.date[2]) if ltype == Types[1]: Answer(AnsBase[11], ltype, source, disp) - Msend(source[0], self.AnsBase[2] % (Numb._str(), list), disp) + Message(source[0], self.AnsBase[2] % (Numb._str(), list), disp) elif Var in ("list", "лист".decode("utf-8")): ls = sorted(Chats[source[1]].get_nicks()) if ltype == Types[1]: Answer(AnsBase[11], ltype, source, disp) - Msend(source[0], self.AnsBase[2] % (str(len(ls)), ", ".join(ls)), disp) + Message(source[0], self.AnsBase[2] % (str(len(ls)), ", ".join(ls)), disp) else: list = str() Numb = itypes.Number() @@ -136,7 +136,7 @@ class expansion_temp(expansion): if Numb._int(): if ltype == Types[1]: Answer(AnsBase[11], ltype, source, disp) - Msend(source[0], self.AnsBase[3] % (Numb._str(), list, Numb2._str()), disp) + Message(source[0], self.AnsBase[3] % (Numb._str(), list, Numb2._str()), disp) else: Answer(self.AnsBase[4], ltype, source, disp) else: @@ -158,7 +158,7 @@ class expansion_temp(expansion): if Numb._int(): if ltype == Types[1]: Answer(AnsBase[11], ltype, source, disp) - Msend(source[0], self.AnsBase[9] % (Numb._str(), list), disp) + Message(source[0], self.AnsBase[9] % (Numb._str(), list), disp) else: answer = self.AnsBase[10] else: diff --git a/expansions/info/insc.py b/expansions/info/insc.py index e1af36a..8a061f3 100644 --- a/expansions/info/insc.py +++ b/expansions/info/insc.py @@ -17,14 +17,14 @@ if DefLANG in ("RU", "UA"): else: AnsBase_temp = ( "Today there were %s visitors here:%s\n+ %s are still here.", # 0 - "Today when I was still nobody came, everyone who was - are still here.", # 1 - "When I was still there were %s visitors here:\n%s", # 2 + "Today, when I was still, nobody came, everyone who was - are still here.", # 1 + "When I was still, there were %s visitors here:\n%s", # 2 "There were %s visitors here:%s\n+ %s are still here.", # 3 - "При мне ещё никто не выходил, все кто был досихпор здесь.", # 4 + "Nobody leaved, all users are steel here.", # 4 "[#] [Chat/Nick] [Jid] [Prefix] [Users] [Admin]", # 5 "The list of conferences is empty.", # 6 "[#][Client][Connected][isActive]", # 7 - "List of users:", # 8 + "Users-list:", # 8 "Total %s similar users:%s", # 9 "No result." # 10 )
\ No newline at end of file diff --git a/expansions/muc/code.py b/expansions/muc/code.py index 51d1c9e..431a443 100644 --- a/expansions/muc/code.py +++ b/expansions/muc/code.py @@ -52,7 +52,7 @@ class expansion_temp(expansion): text = "%s: %s" % (source[2], (body.pop(0)).strip()) else: text = "%s/%s" % (get_self_nick(source[1]), source[2]) - Chats[source[1]].outcast(jid, text, (ltype, source)) + Chats[source[1]].outcast(jid, text, (None, (ltype, source))) else: answer = AnsBase[7] else: @@ -91,7 +91,7 @@ class expansion_temp(expansion): text = "%s: %s" % (source[2], (body.pop(0)).strip()) else: text = "%s/%s" % (get_self_nick(source[1]), source[2]) - Chats[source[1]].none(jid, text, (ltype, source)) + Chats[source[1]].none(jid, text, (None, (ltype, source))) else: answer = AnsBase[7] else: @@ -130,7 +130,7 @@ class expansion_temp(expansion): text = "%s: %s" % (source[2], (body.pop(0)).strip()) else: text = "%s/%s" % (get_self_nick(source[1]), source[2]) - Chats[source[1]].member(jid, text, (ltype, source)) + Chats[source[1]].member(jid, text, (None, (ltype, source))) else: answer = AnsBase[7] else: @@ -169,7 +169,7 @@ class expansion_temp(expansion): text = "%s: %s" % (source[2], (body.pop(0)).strip()) else: text = "%s/%s" % (get_self_nick(source[1]), source[2]) - Chats[source[1]].admin(jid, text, (ltype, source)) + Chats[source[1]].admin(jid, text, (None, (ltype, source))) else: answer = AnsBase[7] else: @@ -208,7 +208,7 @@ class expansion_temp(expansion): text = "%s: %s" % (source[2], (body.pop(0)).strip()) else: text = "%s/%s" % (get_self_nick(source[1]), source[2]) - Chats[source[1]].owner(jid, text, (ltype, source)) + Chats[source[1]].owner(jid, text, (None, (ltype, source))) else: answer = AnsBase[7] else: @@ -246,7 +246,7 @@ class expansion_temp(expansion): text = "%s: %s" % (source[2], (body.pop(0)).strip()) else: text = "%s/%s" % (get_self_nick(source[1]), source[2]) - Chats[source[1]].kick(nick, text, (ltype, source)) + Chats[source[1]].kick(nick, text, (None, (ltype, source))) else: answer = AnsBase[7] else: @@ -284,7 +284,7 @@ class expansion_temp(expansion): text = "%s: %s" % (source[2], (body.pop(0)).strip()) else: text = "%s/%s" % (get_self_nick(source[1]), source[2]) - Chats[source[1]].visitor(nick, text, (ltype, source)) + Chats[source[1]].visitor(nick, text, (None, (ltype, source))) else: answer = AnsBase[7] else: @@ -321,7 +321,7 @@ class expansion_temp(expansion): text = "%s: %s" % (source[2], (body.pop(0)).strip()) else: text = "%s/%s" % (get_self_nick(source[1]), source[2]) - Chats[source[1]].participant(nick, text, (ltype, source)) + Chats[source[1]].participant(nick, text, (None, (ltype, source))) else: answer = AnsBase[7] else: @@ -358,7 +358,7 @@ class expansion_temp(expansion): text = "%s: %s" % (source[2], (body.pop(0)).strip()) else: text = "%s/%s" % (get_self_nick(source[1]), source[2]) - Chats[source[1]].moder(nick, text, (ltype, source)) + Chats[source[1]].moder(nick, text, (None, (ltype, source))) else: answer = AnsBase[7] else: @@ -372,6 +372,30 @@ class expansion_temp(expansion): if locals().has_key(Types[12]): Answer(answer, ltype, source, disp) + PerfDesc = {"done": 0, "fail": 0} + + def HandleFB(self, disp, stanza, desc): + if xmpp.isResultNode(stanza): + desc["done"] += 1 + else: + desc["fail"] += 1 + + def calcPerformance(self, desc): + cl = len(Chats.keys()) + for x in xrange(60): + time.sleep(0.2) + if cl <= sum(desc.values()): + break + sl = sum(desc.values()) + if cl > sl: + desc["none"] = (cl - sl) + answer = self.AnsBase[2] % desc + elif desc["fail"]: + answer = self.AnsBase[3] % desc + else: + answer = self.AnsBase[4] + return answer + def command_fullban(self, ltype, source, body, disp): if Chats.has_key(source[1]): if body: @@ -391,9 +415,10 @@ class expansion_temp(expansion): text = "%s: %s" % (source[2], (body.pop(0)).strip()) else: text = "%s/%s" % (get_self_nick(source[1]), source[2]) + desc = self.PerfDesc.copy() for conf in Chats.keys(): - Chats[conf].outcast(jid, text) - answer = AnsBase[4] + Chats[conf].outcast(jid, text, (self.HandleFB, {"desc": desc})) + answer = self.calcPerformance(desc) else: answer = AnsBase[7] else: @@ -417,9 +442,10 @@ class expansion_temp(expansion): else: jid = None if jid: + desc = self.PerfDesc.copy() for conf in Chats.keys(): - Chats[conf].none(jid) - answer = AnsBase[4] + Chats[conf].none(jid, handler = (self.HandleFB, {"desc": desc})) + answer = self.calcPerformance(desc) else: answer = AnsBase[7] else: diff --git a/expansions/muc/insc.py b/expansions/muc/insc.py index 4b44ae1..dfbfa94 100644 --- a/expansions/muc/insc.py +++ b/expansions/muc/insc.py @@ -3,10 +3,16 @@ if DefLANG in ("RU", "UA"): AnsBase_temp = tuple([line.decode("utf-8") for line in ( "Протоколы безопасности конференции запрещают мне выполнить твою команду.", # 0 - "Дай админа/модера, потом поговорим." # 1 + "Дай админа/модера, потом поговорим.", # 1 + "Задача выполнена в %(done)d, отклонена в %(fail)d, а также нет ответа из %(none)d конференций.", # 2 + "Задача выполнена в %(done)d, отклонена в %(fail)d конференциях.", # 3 + "Задача выполнена во всех конференциях." # 4 )]) else: AnsBase_temp = ( "Security protocols are prohibits this action.", # 0 - "I must to be admin/moder to do this." # 1 + "I must to be admin/moder, to do this.", # 1 + "The task is executed in %(done)d, rejected in %(fail)d, and no response from %(none)d conferences.", # 2 + "The task is executed in %(done)d, rejected in %(fail)d conferences.", # 3 + "The task is executed in all of the conferences." # 4 )
\ No newline at end of file diff --git a/expansions/note/code.py b/expansions/note/code.py index a4501ab..68d1594 100644 --- a/expansions/note/code.py +++ b/expansions/note/code.py @@ -102,7 +102,7 @@ class expansion_temp(expansion): Notes = (self.AnsBase[6] % (Notes)) if ltype == Types[1]: Answer(AnsBase[11], ltype, source, disp) - Msend(source[0], Notes, disp) + Message(source[0], Notes, disp) else: db("delete from note where jid=?", (source_,)) db.commit() diff --git a/expansions/note/insc.py b/expansions/note/insc.py index f4976a0..532086f 100644 --- a/expansions/note/insc.py +++ b/expansions/note/insc.py @@ -22,5 +22,5 @@ else: "This line is empty.", # 5 "Your notes:%s", # 6 "Recorded in line - %s.", # 7 - "This line is alredy empty." # 8 + "This line is already empty." # 8 )
\ No newline at end of file diff --git a/expansions/sconf_attrs/insc.py b/expansions/sconf_attrs/insc.py index fbbf4e8..ed4f337 100644 --- a/expansions/sconf_attrs/insc.py +++ b/expansions/sconf_attrs/insc.py @@ -20,17 +20,17 @@ if DefLANG in ("RU", "UA"): else: AnsBase_temp = ( "I can't, because '%s' is offline.", # 0 - "'%s' is alredy owned by this conferense.", # 1 + "'%s' is already owned by this conference.", # 1 "'%s' not in available clients.", # 2 "Jabber ID changing...", # 3 "My new nick is '%s'.", # 4 "My nick can't be longer than 16 symbols.", # 5 - "Prefix was deleted.", # 6 + "The prefix was deleted.", # 6 "So there is no prefix.", # 7 - "'%s' is prefix now here.", # 8 + "'%s' is prefix here now.", # 8 "So symbol '%s' is prefix here.", # 9 - "Unavalable symbol for prefix! Avalable: '%s'.", # 10 + "Unavailable symbol for prefix! Available: '%s'.", # 10 "'%s' is current prefix here.", # 11 - "Prefix wasn't set.", # 12 + "The prefix wasn't set.", # 12 "'%s' isn't a status." # 13 )
\ No newline at end of file diff --git a/expansions/session_stat/code.py b/expansions/session_stat/code.py index b091f3a..0406592 100644 --- a/expansions/session_stat/code.py +++ b/expansions/session_stat/code.py @@ -24,7 +24,7 @@ class expansion_temp(expansion): exc = "%s" % (exc) if ltype == Types[1]: Answer(AnsBase[11], ltype, source, disp) - Msend(source[0], exc, disp) + Message(source[0], exc, disp) except: answer = self.AnsBase[20] else: diff --git a/expansions/session_stat/insc.py b/expansions/session_stat/insc.py index 0e27e87..d890238 100644 --- a/expansions/session_stat/insc.py +++ b/expansions/session_stat/insc.py @@ -12,7 +12,7 @@ if DefLANG in ("RU", "UA"): "\n# Обслуживаю %d конференций", # 7 "\n# Зафиксировано %d пользователей", # 8 "", # 9 - "\n# Произошло %d ошибок и %s Dispatch Errors", # 10 + "\n# Произошло %d ошибок и %s Dispatch-Errors", # 10 "\n# Записей crash логов %s", # 11 "\n# Создано %s тредов, %d из них активно", # 12 "\n# Потрачено %.2f секунд процессора", # 13 @@ -28,9 +28,9 @@ if DefLANG in ("RU", "UA"): )]) else: AnsBase_temp = ( - "\n*// Session statistics (Pid: %d):", # 0 - "\n# Bot uptime %s", # 1 - "\n# Last working set %s", # 2 + "\n*// Session's statistics (Pid: %d):", # 0 + "\n# Bot's uptime %s", # 1 + "\n# The last working set %s", # 2 "\n# Obtained %s messages", # 3 "\n# Completed %s commands", # 4 "\n# Processed %s presences & %s iq-request", # 5 @@ -38,13 +38,13 @@ else: "\n# Serve %d conferences", # 7 "\n# Fixed %d users", # 8 "", # 9 - "\n# Happened %d exceptions & %s Dispatch Errors", # 10 + "\n# Happened %d exceptions & %s Dispatch-Errors", # 10 "\n# Wrote crash logs %s", # 11 "\n# Created %s threads, %d is now active", # 12 "\n# Used %.2f processor seconds", # 13 "\n# Used %s megabyte RAM", # 14 "\nBot's uptime: %s.", # 15 - "\nLast working set: %s.\nReloads (%s):\n%s.", # 16 + "\nThe last working set: %s.\nReloads (%s):\n%s.", # 16 " - Working without restarts!", # 17 "\nCommand '%s' usage statistics:\nTotal used - %s times (%d users).", # 18 "\n[#][Command][Used][Users used]", # 19 diff --git a/expansions/sheriff/code.py b/expansions/sheriff/code.py index adca226..fe6a716 100644 --- a/expansions/sheriff/code.py +++ b/expansions/sheriff/code.py @@ -1,8 +1,8 @@ # coding: utf-8 # BlackSmith mark.2 -exp_name = "sheriff" # /code.py v.x5 -# Id: 15~3a +exp_name = "sheriff" # /code.py v.x6 +# Id: 15~4a # Code © (2011) by WitcherGeralt [alkorgun@gmail.com] expansion_register(exp_name) @@ -21,7 +21,7 @@ class expansion_temp(expansion): Federal_Jail, Antiwipe = {}, {} - class rUser: + class rUser(object): def __init__(self): self.devoice = 0 @@ -192,16 +192,12 @@ class expansion_temp(expansion): access = 2 return (loy, access) + compile_link = compile__("(?:http[s]?|ftp|svn)://[^\s'\"<>]+", 64) + compile_chat = compile__("[^\s]+?@(?:conference|muc|chat|room)\.[\w-]+?\.[\w-]+", 64) + def tiser_checker(self, body): body = body.lower() - c1, c2 = 0, 0 - for dkey in ("@", "conf", "ence"): - if body.count(dkey): - c1 += 1 - for dkey in ("http", "//", "www"): - if body.count(dkey): - c2 += 1 - if c1 == 3 or c2 > 1: + if self.compile_link.search(body) or self.compile_chat.search(body): return True return False @@ -225,14 +221,14 @@ class expansion_temp(expansion): def nick_checker(conf, nick): nick = nick.lower() - for dkey in ("%s", "%d", "%i", "%f"): + for dkey in ("%s", "%r", "%d", "%i", "%f", "/"): if nick.count(dkey): return True nick = nick.split()[0] - if nick in Cmds.keys(): + if Cmds.has_key(nick): return True if Chats[conf].cPref and nick.startswith(Chats[conf].cPref): - if nick[1:] in Cmds.keys(): + if Cmds.has_key(nick[1:]): return True return False @@ -259,7 +255,7 @@ class expansion_temp(expansion): elif prisoner.offenses == 3: Chats[source[1]].visitor(source[2], "%s: %s" % (get_self_nick(source[1]), body)) prisoner.SetDevoice() - Msend(source[0], self.AnsBase[16] % (body, ChatsAttrs[source[1]]["laws"]["dtime"]), disp) + Message(source[0], self.AnsBase[16] % (body, ChatsAttrs[source[1]]["laws"]["dtime"]), disp) raise iThr.ThrKill("exit") else: prisoner.SetDevoice() @@ -293,12 +289,12 @@ class expansion_temp(expansion): if prisoner.vakey == body.lower(): prisoner.Autenticated() Chats[source[1]].participant(source[2], self.AnsBase[20] % get_self_nick(source[1])) - Msend(source[0], self.AnsBase[21], disp) + Message(source[0], self.AnsBase[21], disp) elif prisoner.vnumb.plus() >= 3: prisoner.vnumb = itypes.Number() self.spesial_kick(source[1], source[2], self.AnsBase[22]) else: - Msend(source[0], self.AnsBase[23], disp) + Message(source[0], self.AnsBase[23], disp) raise iThr.ThrKill("exit") list = getattr(prisoner, "msdates") if len(list) >= 4: @@ -406,7 +402,7 @@ class expansion_temp(expansion): eTime = prisoner.GetDevoice() if (eTime < ChatsAttrs[conf]["laws"]["dtime"]): Chats[conf].visitor(nick, self.AnsBase[11] % get_self_nick(conf)) - Msend("%s/%s" % (conf, nick), self.AnsBase[14] % Time2Text(ChatsAttrs[conf]["laws"]["dtime"] - eTime), disp) + Message("%s/%s" % (conf, nick), self.AnsBase[14] % Time2Text(ChatsAttrs[conf]["laws"]["dtime"] - eTime), disp) else: prisoner.devoice = 0 else: @@ -421,7 +417,7 @@ class expansion_temp(expansion): ques = choice(self.AnsBase[19].splitlines()) ques = ques.split(chr(124), 1) prisoner.vakey = (ques[1].strip()).lower() - Msend("%s/%s" % (conf, nick), self.AnsBase[18] % (ques[0].strip()), disp) + Message("%s/%s" % (conf, nick), self.AnsBase[18] % (ques[0].strip()), disp) del ques list = getattr(prisoner, "prdates") if len(list) >= 4: diff --git a/expansions/sheriff/insc.py b/expansions/sheriff/insc.py index 88e6070..f0f0aeb 100644 --- a/expansions/sheriff/insc.py +++ b/expansions/sheriff/insc.py @@ -38,12 +38,12 @@ if DefLANG in ("RU", "UA"): "\nКонфигурация cлужбы безопасности:\nЗапрет пробелов на концах ника: ", # 24 "включена", # 25 "отключена", # 26 - "\nМаксимальная длинна ника: %d\nЗащита от вайпа: ", # 27 + "\nМаксимальная длина ника: %d\nЗащита от вайпа: ", # 27 "\nНомер кика за которым следует бан: %d\nАвторизация: ", # 28 "\nЛояльность: %d\nАнтиреклама: ", # 29 "\nВремя девойса (в секундах): %d\nАнтимат: ", # 30 - "\nМаксимальная длинна сообщения: %d\nАнтикапс: ", # 31 - "\nМаксимальная длинна презенса: %d\nРежим Спарты: ", # 32 + "\nМаксимальная длина сообщения: %d\nАнтикапс: ", # 31 + "\nМаксимальная длина презенса: %d\nРежим Спарты: ", # 32 "бляд/ блят/ бля / блять / плять /хуй/ ибал/ ебал/ хуи/хуител/хуя/ хую/ хуе/ ахуе/ охуе/хуев/ хер /хер/ пох / нах /писд/пизд/рizd/ пздц / еб/ епана / епать / ипать / выепать / ибаш/ уеб/проеб/праеб/приеб/съеб/взъеб/взьеб/въеб/вьеб/выебан/перееб/недоеб/долбоеб/долбаеб/ ниибац/ неебац/ неебат/ ниибат/ пидар/ рidаr/ пидар/ пидор/педор/пидор/пидарас/пидараз/ педар/педри/пидри/ заеп/ заип/ заеб/ебучий/ебучка /епучий/епучка / заиба/заебан/заебис/ выеб/выебан/ поеб/ наеб/ наеб/сьеб/взьеб/вьеб/ гандон/ гондон/пахуи/похуис/ манда /мандав/залупа/ залупог", # 33 "Сервер в белом списке.", # 34 "Сервера нет в дополнительном белом списке.", # 35 @@ -65,7 +65,7 @@ else: "%s: intruder.", # 11 "%s: antiwipe.", # 12 "presence flood.", # 13 - "Ooops! You earned devoice. Left %s.", # 14 + "Ooops! You have earned devoice. Left %s.", # 14 "flood.", # 15 "%s devoice in to %d seconds.", # 16 "%s verification.", # 17 @@ -90,9 +90,9 @@ else: "\nMax nickname length: %d\nAntiwipe: ", # 27 "\nNumber of the kick, after that ban follows: %d\nVerification: ", # 28 "\nLoyalty: %d\nAntiаdvertising: ", # 29 - "\nDevoice time (seconds): %d\nAntiobscene: ", # 30 - "\nMaximum message length: %d\nAnticaps: ", # 31 - "\nMaximum presence length: %d\nSparta mode: ", # 32 + "\nDevoice-time (seconds): %d\nAntiobscene: ", # 30 + "\nMaximum length of message: %d\nAnticaps: ", # 31 + "\nMaximum length of presence: %d\nSparta mode: ", # 32 " fuck / shit /motherfucker/unclefucker/ bitch / faggot / cock / cunt ", # 33 "Server already in the white list.", # 34 "Server not in extra white list.", # 35 diff --git a/expansions/sheriff/order.ru b/expansions/sheriff/order.ru index 98bdc79..c9d178d 100644 --- a/expansions/sheriff/order.ru +++ b/expansions/sheriff/order.ru @@ -25,9 +25,9 @@ */ордер девойс 360
время (в секундах) на которое участник будет лишен голоса за нарушения (от 60 до 360)
*/ордер мсглен 768
-максимальная длинна сообщения, разрешенная для пользователей (от 512 до 2048)
+максимальная длина сообщения, разрешенная для пользователей (от 512 до 2048)
*/ордер прзлен 256
-максимальная длинна статусного сообщения, разрешенная для пользователей (от 128 до 512)
+максимальная длина статусного сообщения, разрешенная для пользователей (от 128 до 512)
*/ордер сервера
бот покажет список "белых" серверов
*/ордер сервера + some_server.com
diff --git a/expansions/turn/code.py b/expansions/turn/code.py index 0830ea1..a4ca0b0 100644 --- a/expansions/turn/code.py +++ b/expansions/turn/code.py @@ -23,7 +23,7 @@ class expansion_temp(expansion): desc = {} for Nick in Chats[conf].get_nicks(): if Chats[conf].isHereTS(Nick): - for app in (["%s%s" % (Nick, Key) for Key in (":",",",">")] + [Nick]): + for app in (["%s%s" % (Nick, Key) for Key in (":", ",", ">")] + [Nick]): if body.count(app): Numb = "*%s*" % str(len(desc.keys()) + 1) desc[Numb] = app @@ -40,13 +40,13 @@ class expansion_temp(expansion): if Chats.has_key(source[1]): if body: - answer = "*\ %s" % Turn(source[1], body) + answer = "Turn\->\n" + Turn(source[1], body) else: source_ = get_source(source[1], source[2]) if source_ and self.TurnBase[source[1]].has_key(source_): (Time, body) = self.TurnBase[source[1]].pop(source_) body = "Turn\->\n[%s] <%s>: %s" % (Time, source[2], Turn(source[1], body)) - Msend(source[1], body, disp) + Message(source[1], body, disp) else: answer = AnsBase[7] else: diff --git a/expansions/user_stats/insc.py b/expansions/user_stats/insc.py index cd07397..d7d3229 100644 --- a/expansions/user_stats/insc.py +++ b/expansions/user_stats/insc.py @@ -12,8 +12,8 @@ if DefLANG in ("RU", "UA"): )]) else: AnsBase_temp = ( - "\nTotal joins - %d\nLast join time - %s\nLast role - %s", # 0 - "\nLast leave time - %s\nExit reason - %s", # 1 + "\nTotal joins - %d\nThe Last join-time - %s\nThe last role - %s", # 0 + "\nThe last leave-time - %s\nExit reason - %s", # 1 "\nNicks: %s", # 2 "No statistics.", # 3 "'%s' spent here - %s.", # 4 diff --git a/librarys.zip b/librarys.zip Binary files differindex 34330e4..fc0c2bf 100644 --- a/librarys.zip +++ b/librarys.zip diff --git a/static/insc.py b/static/insc.py index b659dba..27f0470 100644 --- a/static/insc.py +++ b/static/insc.py @@ -36,22 +36,22 @@ if DefLANG in ("RU", "UA"): )]) else: AnsBase = ( - "This command is available only in conferences.", # 0 + "This command is available only in the conferences.", # 0 "This command implies arguments using.", # 1 "Invalid syntax.", # 2 - "There is not '%s' in chats list.", # 3 + "There is no '%s' in the chats-list.", # 3 "Done.", # 4 "Parameters should be shorter.", # 5 - "Such command isn't exists.", # 6 + "Such command isn't exist.", # 6 "I can't.", # 7 - "There is not such conference in my list.", # 8 - "Type specified is incorrect.", # 9 + "There is no such conference in my list.", # 8 + "Type is invalid.", # 9 "You need to access higher.", # 10 - "You should to look in to your private.", # 11 + "You should look into private.", # 11 "# %d. - %s", # 12 "command '%s' (%s)", # 13 "prosess '%s'", # 14 - "When execut %s --> error was happend!", # 15 + "When execut %s --> error happend!", # 15 "Type --> 'excinfo %d' to show error (crashfile --> %s)", # 16 "Type --> 'excinfo %d' or 'sh cat %s' to show error", # 17 "%s[...]\n\n** %d symbols limit! Type 'more' to show rest of the text.", # 18 @@ -59,12 +59,12 @@ else: "Error %s (%s) - conference: '%s'.", # 20 "Error %s (%s), full exit from '%s'.", # 21 "Error %s (%s), I leaved '%s'.", # 22 - "Service without admin affilation is unavalable!", # 23 - "I Disable all functions until I'll become an admin!", # 24 + "The service without admin's affilation is unavalable!", # 23 + "I disable all functions until I'll become an admin!", # 24 "Obtaining rights...", # 25 "sCode '%s' in %s (%s). Full leave!", # 26 - "Type HELP to know more (last action - %s)", # 27 - "Client '%s' falled!", # 28 + "Type 'HELP' to know more (the last action - %s)", # 27 + "Client '%s' fell!", # 28 "JID '%s' used in another client! (I have to disconnect it)", # 29 "This is not a number." # 30 )
\ No newline at end of file |