diff options
author | Al Korgun <alkorgun@gmail.com> | 2013-01-06 02:00:16 +0400 |
---|---|---|
committer | Al Korgun <alkorgun@gmail.com> | 2013-01-06 02:00:16 +0400 |
commit | 58e5192c6a297c3e1f63ef672e820d747acf0a93 (patch) | |
tree | 303617003c1370b73f44a95061ee48f0479557a0 | |
parent | 9f0e0aedb78af87d4280e7134693430c481d01e8 (diff) |
expansion "backup" (backup of conferences) added to branches; some expansions modified
-rw-r--r-- | BlackSmith.py | 2 | ||||
-rw-r--r-- | expansions/alive_keeper/code.py | 10 | ||||
-rw-r--r-- | expansions/bot_sends/code.py | 10 | ||||
-rw-r--r-- | expansions/config/code.py | 2 | ||||
-rw-r--r-- | expansions/cron/code.py | 6 | ||||
-rw-r--r-- | expansions/get_iq/code.py | 98 | ||||
-rw-r--r-- | expansions/get_iq/list.ru | 2 | ||||
-rw-r--r-- | expansions/muc/code.py | 148 | ||||
-rw-r--r-- | expansions/muc/insc.py | 4 |
9 files changed, 124 insertions, 158 deletions
diff --git a/BlackSmith.py b/BlackSmith.py index b80cd46..c014774 100644 --- a/BlackSmith.py +++ b/BlackSmith.py @@ -750,7 +750,7 @@ class sConf(object): delivery(self.name) def iq_sender(self, attr, data, afrls, role, reason = str(), handler = None): - stanza = xmpp.Iq(to = self.name, typ = Types[9]) + stanza = xmpp.Iq(Types[9], to = self.name) stanza.setID("Bs-i%d" % Info["outiq"].plus()) query = xmpp.Node(Types[18]) query.setNamespace(xmpp.NS_MUC_ADMIN) diff --git a/expansions/alive_keeper/code.py b/expansions/alive_keeper/code.py index ff53bfb..7e6472a 100644 --- a/expansions/alive_keeper/code.py +++ b/expansions/alive_keeper/code.py @@ -1,8 +1,8 @@ # coding: utf-8 # BlackSmith mark.2 -# exp_name = "alive_keeper" # /code.py v.x6 -# Id: 16~6c +# exp_name = "alive_keeper" # /code.py v.x7 +# Id: 16~7c # Code © (2011-2012) by WitcherGeralt [alkorgun@gmail.com] class expansion_temp(expansion): @@ -17,7 +17,7 @@ class expansion_temp(expansion): Clients[get_disp(disp)].aKeeper = itypes.Number() while VarCache["alive"]: - sleep(360) + sleep(120) ThrIds = iThr.ThrNames() for disp_str, disp in Clients.iteritems(): if not hasattr(disp, "aKeeper"): @@ -37,7 +37,7 @@ class expansion_temp(expansion): collectExc(iThr.Thread.start) elif expansions.has_key(self.name): disp.aKeeper.plus() - iq = xmpp.Iq(to = "%s/%s" % (disp_str, GenResource), typ = Types[10]) + iq = xmpp.Iq(Types[10], to = "%s/%s" % (disp_str, GenResource)) iq.addChild(Types[16], namespace = xmpp.NS_PING) iq.setID("Bs-i%d" % Info["outiq"].plus()) CallForResponse(disp_str, iq, alive_keeper_answer) @@ -76,7 +76,7 @@ class expansion_temp(expansion): collectExc(iThr.Thread.start) elif expansions.has_key(self.name): conf.aKeeper.plus() - iq = xmpp.Iq(to = "%s/%s" % (conf.name, conf.nick), typ = Types[10]) + iq = xmpp.Iq(Types[10], to = "%s/%s" % (conf.name, conf.nick)) iq.addChild(Types[18], namespace = xmpp.NS_PING) iq.setID("Bs-i%d" % Info["outiq"].plus()) CallForResponse(conf.disp, iq, conf_alive_keeper_answer, {"conf": conf.name}) diff --git a/expansions/bot_sends/code.py b/expansions/bot_sends/code.py index 2d700a9..c5bbed3 100644 --- a/expansions/bot_sends/code.py +++ b/expansions/bot_sends/code.py @@ -1,8 +1,8 @@ # coding: utf-8 # BlackSmith mark.2 -# exp_name = "bot_sends" # /code.py v.x7 -# Id: 18~6c +# exp_name = "bot_sends" # /code.py v.x8 +# Id: 18~7c # Code © (2010-2012) by WitcherGeralt [alkorgun@gmail.com] class expansion_temp(expansion): @@ -107,7 +107,8 @@ class expansion_temp(expansion): def command_invite(self, stype, source, body, disp): if Chats.has_key(source[1]): if body: - timer = (726 if enough_access(source[1], source[2], 7) else (time.time() - ChatsAttrs[source[1]]["intr"])) + Time, admin = time.time(), enough_access(source[1], source[2], 7) + timer = (720 if admin else (Time - ChatsAttrs[source[1]]["intr"])) if timer >= 720: source_, arg0 = None, body.split()[0] if Chats[source[1]].isHere(body): @@ -117,7 +118,8 @@ class expansion_temp(expansion): elif isSource(arg0): source_ = arg0.lower() if source_: - ChatsAttrs[source[1]]["intr"] = time.time() + if not admin: + ChatsAttrs[source[1]]["intr"] = Time invite = xmpp.Message(to = source[1]) node = xmpp.Node("x") node.setNamespace(xmpp.NS_MUC_USER) diff --git a/expansions/config/code.py b/expansions/config/code.py index 44ed6a7..06479e4 100644 --- a/expansions/config/code.py +++ b/expansions/config/code.py @@ -195,7 +195,7 @@ class expansion_temp(expansion): for x in xrange(24): code += choice(symbols) if locals().has_key("changed"): - self.answer_register(disp, xmpp.Iq(typ = Types[8]), stype, source, code) + self.answer_register(disp, xmpp.Iq(Types[8]), stype, source, code) elif online(Name): Disp = Clients[Name] iq = xmpp.Iq(Types[9] , xmpp.NS_REGISTER, to = Disp.Server, payload = [xmpp.Node("username", payload = [Disp.User]), xmpp.Node("password", payload = [code])]) diff --git a/expansions/cron/code.py b/expansions/cron/code.py index 8ce0570..c2e4608 100644 --- a/expansions/cron/code.py +++ b/expansions/cron/code.py @@ -70,12 +70,12 @@ class expansion_temp(expansion): id = ls.pop(0) if isNumber(id): id = int(id) - if self.CronDesc.has_key(id): + if id in self.CronDesc: if enough_access(source[1], source[2], 7): del self.CronDesc[id]; self.cdesc_save() answer = AnsBase[4] else: - date, ls = self.CronDesc.get(id) + date, ls = self.CronDesc[id] if ls[1] == get_source(source[1], source[2]): del self.CronDesc[id]; self.cdesc_save() answer = AnsBase[4] @@ -156,7 +156,7 @@ class expansion_temp(expansion): if 59 < Te <= 4147200 or enough_access(source[1], source[2], 7): repeat = ((Te - Time),) try: - answer = self.AnsBase[6] % time.strftime("%H:%M:%S (%d.%m.%Y)", date) + answer = self.AnsBase[6] % time.ctime(Te) except ValueError: answer = self.AnsBase[9] else: diff --git a/expansions/get_iq/code.py b/expansions/get_iq/code.py index 9887c77..8da4d57 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.x9 -# Id: 13~8c +# exp_name = "get_iq" # /code.py v.x10 +# Id: 13~9c # Code © (2010-2012) by WitcherGeralt [alkorgun@gmail.com] class expansion_temp(expansion): @@ -21,7 +21,7 @@ class expansion_temp(expansion): 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]) + iq = xmpp.Iq(Types[10], to = instance) iq.addChild(Types[16], namespace = xmpp.NS_PING) iq.setID("Bs-i%d" % Info["outiq"].plus()) CallForResponse(disp, iq, self.answer_ping, {"stype": stype, "source": source, "instance": instance, "source_": source_, "start": time.time()}) @@ -37,7 +37,7 @@ class expansion_temp(expansion): self.PingStats[source_].append(answer) Answer(self.AnsBase[0] % str(answer), stype, source, disp) else: - iq = xmpp.Iq(to = instance, typ = Types[10]) + iq = xmpp.Iq(Types[10], to = instance) iq.addChild(Types[18], namespace = xmpp.NS_VERSION) iq.setID("Bs-i%d" % Info["outiq"].plus()) CallForResponse(disp, iq, self.answer_ping_ver, {"stype": stype, "source": source, "instance": instance, "source_": source_, "start": time.time()}) @@ -90,28 +90,34 @@ class expansion_temp(expansion): 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 = xmpp.Iq(Types[10], to = instance) 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}) + compile_tzo = compile__("^([-\+]+?)(\d+?):(\d+?)$") + compile_utc = compile__("^(\d+?)-(\d+?)-(\d+?)[A-Z]+?(\d+?):(\d+?):(\d+?)[A-Z]*?$") + def answer_time0202(self, disp, stanza, stype, source, instance): if xmpp.isResultNode(stanza): - hours = None + course, date = None, () for node in stanza.getChildren(): - tzo = node.getTagData("tzo") - if tzo and tzo.startswith((chr(43), chr(45))): - try: - hours, minutes = tzo[1:].split(chr(58)) - symbol = tzo[0] - hours, minutes = int(symbol + hours), int(symbol + minutes) - except: - pass - else: - break - if isinstance(hours, int): - plus = (symbol == chr(43)) - date = list(time.gmtime()) + try: + course, hours, minutes = self.compile_tzo.search(node.getTagData("tzo")).groups() + except: + pass + try: + date = self.compile_utc.search(node.getTagData("utc")).groups() + except: + pass + else: + date = ([int(digit) for digit in date] + [0, 0, 0]) + if course: + break + if course: + hours, minutes = int(course + hours), int(course + minutes) + if not date: + date = list(time.gmtime()) days = (31, 31, (28 if (date[0] % 4) else 29), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31) date[4] += minutes date[3] += hours @@ -120,7 +126,7 @@ class expansion_temp(expansion): date[3] += 1 if date[3] >= 24: date[3] -= 24 - if plus: + if course == chr(43): date[2] += 1 if date[2] > days[date[1]]: date[2] = 1 @@ -141,12 +147,12 @@ class expansion_temp(expansion): except: answer = self.AnsBase[6] else: - answer = time.strftime("%a %b %d %H:%M:%S %Y", date) + answer = time.ctime(time.mktime(date)) else: answer = self.AnsBase[6] Answer(answer, stype, source, disp) else: - iq = xmpp.Iq(to = instance, typ = Types[10]) + iq = xmpp.Iq(Types[10], to = instance) iq.addChild(Types[18], namespace = xmpp.NS_TIME) iq.setID("Bs-i%d" % Info["outiq"].plus()) CallForResponse(disp, iq, self.answer_time0090, {"stype": stype, "source": source}) @@ -169,7 +175,7 @@ class expansion_temp(expansion): 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 = xmpp.Iq(Types[10], to = instance) iq.addChild(Types[18], namespace = xmpp.NS_VERSION) iq.setID("Bs-i%d" % Info["outiq"].plus()) CallForResponse(disp, iq, self.answer_version, {"stype": stype, "source": source}) @@ -201,7 +207,7 @@ class expansion_temp(expansion): 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 = xmpp.Iq(Types[10], to = instance) iq.addChild(Types[18], namespace = xmpp.NS_VCARD) iq.setID("Bs-i%d" % Info["outiq"].plus()) CallForResponse(disp, iq, self.answer_vcard, {"stype": stype, "source": source}) @@ -258,7 +264,7 @@ class expansion_temp(expansion): def command_uptime(self, stype, source, server, disp): if not server: server = disp._owner.Server - iq = xmpp.Iq(to = server, typ = Types[10]) + iq = xmpp.Iq(Types[10], to = server) iq.addChild(Types[18], namespace = xmpp.NS_LAST) iq.setID("Bs-i%d" % Info["outiq"].plus()) CallForResponse(disp, iq, self.answer_idle, {"stype": stype, "source": source, "instance": server, "typ": None}) @@ -272,7 +278,7 @@ class expansion_temp(expansion): else: answer = self.AnsBase[5] % (instance) if not locals().has_key(Types[6]): - iq = xmpp.Iq(to = instance, typ = Types[10]) + iq = xmpp.Iq(Types[10], to = instance) iq.addChild(Types[18], namespace = xmpp.NS_LAST) iq.setID("Bs-i%d" % Info["outiq"].plus()) CallForResponse(disp, iq, self.answer_idle, {"stype": stype, "source": source, "instance": nick, "typ": True}) @@ -296,9 +302,9 @@ class expansion_temp(expansion): def get_req(body): if DefLANG in ("RU", "UA"): - for numb, name in enumerate(("овнер", "админ", "мембер", "бан")): - name = name.decode("utf-8") - if name in body: + for numb, role in enumerate(("овнер", "админ", "мембер", "бан")): + role = role.decode("utf-8") + if role in body: return self.affs[numb] return (body if body in self.affs else None) @@ -310,23 +316,23 @@ class expansion_temp(expansion): if ls: data = (ls.pop(0)).lower() desc = {} - for name in self.affs: - iq = xmpp.Iq(to = source[1], typ = Types[10]) + for role in self.affs: + iq = xmpp.Iq(Types[10], to = source[1]) query = xmpp.Node(Types[18]) query.setNamespace(xmpp.NS_MUC_ADMIN) - query.addChild("item", {aRoles[0]: name}) + query.addChild("item", {aRoles[0]: role}) iq.addChild(node = query) iq.setID("Bs-i%d" % Info["outiq"].plus()) - CallForResponse(disp, iq, self.answer_aflist_search, {"desc": desc, "name": name, "data": data}) + CallForResponse(disp, iq, self.answer_aflist_search, {"desc": desc, "role": role, "data": data}) for x in xrange(60): sleep(0.2) if len(desc.keys()) == 4: break Number = itypes.Number() ls = [] - for name, matches in desc.iteritems(): + for role, matches in desc.iteritems(): if matches: - ls.append(name.capitalize() + "s:") + ls.append(role.capitalize() + "s:") for jid in matches: ls.append("%d) %s" % (Number.plus(), jid)) if ls: @@ -348,7 +354,7 @@ class expansion_temp(expansion): Numb = 20 else: Numb = x - iq = xmpp.Iq(to = source[1], typ = Types[10]) + iq = xmpp.Iq(Types[10], to = source[1]) query = xmpp.Node(Types[18]) query.setNamespace(xmpp.NS_MUC_ADMIN) query.addChild("item", {aRoles[0]: body}) @@ -364,7 +370,7 @@ class expansion_temp(expansion): if locals().has_key(Types[6]): Answer(answer, stype, source, disp) - def answer_aflist_search(self, disp, stanza, desc, name, data): + def answer_aflist_search(self, disp, stanza, desc, role, data): if xmpp.isResultNode(stanza): count = [] for node in stanza.getQueryChildren(): @@ -375,11 +381,11 @@ class expansion_temp(expansion): if signature: jid = "%s (%s)" % (jid, signature) count.append(jid) - desc[name] = count + desc[role] = count def answer_aflist(self, disp, stanza, stype, source, Numb): if xmpp.isResultNode(stanza): - ls, Number = [], itypes.Number() + jids, Number = [], itypes.Number() for node in stanza.getQueryChildren(): if node and node != "None": jid = node.getAttr("jid") @@ -390,11 +396,11 @@ class expansion_temp(expansion): signature = node.getTagData("reason") if signature: jid = "%s (%s)" % (jid, signature) - ls.append("%d) %s" % (Number.plus(), jid)) - if ls: + jids.append("%d) %s" % (Number.plus(), jid)) + if jids: if Numb and Numb < Number._int(): - ls.append("...\nTotal: %s items." % (Number._str())) - Message(source[0], str.join(chr(10), ls), disp) + jids.append("...\nTotal: %s items." % (Number._str())) + Message(source[0], str.join(chr(10), jids), disp) if stype == Types[1]: answer = AnsBase[11] else: @@ -409,14 +415,14 @@ class expansion_temp(expansion): def command_server_stats(self, stype, source, server, disp): if not server: server = disp._owner.Server - iq = xmpp.Iq(to = server, typ = Types[10]) + iq = xmpp.Iq(Types[10], to = server) iq.addChild(Types[18], namespace = xmpp.NS_STATS) iq.setID("Bs-i%d" % Info["outiq"].plus()) CallForResponse(disp, iq, self.answer_server_stats, {"stype": stype, "source": source}) def answer_server_stats(self, disp, stanza, stype, source): if xmpp.isResultNode(stanza): - iq = xmpp.Iq(to = stanza.getFrom(), typ = Types[10]) + iq = xmpp.Iq(Types[10], to = stanza.getFrom()) iq.addChild(Types[18], {}, stanza.getQueryChildren(), xmpp.NS_STATS) iq.setID("Bs-i%d" % Info["outiq"].plus()) CallForResponse(disp, iq, self.answer_server_stats_get, {"stype": stype, "source": source}) @@ -462,7 +468,7 @@ class expansion_temp(expansion): desc["body"] = ls.pop(0) else: desc["body"] = body[len(server):].strip() - iq = xmpp.Iq(to = server, typ = Types[10]) + iq = xmpp.Iq(Types[10], to = server) iq.addChild(Types[18], namespace = xmpp.NS_DISCO_ITEMS) iq.setID("Bs-i%d" % Info["outiq"].plus()) CallForResponse(disp, iq, self.answer_disco, desc) diff --git a/expansions/get_iq/list.ru b/expansions/get_iq/list.ru index 761c45f..af793fe 100644 --- a/expansions/get_iq/list.ru +++ b/expansions/get_iq/list.ru @@ -1,5 +1,5 @@ списки аффиляций
-{command} [овнеров/админов/мемберов/бани]/[[искать] [текст]]
+{command} [овнеров/админов/мемберов/банов]/[[искать] [текст]]
*/{command} мемберов
бот покажет список постоянных участников конференции
*/{command} искать dude
diff --git a/expansions/muc/code.py b/expansions/muc/code.py index d89c0ae..ee5cbb7 100644 --- a/expansions/muc/code.py +++ b/expansions/muc/code.py @@ -1,8 +1,8 @@ # coding: utf-8 # BlackSmith mark.2 -# exp_name = "muc" # /code.py v.x8 -# Id: 05~4c +# exp_name = "muc" # /code.py v.x9 +# Id: 05~5c # Code © (2009-2012) by WitcherGeralt [alkorgun@gmail.com] class expansion_temp(expansion): @@ -13,7 +13,7 @@ class expansion_temp(expansion): def command_subject(self, stype, source, body, disp): if Chats.has_key(source[1]): if body: - if Chats[source[1]].isModer: + if Chats[source[1]].isModer or getattr(Chats[source[1]].get_user(get_nick(source[1])), "role", (None,)*2)[1] == aRoles[9]: Info["omsg"].plus() Chats[source[1]].subject(xmpp.XMLescape(body)) else: @@ -31,11 +31,7 @@ class expansion_temp(expansion): if Chats.has_key(source[1]): if body: if Chats[source[1]].isModer: - Lock, BsNick = False, get_nick(source[1]) - if getattr(Chats[source[1]].get_user(BsNick), "role", (aRoles[5],))[0] == aRoles[5]: - if not enough_access(source[1], source[2], 6): - Lock = True - if not Lock: + if enough_access(source[1], source[2], 6) or getattr(Chats[source[1]].get_user(get_nick(source[1])), "role", (aRoles[5],))[0] != aRoles[5]: body = body.split(self.sep, 1) nick = (body.pop(0)).strip() if Chats[source[1]].isHere(nick): @@ -67,11 +63,7 @@ class expansion_temp(expansion): if Chats.has_key(source[1]): if body: if Chats[source[1]].isModer: - Lock, BsNick = False, get_nick(source[1]) - if getattr(Chats[source[1]].get_user(BsNick), "role", (aRoles[5],))[0] == aRoles[5]: - if not enough_access(source[1], source[2], 6): - Lock = True - if not Lock: + if enough_access(source[1], source[2], 6) or getattr(Chats[source[1]].get_user(get_nick(source[1])), "role", (aRoles[5],))[0] != aRoles[5]: body = body.split(self.sep, 1) nick = (body.pop(0)).strip() if Chats[source[1]].isHere(nick): @@ -103,11 +95,7 @@ class expansion_temp(expansion): if Chats.has_key(source[1]): if body: if Chats[source[1]].isModer: - Lock, BsNick = False, get_nick(source[1]) - if getattr(Chats[source[1]].get_user(BsNick), "role", (aRoles[5],))[0] == aRoles[5]: - if not enough_access(source[1], source[2], 6): - Lock = True - if not Lock: + if enough_access(source[1], source[2], 6) or getattr(Chats[source[1]].get_user(get_nick(source[1])), "role", (aRoles[5],))[0] != aRoles[5]: body = body.split(self.sep, 1) nick = (body.pop(0)).strip() if Chats[source[1]].isHere(nick): @@ -138,30 +126,23 @@ class expansion_temp(expansion): def command_admin(self, stype, source, body, disp): if Chats.has_key(source[1]): if body: - if Chats[source[1]].isModer: - Lock, BsNick = False, get_nick(source[1]) - if getattr(Chats[source[1]].get_user(BsNick), "role", (aRoles[5],))[0] == aRoles[5]: - if not enough_access(source[1], source[2], 6): - Lock = True - if not Lock: - body = body.split(self.sep, 1) - nick = (body.pop(0)).strip() - if Chats[source[1]].isHere(nick): - jid = get_source(source[1], nick) - elif nick.count(chr(46)): - jid = nick - else: - jid = None - if jid: - if body: - body = "%s: %s" % (source[2], body[0].strip()) - else: - body = "%s/%s" % (get_nick(source[1]), source[2]) - Chats[source[1]].admin(jid, body, (None, (stype, source))) + if getattr(Chats[source[1]].get_user(get_nick(source[1])), "role", (aRoles[5],))[0] == aRoles[5]: + body = body.split(self.sep, 1) + nick = (body.pop(0)).strip() + if Chats[source[1]].isHere(nick): + jid = get_source(source[1], nick) + elif nick.count(chr(46)): + jid = nick + else: + jid = None + if jid: + if body: + body = "%s: %s" % (source[2], body[0].strip()) else: - answer = AnsBase[7] + body = "%s/%s" % (get_nick(source[1]), source[2]) + Chats[source[1]].admin(jid, body, (None, (stype, source))) else: - answer = self.AnsBase[0] + answer = AnsBase[7] else: answer = self.AnsBase[1] else: @@ -174,30 +155,23 @@ class expansion_temp(expansion): def command_owner(self, stype, source, body, disp): if Chats.has_key(source[1]): if body: - if Chats[source[1]].isModer: - Lock, BsNick = False, get_nick(source[1]) - if getattr(Chats[source[1]].get_user(BsNick), "role", (aRoles[5],))[0] == aRoles[5]: - if not enough_access(source[1], source[2], 6): - Lock = True - if not Lock: - body = body.split(self.sep, 1) - nick = (body.pop(0)).strip() - if Chats[source[1]].isHere(nick): - jid = get_source(source[1], nick) - elif nick.count(chr(46)): - jid = nick - else: - jid = None - if jid: - if body: - body = "%s: %s" % (source[2], body[0].strip()) - else: - body = "%s/%s" % (get_nick(source[1]), source[2]) - Chats[source[1]].owner(jid, body, (None, (stype, source))) + if getattr(Chats[source[1]].get_user(get_nick(source[1])), "role", (aRoles[5],))[0] == aRoles[5]: + body = body.split(self.sep, 1) + nick = (body.pop(0)).strip() + if Chats[source[1]].isHere(nick): + jid = get_source(source[1], nick) + elif nick.count(chr(46)): + jid = nick + else: + jid = None + if jid: + if body: + body = "%s: %s" % (source[2], body[0].strip()) else: - answer = AnsBase[7] + body = "%s/%s" % (get_nick(source[1]), source[2]) + Chats[source[1]].owner(jid, body, (None, (stype, source))) else: - answer = self.AnsBase[0] + answer = AnsBase[7] else: answer = self.AnsBase[1] else: @@ -210,12 +184,9 @@ class expansion_temp(expansion): def command_kick(self, stype, source, body, disp): if Chats.has_key(source[1]): if body: - if Chats[source[1]].isModer: - Lock, BsNick = False, get_nick(source[1]) - if getattr(Chats[source[1]].get_user(BsNick), "role", (aRoles[5],))[0] == aRoles[5]: - if not enough_access(source[1], source[2], 6): - Lock = True - if not Lock: + aRole = getattr(Chats[source[1]].get_user(get_nick(source[1])), "role", (aRoles[5], None)) + if Chats[source[1]].isModer or aRole[1] == aRoles[9]: + if enough_access(source[1], source[2], 6) or aRole[0] != aRoles[5]: body = body.split(self.sep, 1) nick = (body.pop(0)).strip() if Chats[source[1]].isHere(nick): @@ -244,12 +215,9 @@ class expansion_temp(expansion): def command_visitor(self, stype, source, body, disp): if Chats.has_key(source[1]): if body: - if Chats[source[1]].isModer: - Lock, BsNick = False, get_nick(source[1]) - if getattr(Chats[source[1]].get_user(BsNick), "role", (aRoles[5],))[0] == aRoles[5]: - if not enough_access(source[1], source[2], 6): - Lock = True - if not Lock: + aRole = getattr(Chats[source[1]].get_user(get_nick(source[1])), "role", (aRoles[5], None)) + if Chats[source[1]].isModer or aRole[1] == aRoles[9]: + if enough_access(source[1], source[2], 6) or aRole[0] != aRoles[5]: body = body.split(self.sep, 1) nick = (body.pop(0)).strip() if Chats[source[1]].isHere(nick): @@ -278,12 +246,9 @@ class expansion_temp(expansion): def command_participant(self, stype, source, body, disp): if Chats.has_key(source[1]): if body: - if Chats[source[1]].isModer: - Lock, BsNick = False, get_nick(source[1]) - if getattr(Chats[source[1]].get_user(BsNick), "role", (aRoles[5],))[0] == aRoles[5]: - if not enough_access(source[1], source[2], 6): - Lock = True - if not Lock: + aRole = getattr(Chats[source[1]].get_user(get_nick(source[1])), "role", (aRoles[5], None)) + if Chats[source[1]].isModer or aRole[1] == aRoles[9]: + if enough_access(source[1], source[2], 6) or aRole[0] != aRoles[5]: body = body.split(self.sep, 1) nick = (body.pop(0)).strip() if Chats[source[1]].isHere(nick): @@ -309,23 +274,16 @@ class expansion_temp(expansion): if Chats.has_key(source[1]): if body: if Chats[source[1]].isModer: - Lock, BsNick = False, get_nick(source[1]) - if getattr(Chats[source[1]].get_user(BsNick), "role", (aRoles[5],))[0] == aRoles[5]: - if not enough_access(source[1], source[2], 6): - Lock = True - if not Lock: - body = body.split(self.sep, 1) - nick = (body.pop(0)).strip() - if Chats[source[1]].isHere(nick): - if body: - body = "%s: %s" % (source[2], body[0].strip()) - else: - body = "%s/%s" % (get_nick(source[1]), source[2]) - Chats[source[1]].moder(nick, body, (None, (stype, source))) + body = body.split(self.sep, 1) + nick = (body.pop(0)).strip() + if Chats[source[1]].isHere(nick): + if body: + body = "%s: %s" % (source[2], body[0].strip()) else: - answer = AnsBase[7] + body = "%s/%s" % (get_nick(source[1]), source[2]) + Chats[source[1]].moder(nick, body, (None, (stype, source))) else: - answer = self.AnsBase[0] + answer = AnsBase[7] else: answer = self.AnsBase[1] else: diff --git a/expansions/muc/insc.py b/expansions/muc/insc.py index dfbfa94..33fb1f9 100644 --- a/expansions/muc/insc.py +++ b/expansions/muc/insc.py @@ -3,7 +3,7 @@ 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 @@ -11,7 +11,7 @@ if DefLANG in ("RU", "UA"): else: AnsBase_temp = ( "Security protocols are prohibits this action.", # 0 - "I must to be admin/moder, to do this.", # 1 + "I don't have enough rights, 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 |