diff options
author | Al Korgun <alkorgun@gmail.com> | 2013-01-02 21:02:48 +0400 |
---|---|---|
committer | Al Korgun <alkorgun@gmail.com> | 2013-01-02 21:02:48 +0400 |
commit | 9f0e0aedb78af87d4280e7134693430c481d01e8 (patch) | |
tree | 6e7e3b3b57836b49f4ebac01052b29c038b80c71 | |
parent | f5a9ee810d8215d7162f7f2faf0588c3a239e1f4 (diff) |
some modifications (the core now ready for "alias")
-rw-r--r-- | BlackSmith.py | 20 | ||||
-rw-r--r-- | expansions/access/code.py | 77 | ||||
-rw-r--r-- | expansions/access/insc.py | 8 | ||||
-rw-r--r-- | expansions/basic_control/code.py | 6 | ||||
-rw-r--r-- | expansions/books/code.py | 8 | ||||
-rw-r--r-- | expansions/bot_sends/code.py | 9 | ||||
-rw-r--r-- | expansions/cmd_control/code.py | 10 | ||||
-rw-r--r-- | expansions/config/code.py | 2 | ||||
-rw-r--r-- | expansions/cron/code.py | 61 | ||||
-rw-r--r-- | expansions/cron/insc.py | 4 | ||||
-rw-r--r-- | expansions/get_iq/code.py | 24 | ||||
-rw-r--r-- | expansions/note/code.py | 16 | ||||
-rw-r--r-- | expansions/note/insc.py | 2 | ||||
-rw-r--r-- | expansions/sheriff/code.py | 6 | ||||
-rw-r--r-- | expansions/wtf/code.py | 20 |
15 files changed, 125 insertions, 148 deletions
diff --git a/BlackSmith.py b/BlackSmith.py index b353419..b80cd46 100644 --- a/BlackSmith.py +++ b/BlackSmith.py @@ -264,7 +264,7 @@ GenConFile = static % ("config.ini") ConDispFile = static % ("clients.ini") ChatsFile = dynamic % ("chats.db") -(BsMark, BsVer, BsRev) = (2, 42, 0) +(BsMark, BsVer, BsRev) = (2, 43, 0) if os.access(SvnCache, os.R_OK): Cache = open(SvnCache).readlines() @@ -389,13 +389,13 @@ def composeThr(handler, Name, list = (), command = None): Name = "%s-%d" % (Name, iThr.aCounter._int()) return iThr.KThread(execute_handler, Name, (handler, list, command,)) -def Try_Thr(Thr, Number = 0): - if Number >= 4: +def StartThr(Thr, Number = 0): + if Number > 3: raise RuntimeError("exit") try: Thr.start() except iThr.error: - Try_Thr(Thr, (Number + 1)) + StartThr(Thr, (Number + 1)) except: collectExc(Thr.start) @@ -404,7 +404,7 @@ def sThread_Run(Thr, handler, command = None): Thr.start() except iThr.error: try: - Try_Thr(Thr) + StartThr(Thr) except RuntimeError: try: Thr._run_backup() @@ -1431,7 +1431,7 @@ def XmppIqCB(disp, stanza): class Macro: - __call__, __contains__ = None, lambda self, args: False + __call__, __contains__ = lambda self, *args: None, lambda self, args: False Macro = Macro() @@ -1499,11 +1499,9 @@ def XmppMessageCB(disp, stanza): command = None elif isToBs and command not in Cmds and (command, inst) not in Macro and command.startswith(cPrefs): command = command[1:] - if isConf: - if (command, inst) in Macro: - Macro(inst, command, stype, source, nick, temp, disp) - elif command in Chats[inst].oCmds: - xmpp_raise() + if isConf and command in Chats[inst].oCmds: + xmpp_raise() + Macro(inst, isConf, command, stype, source, nick, temp, disp) if command in Cmds: VarCache["action"] = AnsBase[27] % command.capitalize() VarCache["idle"] = time.time() diff --git a/expansions/access/code.py b/expansions/access/code.py index c24c622..282588d 100644 --- a/expansions/access/code.py +++ b/expansions/access/code.py @@ -1,8 +1,8 @@ # coding: utf-8 # BlackSmith mark.2 -# exp_name = "access" # /code.py v.x2 -# Id: 20~2c +# exp_name = "access" # /code.py v.x3 +# Id: 20~3c # Code © (2011) by WitcherGeralt [alkorgun@gmail.com] class expansion_temp(expansion): @@ -13,66 +13,63 @@ class expansion_temp(expansion): AccessFile = dynamic % ("access.db") ChatAccessFile = "access.db" - def command_get_access(self, stype, source, body, disp): + accessDesc = ( + "Visitor", # 0 + "Participant", # 1 + "Member", # 2 + "Moder", # 3 + "Member/Moder", # 4 + "Admin", # 5 + "Owner", # 6 + "Chief", # 7 + "God" # 8 + ) - def get_acc(access): - if access > 8: - access = "%d (Gandalf)" % (access) - elif access == 8: - access = "8 (God)" - elif access == 7: - access = "7 (Chief)" - else: - access = str(access) - return access + def get_acc(self, access): + if access > 8: + access = "%d (Gandalf)" % (access) + elif access < 0: + access = "%d (f7u12)" % (access) + else: + access = "%d (%s)" % (access, self.accessDesc[access]) + return access + def command_get_access(self, stype, source, body, disp): if not body: - answer = self.AnsBase[0] % get_acc(get_access(source[1], source[2])) + answer = self.AnsBase[0] % self.get_acc(get_access(source[1], source[2])) elif Chats.has_key(source[1]): if Chats[source[1]].isHere(body): - answer = self.AnsBase[1] % (body, get_acc(get_access(source[1], body))) + answer = self.AnsBase[1] % (body, self.get_acc(get_access(source[1], body))) elif Galist.has_key(body): - answer = self.AnsBase[1] % (body, get_acc(Galist.get(body, 0))) + answer = self.AnsBase[1] % (body, self.get_acc(Galist.get(body, 0))) elif Chats[source[1]].alist.has_key(body): answer = self.AnsBase[1] % (body, str(Chats[source[1]].alist.get(body, 0))) else: answer = self.AnsBase[2] % (body) elif Galist.has_key(body): - answer = self.AnsBase[1] % (body, get_acc(Galist.get(body, 0))) + answer = self.AnsBase[1] % (body, self.get_acc(Galist.get(body, 0))) else: answer = self.AnsBase[2] % (body) Answer(answer, stype, source, disp) def command_get_galist(self, stype, source, body, disp): if Galist: - list = [] - for x, y in Galist.items(): - list.append([y, x]) - list.sort() - list.reverse() + ls = sorted([(acc, user) for user, acc in Galist.iteritems()], reverse = True) if stype == Types[1]: - Answer(AnsBase[11], stype, source, disp) - answer, Numb = self.AnsBase[5], itypes.Number() - for x in list: - answer += "%d) %s - %d\n" % (Numb.plus(), x[1], x[0]) - Message(source[0], answer, disp) + answer = AnsBase[11] + Message(source[0], self.AnsBase[5] + enumerated_list("%s - %d" % (user, acc) for acc, user in ls), disp) else: - Answer(self.AnsBase[3], stype, source, disp) + answer = self.AnsBase[3] + if locals().has_key(Types[6]): + Answer(answer, stype, source, disp) def command_get_lalist(self, stype, source, body, disp): if Chats.has_key(source[1]): if Chats[source[1]].alist: - list = [] - for x, y in Chats[source[1]].alist.items(): - list.append([y, x]) - list.sort() - list.reverse() + ls = sorted([(acc, user) for user, acc in Chats[source[1]].alist.iteritems()], reverse = True) if stype == Types[1]: - Answer(AnsBase[11], stype, source, disp) - answer, Numb = self.AnsBase[5], itypes.Number() - for x in list: - answer += "%d) %s - %d\n" % (Numb.plus(), x[1], x[0]) - Message(source[0], answer, disp) + answer = AnsBase[11] + Message(source[0], self.AnsBase[5] + enumerated_list("%s - %d" % (user, acc) for acc, user in ls), disp) else: answer = self.AnsBase[4] else: @@ -111,7 +108,7 @@ class expansion_temp(expansion): instance = None if instance: access = body.pop(0) - if access == "!": + if access == chr(33): if Galist.has_key(instance): set_access(instance) answer = AnsBase[4] @@ -164,7 +161,7 @@ class expansion_temp(expansion): instance = None if instance: access = body.pop(0) - if access == "!": + if access == chr(33): if Chats[source[1]].alist.has_key(instance): set_access(source[1], instance) answer = AnsBase[4] diff --git a/expansions/access/insc.py b/expansions/access/insc.py index 4a9b9ca..21c847b 100644 --- a/expansions/access/insc.py +++ b/expansions/access/insc.py @@ -2,8 +2,8 @@ if DefLANG in ("RU", "UA"): AnsBase_temp = tuple([line.decode("utf-8") for line in ( - "Твой доступ = %s", # 0 - "Доступ «%s» = %s", # 1 + "Твой доступ - %s.", # 0 + "Доступ «%s» - %s.", # 1 "На «%s» нет информации.", # 2 "Нет глобальных доступов.", # 3 "Нет локальных доступов.", # 4 @@ -16,8 +16,8 @@ if DefLANG in ("RU", "UA"): )]) else: AnsBase_temp = ( - "Your access = %s", # 0 - "%s's access = %s", # 1 + "Your access - %s.", # 0 + "%s's access - %s.", # 1 "I have no info about '%s'.", # 2 "No global accesses.", # 3 "No local accesses.", # 4 diff --git a/expansions/basic_control/code.py b/expansions/basic_control/code.py index 1dad04a..0d2dc09 100644 --- a/expansions/basic_control/code.py +++ b/expansions/basic_control/code.py @@ -24,7 +24,7 @@ class expansion_temp(expansion): ls = body.split() conf = (ls.pop(0)).lower() if conf.count("@") and conf.count(".") >= 2: - if not Chats.has_key(conf): + if conf not in Chats: confname = dynamic % (conf) if not check_nosimbols(confname): confname = encode_filename(confname) @@ -148,7 +148,7 @@ class expansion_temp(expansion): pass if connect_client(Name, InstansesDesc[Name])[0]: try: - Try_Thr(composeThr(DispatchHandler, ThrName, (Name,)), -1) + StartThr(composeThr(DispatchHandler, ThrName, (Name,)), -1) except RuntimeError: answer = self.AnsBase[16] else: @@ -179,7 +179,7 @@ class expansion_temp(expansion): Exit("\n\nRestart command...", 0, 15) def command_exit(self, stype, source, body, disp): - exit_desclr = self.AnsBase[11] % (source[2]) + exit_desclr = self.AnsBase[12] % (source[2]) if body.lower() not in ("-s", "silent", "тихо".decode("utf-8")): if body: exit_desclr += self.AnsBase[1] % (body) diff --git a/expansions/books/code.py b/expansions/books/code.py index b2db79a..6e5aff2 100644 --- a/expansions/books/code.py +++ b/expansions/books/code.py @@ -55,22 +55,22 @@ class expansion_temp(expansion): ls = [] Numb = itypes.Number() Number = itypes.Number() -# lTotal = itypes.Number() +# llen = itypes.Number() for line in body.splitlines(): line = line.strip() ls.append(line) if Number.plus(len(line)) >= 2048: db("insert into %s values (?,?)" % (a2), (Numb.plus(), str.join(chr(10), ls))) -# lTotal.plus(Number._int()) +# llen.plus(Number._int()) ls = [] Number = itypes.Number() if ls: -# lTotal.plus(Number._int()) +# llen.plus(Number._int()) db("insert into %s values (?,?)" % (a2), (Numb.plus(), str.join(chr(10), ls))) db.commit() raise SelfExc("Done. ID - '%s', total pages: %s" % (a2, Numb._str())) else: - raise SelfExc("A book with the same name is already in the libraly!") + raise SelfExc("A book with the same name is already in the library!") def getID(self, Name): while Name.startswith(tuple("1234567890")): diff --git a/expansions/bot_sends/code.py b/expansions/bot_sends/code.py index 0b85582..2d700a9 100644 --- a/expansions/bot_sends/code.py +++ b/expansions/bot_sends/code.py @@ -109,14 +109,13 @@ class expansion_temp(expansion): if body: timer = (726 if enough_access(source[1], source[2], 7) else (time.time() - ChatsAttrs[source[1]]["intr"])) if timer >= 720: - source_, ar = None, body.split()[0] + source_, arg0 = None, body.split()[0] if Chats[source[1]].isHere(body): if Chats[source[1]].isHereTS(body): - Answer(self.AnsBase[6] % (body), stype, source, disp) - raise iThr.ThrKill("exit") + Answer(self.AnsBase[6] % (body), stype, source, disp); raise iThr.ThrKill("exit") source_ = get_source(source[1], body) - elif isSource(ar): - source_ = ar.lower() + elif isSource(arg0): + source_ = arg0.lower() if source_: ChatsAttrs[source[1]]["intr"] = time.time() invite = xmpp.Message(to = source[1]) diff --git a/expansions/cmd_control/code.py b/expansions/cmd_control/code.py index a90503f..202846c 100644 --- a/expansions/cmd_control/code.py +++ b/expansions/cmd_control/code.py @@ -1,8 +1,8 @@ # coding: utf-8 # BlackSmith mark.2 -# exp_name = "cmd_control" # /code.py v.x1 -# Id: 32~1c +# exp_name = "cmd_control" # /code.py v.x2 +# Id: 32~2c # Code © (2012) by WitcherGeralt [alkorgun@gmail.com] class expansion_temp(expansion): @@ -19,7 +19,7 @@ class expansion_temp(expansion): if enough_access(source[1], source[2], 6): ls = body.split() command = (ls.pop(0)).lower() - if Cmds.has_key(command): + if command in Cmds: if enough_access(source[1], source[2], Cmds[command].access): if command not in sCmds: if command in oCmds: @@ -33,6 +33,10 @@ class expansion_temp(expansion): answer = self.AnsBase[2] else: answer = AnsBase[10] + elif command in oCmds: + oCmds.remove(command) + answer = AnsBase[4] + cat_file(chat_file(source[1], self.TabooFile), str(oCmds)) else: answer = AnsBase[6] else: diff --git a/expansions/config/code.py b/expansions/config/code.py index d099767..44ed6a7 100644 --- a/expansions/config/code.py +++ b/expansions/config/code.py @@ -166,7 +166,7 @@ class expansion_temp(expansion): InstansesDesc[Instance] = desc cat_file(ConDispFile, self.get_config(ConDisp)) try: - Try_Thr(composeThr(DispatchHandler, "%s-%s" % (Types[13], Instance), (Instance,)), -1) + StartThr(composeThr(DispatchHandler, "%s-%s" % (Types[13], Instance), (Instance,)), -1) except RuntimeError: answer = self.AnsBase[8] else: diff --git a/expansions/cron/code.py b/expansions/cron/code.py index a33ddf0..8ce0570 100644 --- a/expansions/cron/code.py +++ b/expansions/cron/code.py @@ -1,9 +1,9 @@ # coding: utf-8 # BlackSmith mark.2 -# exp_name = "cron" # /code.py v.x4 -# Id: 27~3c -# Code © (2010-2011) by WitcherGeralt [alkorgun@gmail.com] +# exp_name = "cron" # /code.py v.x5 +# Id: 27~4c +# Code © (2010-2012) by WitcherGeralt [alkorgun@gmail.com] class expansion_temp(expansion): @@ -40,26 +40,6 @@ class expansion_temp(expansion): sThread("command(cron)", exe_cron, ls) del self.CronDesc[id] - def getDate(self, ls, sft, sftime = "%H:%M:%S (%d.%m.%Y)"): - ls[5] += sft - while ls[5] >= 60: - ls[5] -= 60 - ls[4] += 1 - if ls[4] >= 60: - ls[4] -= 60 - ls[3] += 1 - if ls[3] >= 24: - ls[3] -= 24 - ls[2] += 1 - days = (0, 31, (28 if (ls[0] % 4) else 29), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31) - if ls[2] > days[ls[1]]: - ls[2] -= days[ls[1]] - ls[1] += 1 - if ls[1] > 12: - ls[1] -= 12 - ls[0] += 1 - return time.strftime(sftime, time.struct_time(ls)) - def add_cron(self, disp, ls, body, Te, source, stype, gt, answer, repeat, **etc): cmd = (ls.pop(0)).lower() if Cmds.has_key(cmd): @@ -69,9 +49,8 @@ class expansion_temp(expansion): else: body = "" if 1024 >= len(body): - Time = time.mktime(gt) instance = get_source(source[1], source[2]) - self.CronDesc[self.CronCounter.plus()] = ((Te + Time), (cmd, instance, (stype, source, body, get_disp(disp)), repeat)) + self.CronDesc[self.CronCounter.plus()] = (Te, (cmd, instance, (stype, source, body, get_disp(disp)), repeat)) self.cdesc_save() else: answer = AnsBase[5] @@ -86,8 +65,8 @@ class expansion_temp(expansion): if body: ls = body.split() if len(ls) >= 2: - Mode = (ls.pop(0)).lower() - if Mode in ("stop", "стоп".decode("utf-8")): + arg0 = (ls.pop(0)).lower() + if arg0 in ("stop", "стоп".decode("utf-8")): id = ls.pop(0) if isNumber(id): id = int(id) @@ -106,7 +85,7 @@ class expansion_temp(expansion): answer = self.AnsBase[1] % (id) else: answer = AnsBase[30] - elif Mode in ("cycled", "цикл".decode("utf-8")): + elif arg0 in ("cycled", "цикл".decode("utf-8")): if len(ls) >= 3: Te = ls.pop(0) Tr = ls.pop(0) @@ -118,8 +97,10 @@ class expansion_temp(expansion): t_ls, repeat = [Te], (Te, itypes.Number(Tr)) for x in xrange(1, Tr): t_ls.append(t_ls[-1] + Te) + Time = time.mktime(gt) + Te += Time ltls = len(t_ls) - t_ls = enumerated_list([self.getDate(list(gt), dt) for dt in t_ls[:8]]) + t_ls = enumerated_list([time.ctime(dt + Time) for dt in t_ls[:8]]) if ltls > 8: t_ls += self.AnsBase[3] % (ltls - 8) answer = self.AnsBase[4] % (t_ls) @@ -132,7 +113,7 @@ class expansion_temp(expansion): answer = AnsBase[30] else: answer = AnsBase[2] - elif Mode in ("date", "дата".decode("utf-8")): + elif arg0 in ("date", "дата".decode("utf-8")): if len(ls) >= 2: date = list(gt) Te = ls.pop(0) @@ -172,9 +153,8 @@ class expansion_temp(expansion): else: Time, Te = time.mktime(gt), time.mktime(date) if Te > Time: - Te = (Te - Time) if 59 < Te <= 4147200 or enough_access(source[1], source[2], 7): - repeat = (Te,) + repeat = ((Te - Time),) try: answer = self.AnsBase[6] % time.strftime("%H:%M:%S (%d.%m.%Y)", date) except ValueError: @@ -189,11 +169,12 @@ class expansion_temp(expansion): answer = AnsBase[2] else: answer = AnsBase[2] - elif isNumber(Mode): - Te = int(Mode) + elif isNumber(arg0): + Te = int(arg0) if 59 < Te <= 4147200 or enough_access(source[1], source[2], 7): repeat = (Te,) - answer = self.AnsBase[6] % self.getDate(list(gt), Te) + Te += time.mktime(gt) + answer = self.AnsBase[6] % time.ctime(Te) add = self.add_cron del self answer = add(**locals()) @@ -206,13 +187,13 @@ class expansion_temp(expansion): elif not self.CronDesc: answer = self.AnsBase[7] else: - Te = time.mktime(gt) + Time = time.mktime(gt) ls = [] - for id, (date, desc) in self.CronDesc.items(): - if date > Te: - line = "%d (%s) [%s]" % (id, desc[0], self.getDate(list(gt), int(date - Te))) + for id, (date, desc) in sorted(self.CronDesc.items()): + if date > Time: + line = "%d (%s) [%s]" % (id, desc[0], time.ctime(date)) ls.append(line) - answer = self.AnsBase[8] % enumerated_list(sorted(ls)) + answer = self.AnsBase[8] % enumerated_list(ls) Answer(answer, stype, source, disp) def start_cron(self): diff --git a/expansions/cron/insc.py b/expansions/cron/insc.py index f1d2b5a..35ba169 100644 --- a/expansions/cron/insc.py +++ b/expansions/cron/insc.py @@ -4,8 +4,8 @@ if DefLANG in ("RU", "UA"): AnsBase_temp = tuple([line.decode("utf-8") for line in ( "Ты просил выполнить «%s».", # 0 "Нет задания с ID'ом «%d».", # 1 - "Слишком быстро и часто. (при количестве циклов большем 4х - тайм-аут должен превышать 4 минуты)", # 2 - "\n+ ещё %d раз.", # 3 + "Слишком быстро и часто. (при количестве циклов больше 4х - тайм-аут должен превышать 4 минуты)", # 2 + "\n+ ещё %d раз(а).", # 3 "Выполню в:\n%s", # 4 "Тайм-аут не может быть меньше минуты и больше 48 дней.", # 5 "Выполню в %s.", # 6 diff --git a/expansions/get_iq/code.py b/expansions/get_iq/code.py index ef74870..9887c77 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.x8 -# Id: 13~7c +# exp_name = "get_iq" # /code.py v.x9 +# Id: 13~8c # Code © (2010-2012) by WitcherGeralt [alkorgun@gmail.com] class expansion_temp(expansion): @@ -18,8 +18,7 @@ class expansion_temp(expansion): conf_nick = (source[1], instance) instance, source_ = "%s/%s" % conf_nick, get_source(*conf_nick) else: - Answer(self.AnsBase[5] % (instance), stype, source, disp) - raise iThr.ThrKill("exit") + Answer(self.AnsBase[5] % (instance), stype, source, disp); raise iThr.ThrKill("exit") else: instance, source_ = source[0], get_source(source[1], source[2]) iq = xmpp.Iq(to = instance, typ = Types[10]) @@ -88,12 +87,11 @@ class expansion_temp(expansion): if Chats[source[1]].isHereTS(instance): instance = "%s/%s" % (source[1], instance) else: - Answer(self.AnsBase[5] % (instance), stype, source, disp) - raise iThr.ThrKill("exit") + Answer(self.AnsBase[5] % (instance), stype, source, disp); raise iThr.ThrKill("exit") else: instance = source[0] iq = xmpp.Iq(to = instance, typ = Types[10]) - iq.addChild(Types[18], namespace = xmpp.NS_URN_TIME) + iq.addChild(Types[17], namespace = xmpp.NS_URN_TIME) iq.setID("Bs-i%d" % Info["outiq"].plus()) CallForResponse(disp, iq, self.answer_time0202, {"stype": stype, "source": source, "instance": instance}) @@ -168,8 +166,7 @@ class expansion_temp(expansion): if Chats[source[1]].isHereTS(instance): instance = "%s/%s" % (source[1], instance) else: - Answer(self.AnsBase[5] % (instance), stype, source, disp) - raise iThr.ThrKill("exit") + Answer(self.AnsBase[5] % (instance), stype, source, disp); raise iThr.ThrKill("exit") else: instance = source[0] iq = xmpp.Iq(to = instance, typ = Types[10]) @@ -201,8 +198,7 @@ class expansion_temp(expansion): if Chats[source[1]].isHereTS(instance): instance = "%s/%s" % (source[1], instance) else: - Answer(self.AnsBase[5] % (instance), stype, source, disp) - raise iThr.ThrKill("exit") + Answer(self.AnsBase[5] % (instance), stype, source, disp); raise iThr.ThrKill("exit") else: instance = source[0] iq = xmpp.Iq(to = instance, typ = Types[10]) @@ -249,11 +245,15 @@ class expansion_temp(expansion): if ls: ls.insert(0, "\->") answer = str.join(chr(10), ls) + if stype == Types[1]: + Message(source[1], answer, disp) + del answer else: answer = self.AnsBase[10] else: answer = self.AnsBase[6] - Answer(answer, stype, source, disp) + if locals().has_key(Types[6]): + Answer(answer, stype, source, disp) def command_uptime(self, stype, source, server, disp): if not server: diff --git a/expansions/note/code.py b/expansions/note/code.py index fc313f9..750efc1 100644 --- a/expansions/note/code.py +++ b/expansions/note/code.py @@ -1,8 +1,8 @@ # coding: utf-8 # BlackSmith mark.2 -# exp_name = "note" # /code.py v.x6 -# Id: 22~5c +# exp_name = "note" # /code.py v.x7 +# Id: 22~6c # Code © (2010-2011) by WitcherGeralt [alkorgun@gmail.com] class expansion_temp(expansion): @@ -17,8 +17,8 @@ class expansion_temp(expansion): if source_: if body: ls = body.split() - mode = (ls.pop(0)).lower() - if mode in ("clear", "чисть".decode("utf-8")): + arg0 = (ls.pop(0)).lower() + if arg0 in ("clear", "чисть".decode("utf-8")): with database(self.NoteFile) as db: db("select * from note where jid=?", (source_,)) db_desc = db.fetchone() @@ -29,9 +29,9 @@ class expansion_temp(expansion): else: answer = self.AnsBase[0] elif ls: - if mode == "+": + if arg0 == "+": body = body[2:].lstrip() - if len(body) <= 512: + if len(body) <= 512 or enough_access(source[1], source[2], 7): date = strfTime(local = False) with database(self.NoteFile) as db: db("select * from note where jid=?", (source_,)) @@ -53,7 +53,7 @@ class expansion_temp(expansion): answer = AnsBase[4] else: answer = self.AnsBase[1] - elif mode in ("-", "*"): + elif arg0 in ("-", "*"): Numb = ls.pop(0) if isNumber(Numb): Numb = int(Numb) @@ -62,7 +62,7 @@ class expansion_temp(expansion): db("select * from note where jid=?", (source_,)) db_desc = db.fetchone() if db_desc: - if mode == "*": + if arg0 == "*": if db_desc[Numb]: answer = db_desc[Numb] else: diff --git a/expansions/note/insc.py b/expansions/note/insc.py index 2675fbf..caff575 100644 --- a/expansions/note/insc.py +++ b/expansions/note/insc.py @@ -3,7 +3,7 @@ if DefLANG in ("RU", "UA"): AnsBase_temp = tuple([line.decode("utf-8") for line in ( "У тебя нет записей в блокноте.", # 0 - "Длинна одной записи не должна превышать 512 символов.", # 1 + "Длина одной записи не должна превышать 512 символов.", # 1 "Не получится. Твой jid мне не известен.", # 2 "Все 16 строк уже заполнены.", # 3 "В блокноте 16 строк.", # 4 diff --git a/expansions/sheriff/code.py b/expansions/sheriff/code.py index 39462fa..1a03197 100644 --- a/expansions/sheriff/code.py +++ b/expansions/sheriff/code.py @@ -243,8 +243,7 @@ class expansion_temp(expansion): if prisoner: prisoner.offenses += 1 if prisoner.offenses in (1, 2): - Answer(body, stype, source, disp) - raise iThr.ThrKill("exit") + Answer(body, stype, source, disp); raise iThr.ThrKill("exit") elif prisoner.offenses == 3: Chats[source[1]].visitor(source[2], "%s: %s" % (get_nick(source[1]), body)) prisoner.setDevoice() @@ -256,8 +255,7 @@ class expansion_temp(expansion): else: self.spesial_kick(source[1], source[2], body) else: - Answer(body, stype, source, disp) - raise iThr.ThrKill("exit") + Answer(body, stype, source, disp); raise iThr.ThrKill("exit") def sheriff_01eh(self, stanza, isConf, stype, source, body, isToBs, disp): if isConf and source[2] and Chats[source[1]].isModer: diff --git a/expansions/wtf/code.py b/expansions/wtf/code.py index 9e733bf..efc5943 100644 --- a/expansions/wtf/code.py +++ b/expansions/wtf/code.py @@ -2,7 +2,7 @@ # BlackSmith mark.2 # exp_name = "wtf" # /code.py v.x3 -# Id: 28~23 +# Id: 28~3c # Code © (2012) by WitcherGeralt [alkorgun@gmail.com] class expansion_temp(expansion): @@ -16,8 +16,8 @@ class expansion_temp(expansion): def command_wtf(self, stype, source, body, disp): if body: ls = body.split(None, 1) - ar = (ls.pop(0)).lower() - if ar in ("all", "всё".decode("utf-8")): + arg0 = (ls.pop(0)).lower() + if arg0 in ("all", "всё".decode("utf-8")): ls = [] with database(self.Base) as db: db("select name from wtf order by name") @@ -34,7 +34,7 @@ class expansion_temp(expansion): answer = self.AnsBase[-1] + str.join(chr(10)*2, ls) else: answer = self.AnsBase[2] - elif ar in ("search", "искать".decode("utf-8")): + elif arg0 in ("search", "искать".decode("utf-8")): if ls: body = ls[0].lower() ls = [] @@ -62,23 +62,23 @@ class expansion_temp(expansion): else: answer = self.AnsBase[4] else: - name = body.lower() + body = body.lower() answer = None with database(self.Base) as db: - db("select * from wtf where name=?", (name,)) + db("select * from wtf where name=?", (body,)) desc = db.fetchone() if desc: name, data, nick, date = desc answer = self.AnsBase[5] % (name.title(), data, nick, date) if Chats.has_key(source[1]) and not answer: with database(cefile(chat_file(source[1], self.ChatBase))) as db: - db("select * from wtf where name=?", (name,)) + db("select * from wtf where name=?", (body,)) desc = db.fetchone() if desc: name, data, nick, date = desc answer = self.AnsBase[5] % (name.title(), data, nick, date) if not answer: - answer = self.AnsBase[6] % (name) + answer = self.AnsBase[6] % (body) else: ls = [] with database(self.Base) as db: @@ -122,8 +122,8 @@ class expansion_temp(expansion): def command_def(self, stype, source, body, disp): if body: ls = body.split(None, 1) - ar = (ls.pop(0)).lower() - if ar in ("globally", "глобально".decode("utf-8")): + arg0 = (ls.pop(0)).lower() + if arg0 in ("globally", "глобально".decode("utf-8")): if enough_access(source[1], source[2], 7): if ls and self.sep in ls[0]: ls = ls[0].split(self.sep, 1) |