Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/alkorgun/blacksmith-2.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAl Korgun <alkorgun@gmail.com>2013-12-05 12:42:32 +0400
committerAl Korgun <alkorgun@gmail.com>2013-12-05 12:42:32 +0400
commit89b59b77a8740d5ef8bef3e3b8f4b20efb1487a0 (patch)
treed73ab7c93eba461d2195834fa889ad3af3e694a4
parent00e7b275bb8eb242ad980cda58831828bee6d686 (diff)
some fixes; code formatting and refactoring (include librarys)
-rw-r--r--BlackSmith.py502
-rw-r--r--expansions/access/code.py14
-rw-r--r--expansions/access/insc.py4
-rw-r--r--expansions/alive_keeper/code.py56
-rw-r--r--expansions/allweb/code.py88
-rw-r--r--expansions/allweb/insc.py14
-rw-r--r--expansions/basic_control/code.py22
-rw-r--r--expansions/basic_control/insc.py4
-rw-r--r--expansions/books/code.py10
-rw-r--r--expansions/books/insc.py4
-rw-r--r--expansions/bot_sends/code.py32
-rw-r--r--expansions/bot_sends/insc.py4
-rw-r--r--expansions/clear_stats/code.py2
-rw-r--r--expansions/cmd_control/insc.py4
-rw-r--r--expansions/config/code.py76
-rw-r--r--expansions/config/insc.py4
-rw-r--r--expansions/converter/code.py30
-rw-r--r--expansions/converter/insc.py4
-rw-r--r--expansions/cron/code.py12
-rw-r--r--expansions/cron/insc.py4
-rw-r--r--expansions/dns/code.py2
-rw-r--r--expansions/exp_control/code.py10
-rw-r--r--expansions/exp_control/insc.py4
-rw-r--r--expansions/extra_control/code.py18
-rw-r--r--expansions/game/code.py12
-rw-r--r--expansions/game/insc.py12
-rw-r--r--expansions/get_iq/code.py99
-rw-r--r--expansions/get_iq/insc.py4
-rw-r--r--expansions/help/code.py34
-rw-r--r--expansions/help/insc.py4
-rw-r--r--expansions/info/code.py42
-rw-r--r--expansions/info/insc.py4
-rw-r--r--expansions/interpreter/code.py16
-rw-r--r--expansions/muc/code.py26
-rw-r--r--expansions/muc/insc.py4
-rw-r--r--expansions/new_year/code.py2
-rw-r--r--expansions/note/code.py28
-rw-r--r--expansions/note/insc.py4
-rw-r--r--expansions/roster_control/code.py4
-rw-r--r--expansions/roster_control/insc.py4
-rw-r--r--expansions/sconf_attrs/code.py2
-rw-r--r--expansions/sconf_attrs/insc.py4
-rw-r--r--expansions/session_stats/code.py26
-rw-r--r--expansions/session_stats/insc.py4
-rw-r--r--expansions/sheriff/code.py375
-rw-r--r--expansions/sheriff/insc.py4
-rw-r--r--expansions/talkers/code.py10
-rw-r--r--expansions/talkers/insc.py4
-rw-r--r--expansions/turn/code.py28
-rw-r--r--expansions/user_stats/code.py8
-rw-r--r--expansions/user_stats/insc.py4
-rw-r--r--expansions/wtf/code.py4
-rw-r--r--expansions/wtf/insc.py4
-rw-r--r--librarys.zipbin101254 -> 101096 bytes
-rw-r--r--static/insc.py4
55 files changed, 845 insertions, 859 deletions
diff --git a/BlackSmith.py b/BlackSmith.py
index 97e33d0..3e865c9 100644
--- a/BlackSmith.py
+++ b/BlackSmith.py
@@ -8,7 +8,7 @@
# imports
-from types import NoneType, UnicodeType, InstanceType
+from types import NoneType, InstanceType, GeneratorType
from traceback import print_exc as exc_info__
from random import shuffle, randrange, choice
from re import compile as compile__
@@ -28,7 +28,7 @@ sys.path.insert(0, ZipLib)
from enconf import *
-import xmpp, iThr, itypes
+import xmpp, ithr, itypes
# Cache & Statistics
@@ -40,7 +40,7 @@ color2 = chr(27) + "[31;1m" # red
color3 = chr(27) + "[32m" # green
color4 = chr(27) + "[34;1m" # blue
-sys_cmds = [
+cmdsDb = [
"ps -o rss -p %d", # 0
'TASKLIST /FI "PID eq %d"', # 1
"COLOR F0", # 2
@@ -48,9 +48,9 @@ sys_cmds = [
"TASKKILL /PID %d /T /f", # 4
"Ver", # 5
'sh -c "%s" 2>&1' # 6
- ]
+]
-Types = (
+sBase = (
"chat", # 0
"groupchat", # 1
"normal", # 2
@@ -70,7 +70,7 @@ Types = (
"ping", # 16
"time", # 17
"query" # 18
- )
+)
aRoles = (
"affiliation", # 0
@@ -83,14 +83,14 @@ aRoles = (
"visitor", # 7
"participant", # 8
"moderator" # 9
- )
+)
sList = (
"chat", # готов поболтать
"away", # отошел
"xa", # не беспокоить
"dnd" # недоступен
- )
+)
aDesc = {
"owner": 3,
@@ -98,14 +98,14 @@ aDesc = {
"admin": 2,
"participant": 1,
"member": 1
- }
+}
sCodesDesc = {
"301": "has-been-banned", # 0
"303": "nick-changed", # 1
"307": "has-been-kicked", # 2
"407": "members-only" # 3
- }
+}
sCodes = sorted(sCodesDesc.keys())
@@ -124,7 +124,7 @@ eCodesDesc = {
"501": "feature-not-implemented", # 11
"503": "service-unavailable", # 12
"504": "remote-server-timeout" # 13
- }
+}
eCodes = sorted(eCodesDesc.keys())
@@ -135,7 +135,7 @@ IqXEPs = (
xmpp.NS_URN_TIME, # 3
xmpp.NS_LAST, # 4
xmpp.NS_DISCO_INFO # 5
- )
+)
XEPs = set(IqXEPs + (
xmpp.NS_CAPS,
@@ -144,7 +144,7 @@ XEPs = set(IqXEPs + (
xmpp.NS_MUC,
xmpp.NS_ROSTER,
xmpp.NS_RECEIPTS
- ))
+))
isJID = compile__("^.+?@[\w-]+?\.[\.\w-]+?$", 32)
@@ -153,7 +153,7 @@ VarCache = {
"alive": True,
"errors": [],
"action": "# %s %s &" % (os.path.basename(sys.executable), BsCore)
- }
+}
Info = {
"cmd": itypes.Number(), "sess": time.time(),
@@ -162,7 +162,7 @@ Info = {
"prs": itypes.Number(), "iq": itypes.Number(),
"errors": itypes.Number(),
"omsg": itypes.Number(), "outiq": itypes.Number()
- }
+}
# Useful features
@@ -189,7 +189,7 @@ sleep, database = time.sleep, itypes.Database
def get_exc():
try:
- exc = iThr.get_exc()
+ exc = ithr.get_exc()
except:
exc = "(...)"
return exc
@@ -205,7 +205,7 @@ def apply(instance, args = ()):
def text_color(text, color):
if eColors and color:
- text = color+text+color0
+ text = color + text + color0
return text
def Print(text, color = None):
@@ -266,7 +266,7 @@ ConDispFile = static % ("clients.ini")
ChatsFile = dynamic % ("chats.db")
ChatsFileBackup = dynamic % ("chats.cp")
-(BsMark, BsVer, BsRev) = (2, 48, 0)
+(BsMark, BsVer, BsRev) = (2, 50, 0)
if os.access(SvnCache, os.R_OK):
Cache = open(SvnCache).readlines()
@@ -283,9 +283,9 @@ Caps = "http://blacksmith-2.googlecode.com/svn/"
CapsVer = "%d.%d" % (BsMark, BsVer)
FullName = "HellDev's %s Ver.%s (%s)" % (ProdName, ProdVer, Caps)
-BotOs, BsPid = os.name, os.getpid()
+BotOS, BsPid = os.name, os.getpid()
-oSlist = ((BotOs == "nt"), (BotOs == "posix"))
+OSList = ((BotOS == "nt"), (BotOS == "posix"))
def client_config(config, section):
serv = config.get(section, "serv").lower()
@@ -294,9 +294,9 @@ def client_config(config, section):
port = 5222
user = config.get(section, "user").lower()
host = config.get(section, "host").lower()
- code = config.get(section, "pass")
+ password = config.get(section, "pass")
jid = "%s@%s" % (user, host)
- return (jid, (serv, port, host, user, code))
+ return (jid, (serv, port, host, user, password))
try:
GenCon = ConfigParser.ConfigParser()
@@ -333,9 +333,9 @@ try:
except:
Exit("\n\nError: general inscript is damaged!", 1, 30)
-if oSlist[0]:
- os.system(sys_cmds[2])
- os.system("%s %s" % (sys_cmds[3], FullName))
+if OSList[0]:
+ os.system(cmdsDb[2])
+ os.system("%s %s" % (cmdsDb[3], FullName))
# lists & dicts
@@ -357,9 +357,9 @@ Handlers = {
"09eh": [], "00si": [],
"01si": [], "02si": [],
"03si": [], "04si": []
- }
+}
-Sequence = iThr.Semaphore()
+Sequence = ithr.Semaphore()
# call & execute Threads & handlers
@@ -368,7 +368,7 @@ def execute_handler(handler_instance, list = (), command = None):
handler_instance(*list)
except KeyboardInterrupt:
pass
- except iThr.ThrKill:
+ except ithr.ThrKill:
pass
except SelfExc:
pass
@@ -379,37 +379,37 @@ def call_sfunctions(ls, list = ()):
for inst in Handlers[ls]:
execute_handler(inst, list)
-def composeTimer(sleep, handler, Name = None, list = (), command = None):
- if not Name:
- Name = "iTimer-%d" % (iThr.aCounter._int())
- Timer = iThr.Timer(sleep, execute_handler, (handler, list, command,))
- Timer.name = Name
+def composeTimer(sleep, handler, name = None, list = (), command = None):
+ if not name:
+ name = "iTimer-%s" % (ithr.aCounter._str())
+ Timer = ithr.Timer(sleep, execute_handler, (handler, list, command,))
+ Timer.name = name
return Timer
-def composeThr(handler, Name, list = (), command = None):
- if not Name.startswith(Types[13]):
- Name = "%s-%d" % (Name, iThr.aCounter._int())
- return iThr.KThread(execute_handler, Name, (handler, list, command,))
+def composeThr(handler, name, list = (), command = None):
+ if not name.startswith(sBase[13]):
+ name = "%s-%s" % (name, ithr.aCounter._str())
+ return ithr.KThread(execute_handler, name, (handler, list, command,))
-def StartThr(Thr, Number = 0):
- if Number > 2:
+def startThr(thr, number = 0):
+ if number > 2:
raise RuntimeError("exit")
try:
- Thr.start()
- except iThr.error:
- StartThr(Thr, (Number + 1))
+ thr.start()
+ except ithr.error:
+ startThr(thr, (number + 1))
except:
- collectExc(Thr.start)
+ collectExc(thr.start)
-def sThread_Run(Thr, handler, command = None):
+def sThread_Run(thr, handler, command = None):
try:
- Thr.start()
- except iThr.error:
+ thr.start()
+ except ithr.error:
try:
- StartThr(Thr)
+ startThr(thr)
except RuntimeError:
try:
- Thr._run_backup()
+ thr._run_backup()
except Exception:
collectExc(handler, command)
except:
@@ -449,7 +449,7 @@ class expansion(object):
for ls in self.commands:
command_handler(self, *ls)
for inst, ls in self.handlers:
- self.handler_register(getattr(self, inst.func_name), ls)
+ self.handler_register(getattr(self, inst.__name__), ls)
auto_clear = None
@@ -458,7 +458,7 @@ class expansion(object):
cmd = self.cmds.pop()
if cmd in Cmds:
Cmds[cmd].off()
- self.funcs_del()
+ self.clear_handlers()
self.commands = ()
self.handlers = ()
if self.auto_clear:
@@ -466,16 +466,12 @@ class expansion(object):
if full and expansions.has_key(self.name):
del expansions[self.name]
- def ls_add(self, ls):
- if not self.desc.has_key(ls):
- self.desc[ls] = []
-
- def funcs_del(self, handler = None):
+ def clear_handlers(self, handler = None):
def Del(inst, ls):
if ls == "03si":
execute_handler(inst)
- self.inst_del(ls, inst)
+ self.del_handler(ls, inst)
list = self.desc[ls]
list.remove(inst)
if not list:
@@ -505,10 +501,6 @@ class expansion(object):
for conf in Chats.keys():
execute_handler(inst, (conf,))
- def func_add(self, ls, inst):
- self.ls_add(ls)
- self.desc[ls].append(inst)
-
def load(self):
if expansions.has_key(self.name):
expansions[self.name].dels()
@@ -523,21 +515,21 @@ class expansion(object):
exp = (exp_inst, ())
return exp
- def inst_add(self, ls, inst):
+ def add_handler(self, ls, inst):
if inst not in Handlers[ls]:
Handlers[ls].append(inst)
- def inst_del(self, ls, inst):
+ def del_handler(self, ls, inst):
if inst in Handlers[ls]:
Handlers[ls].remove(inst)
def handler_register(self, inst, ls):
- Name = inst.func_name
+ name = inst.__name__
for instance in Handlers[ls]:
- if Name == instance.func_name:
- self.inst_del(ls, instance)
- self.inst_add(ls, inst)
- self.func_add(ls, inst)
+ if name == instance.__name__:
+ self.del_handler(ls, instance)
+ self.add_handler(ls, inst)
+ self.desc.setdefault(ls, []).append(inst)
class Command(object):
@@ -576,7 +568,7 @@ class Command(object):
answer = AnsBase[19] % (self.name)
else:
answer = AnsBase[10]
- if locals().has_key(Types[6]):
+ if locals().has_key(sBase[6]):
Answer(answer, stype, source, disp)
def command_handler(exp_inst, handler, default, access, prefix = True):
@@ -712,7 +704,7 @@ class sConf(object):
def subject(self, body):
Info["omsg"].plus()
- self.csend(xmpp.Message(self.name, "", Types[1], body))
+ self.csend(xmpp.Message(self.name, "", sBase[1], body))
def set_status(self, state, status):
self.state, self.status = (state, status)
@@ -728,7 +720,7 @@ class sConf(object):
self.IamHere = None
self.isModer = True
self.more = ""
- stanza = xmpp.Presence(self.name, Types[4])
+ stanza = xmpp.Presence(self.name, sBase[4])
if exit_status:
stanza.setStatus(exit_status)
self.csend(stanza)
@@ -749,7 +741,7 @@ class sConf(object):
if self.name in desc:
del desc[self.name]
else:
- desc[self.name] = {"disp": self.disp, Types[12]: self.nick, "cPref": self.cPref, "code": self.code}
+ desc[self.name] = {"disp": self.disp, sBase[12]: self.nick, "cPref": self.cPref, "code": self.code}
desc = str(desc)
cat_file(ChatsFileBackup, desc)
cat_file(ChatsFile, desc)
@@ -757,9 +749,9 @@ class sConf(object):
delivery(self.name)
def iq_sender(self, attr, data, afrls, role, reason = str(), handler = None):
- stanza = xmpp.Iq(Types[9], to = self.name)
+ stanza = xmpp.Iq(sBase[9], to = self.name)
stanza.setID("Bs-i%d" % Info["outiq"].plus())
- query = xmpp.Node(Types[18])
+ query = xmpp.Node(sBase[18])
query.setNamespace(xmpp.NS_MUC_ADMIN)
arole = query.addChild("item", {attr: data, afrls: role})
if reason:
@@ -770,36 +762,36 @@ class sConf(object):
else:
handler, kdesc = handler
if not handler:
- handler = HandleResponse
+ handler = handleResponse
kdesc = {"source": kdesc}
CallForResponse(self.disp, stanza, handler, kdesc)
def outcast(self, jid, reason = str(), handler = ()):
- self.iq_sender(Types[11], jid, aRoles[0], aRoles[1], reason, handler)
+ self.iq_sender(sBase[11], jid, aRoles[0], aRoles[1], reason, handler)
def none(self, jid, reason = str(), handler = ()):
- self.iq_sender(Types[11], jid, aRoles[0], aRoles[2], reason, handler)
+ self.iq_sender(sBase[11], jid, aRoles[0], aRoles[2], reason, handler)
def member(self, jid, reason = str(), handler = ()):
- self.iq_sender(Types[11], jid, aRoles[0], aRoles[3], reason, handler)
+ self.iq_sender(sBase[11], jid, aRoles[0], aRoles[3], reason, handler)
def admin(self, jid, reason = str(), handler = ()):
- self.iq_sender(Types[11], jid, aRoles[0], aRoles[4], reason, handler)
+ self.iq_sender(sBase[11], jid, aRoles[0], aRoles[4], reason, handler)
def owner(self, jid, reason = str(), handler = ()):
- self.iq_sender(Types[11], jid, aRoles[0], aRoles[5], reason, handler)
+ self.iq_sender(sBase[11], jid, aRoles[0], aRoles[5], reason, handler)
def kick(self, nick, reason = str(), handler = ()):
- self.iq_sender(Types[12], nick, aRoles[6], aRoles[2], reason, handler)
+ self.iq_sender(sBase[12], nick, aRoles[6], aRoles[2], reason, handler)
def visitor(self, nick, reason = str(), handler = ()):
- self.iq_sender(Types[12], nick, aRoles[6], aRoles[7], reason, handler)
+ self.iq_sender(sBase[12], nick, aRoles[6], aRoles[7], reason, handler)
def participant(self, nick, reason = str(), handler = ()):
- self.iq_sender(Types[12], nick, aRoles[6], aRoles[8], reason, handler)
+ self.iq_sender(sBase[12], nick, aRoles[6], aRoles[8], reason, handler)
def moder(self, nick, reason = str(), handler = ()):
- self.iq_sender(Types[12], nick, aRoles[6], aRoles[9], reason, handler)
+ self.iq_sender(sBase[12], nick, aRoles[6], aRoles[9], reason, handler)
def get_source(source, nick):
if source in Chats:
@@ -815,7 +807,7 @@ def get_access(source, nick):
enough_access = lambda conf, nick, access = 0: (access <= get_access(conf, nick))
-object_encode = lambda obj: (obj if isinstance(obj, UnicodeType) else str(obj).decode("utf-8", "replace"))
+object_encode = lambda obj: (obj if isinstance(obj, unicode) else str(obj).decode("utf-8", "replace"))
def delivery(body):
try:
@@ -828,12 +820,12 @@ def delivery(body):
if not online(Disp):
raise SelfExc("disconnected!")
Info["omsg"].plus()
- Clients[Disp].send(xmpp.Message(GodName, body, Types[0]))
+ Clients[Disp].send(xmpp.Message(GodName, body, sBase[0]))
except IOError:
Print("\n\n%s" % (body), color1)
except SelfExc:
Print("\n\n%s" % (body), color1)
- except iThr.ThrKill:
+ except ithr.ThrKill:
raise
except Exception:
exc_info_()
@@ -841,14 +833,14 @@ def delivery(body):
def Message(inst, body, disp = None):
body = object_encode(body)
if inst in Chats:
- stype = Types[1]
+ stype = sBase[1]
if not disp:
disp = Chats[inst].disp
if len(body) > ConfLimit:
Chats[inst].more = body[ConfLimit:].strip()
body = AnsBase[18] % (body[:ConfLimit].strip(), ConfLimit)
else:
- stype = Types[0]
+ stype = sBase[0]
if not disp:
if isinstance(inst, xmpp.JID):
chat = inst.getStripped()
@@ -870,7 +862,7 @@ def Message(inst, body, disp = None):
Sender(disp, xmpp.Message(inst, body.strip(), stype))
def Answer(body, stype, source, disp = None):
- if stype == Types[0]:
+ if stype == sBase[0]:
instance = source[0]
else:
body = "%s: %s" % (source[2], object_encode(body))
@@ -911,11 +903,11 @@ def ejoinTimer(conf):
if conf in Chats:
Chats[conf].join()
-ejoinTimerName = lambda conf: "%s-%s" % (ejoinTimer.func_name, conf.decode("utf-8"))
+ejoinTimerName = lambda conf: "%s-%s" % (ejoinTimer.__name__, conf.decode("utf-8"))
get_disp = lambda disp: "%s@%s" % (disp._owner.User, disp._owner.Server) if isinstance(disp, (xmpp.Client, xmpp.dispatcher.Dispatcher)) else disp
-get_nick = lambda chat: getattr(Chats.get(chat), Types[12], DefNick)
+get_nick = lambda chat: getattr(Chats.get(chat), sBase[12], DefNick)
def online(disp):
disp = get_disp(disp)
@@ -942,14 +934,12 @@ def ResponseChecker(disp, iq):
Disp, ID = disp._owner, iq.getID()
if ID in Disp.RespExp:
(handler, kdesc) = Disp.RespExp.pop(ID)
- sThread(handler.func_name, exec_bsExp, (handler, disp, iq, kdesc))
+ sThread(getattr(handler, "__name__"), exec_bsExp, (handler, disp, iq, kdesc))
xmpp_raise()
-def HandleResponse(disp, stanza, source):
- if xmpp.isResultNode(stanza):
- Answer(AnsBase[4], source[0], source[1], disp)
- else:
- Answer(AnsBase[7], source[0], source[1], disp)
+def handleResponse(disp, stanza, source):
+ stype, source = source[:2]
+ Answer(AnsBase[4 if xmpp.isResultNode(stanza) else 7], stype, source, disp)
def Sender(disp, stanza):
try:
@@ -960,18 +950,18 @@ def Sender(disp, stanza):
disp.send(stanza)
except IOError:
pass
- except SelfExc, exc:
+ except SelfExc as exc:
Print(exc_str(exc, "\n\n%s: %s!"), color2)
- except iThr.ThrKill:
+ except ithr.ThrKill:
raise
except Exeption:
collectExc(Sender)
-sUnavailable = lambda disp, data: Sender(disp, xmpp.Presence(typ = Types[4], status = data))
+sUnavailable = lambda disp, data: Sender(disp, xmpp.Presence(typ = sBase[4], status = data))
-def caps_add(Node):
- Node.setTag("c", {"node": Caps, "ver": CapsVer}, xmpp.NS_CAPS)
- return Node
+def caps_add(node):
+ node.setTag("c", {"node": Caps, "ver": CapsVer}, xmpp.NS_CAPS)
+ return node
Yday = lambda: getattr(time.gmtime(), "tm_yday")
@@ -983,7 +973,7 @@ def sAttrs(stanza):
return (source, instance.lower(),
stype, resource)
-GetRole = lambda Node: (str(Node.getAffiliation()), str(Node.getRole()))
+GetRole = lambda node: (str(node.getAffiliation()), str(node.getRole()))
def xmpp_raise():
raise xmpp.NodeProcessed("continue")
@@ -1020,51 +1010,51 @@ def cat_file(filename, data, otype = "wb"):
# Crashlogs
def collectDFail():
- crashfile = open(GenCrash, "ab")
- exc_info_(crashfile)
- crashfile.close()
+ with open(GenCrash, "ab") as fp:
+ exc_info_(fp)
-def collectExc(instance, command = None):
- Number, instance, error_body = (len(VarCache["errors"]) + 1), instance.func_name, get_exc()
- VarCache["errors"].append(error_body)
+def collectExc(inst, command = None):
+ error = get_exc()
+ VarCache["errors"].append(error)
+ inst, number = getattr(inst, "__name__") or str(inst), len(VarCache["errors"])
if GetExc and online(GenDisp):
if command:
- exception = AnsBase[13] % (command, instance)
+ exception = AnsBase[13] % (command, inst)
else:
- exception = AnsBase[14] % (instance)
+ exception = AnsBase[14] % (inst)
delivery(AnsBase[15] % exception)
else:
- Print("\n\nError: can't execute '%s'!" % (instance), color2)
- filename = "%s/error[%d]%s.crash" % (FailDir, (Info["cfw"]._int() + 1), strfTime("[%H.%M.%S][%d.%m.%Y]"))
+ Print("\n\nError: can't execute '%s'!" % (inst), color2)
+ filename = "%s/error[%d]%s.crash" % (FailDir, int(Info["cfw"]) + 1, strfTime("[%H.%M.%S][%d.%m.%Y]"))
try:
if not os.path.exists(FailDir):
os.mkdir(FailDir, 0755)
- crashfile = open(filename, "wb")
- Info["cfw"].plus()
- exc_info_(crashfile)
- crashfile.close()
- if GetExc and online(GenDisp):
- if oSlist[0]:
- delivery(AnsBase[16] % (Number, filename))
- else:
- delivery(AnsBase[17] % (Number, filename))
- else:
- Print("\n\nCrash file --> %s\nError's number --> %d" % (filename, Number), color2)
+ with open(filename, "wb") as fp:
+ Info["cfw"].plus()
+ exc_info_(fp)
except:
exc_info_()
if GetExc and online(GenDisp):
- delivery(error_body)
+ delivery(error)
+ else:
+ Print(error, color2)
+ else:
+ if GetExc and online(GenDisp):
+ if OSList[0]:
+ delivery(AnsBase[16] % (number, filename))
+ else:
+ delivery(AnsBase[17] % (number, filename))
else:
- Print(error_body, color2)
+ Print("\n\nCrash file --> %s\nError's number --> %d" % (filename, number), color2)
# Other functions
def load_expansions():
Print("\n\nExpansions loading...\n", color4)
- for ExpDir in sorted(os.listdir(ExpsDir)):
- if (".svn" == ExpDir) or not os.path.isdir(os.path.join(ExpsDir, ExpDir)):
+ for expDir in sorted(os.listdir(ExpsDir)):
+ if (".svn" == expDir) or not os.path.isdir(os.path.join(ExpsDir, expDir)):
continue
- exp = expansion(ExpDir)
+ exp = expansion(expDir)
if exp.isExp:
exp, exc = exp.load()
if exp:
@@ -1073,19 +1063,19 @@ def load_expansions():
except:
exc = exc_info()
exp.dels(True)
- Print("Can't init - %s!%s" % (ExpDir, "\n\t* %s: %s" % exc), color2)
+ Print("Can't init - %s!%s" % (expDir, "\n\t* %s: %s" % exc), color2)
else:
- Print("%s - successfully loaded!" % (ExpDir), color3)
+ Print("%s - successfully loaded!" % (expDir), color3)
else:
- Print("Can't load - %s!%s" % (ExpDir, "\n\t* %s: %s" % exc), color2)
+ Print("Can't load - %s!%s" % (expDir, "\n\t* %s: %s" % exc), color2)
else:
- Print("%s - isn't an expansion!" % (ExpDir), color2)
+ Print("%s - isn't an expansion!" % (expDir), color2)
def get_pipe(command):
try:
with os.popen(command) as pipe:
data = pipe.read()
- if oSlist[0]:
+ if OSList[0]:
data = data.decode("cp866")
except Exception:
data = "(...)"
@@ -1218,52 +1208,52 @@ isNumber = lambda obj: (not apply(int, (obj,)) is None)
isSource = lambda jid: isJID.match(jid)
-def calculate(Numb = int()):
- if oSlist[0]:
- lines = get_pipe(sys_cmds[1] % (BsPid)).splitlines()
+def calculate(numb = int()):
+ if OSList[0]:
+ lines = get_pipe(cmdsDb[1] % (BsPid)).splitlines()
if len(lines) >= 3:
list = lines[3].split()
if len(list) > 5:
- Numb = (list[4] + list[5])
+ numb = (list[4] + list[5])
else:
- lines = get_pipe(sys_cmds[0] % (BsPid)).splitlines()
+ lines = get_pipe(cmdsDb[0] % (BsPid)).splitlines()
if len(lines) >= 2:
- Numb = lines[1].strip()
- return (0 if not isNumber(Numb) else int(Numb))
+ numb = lines[1].strip()
+ return (0 if not isNumber(numb) else int(numb))
def check_copies():
- Cache = Base = {"PID": BsPid, "up": Info["sess"], "alls": []}
+ cache = base = {"PID": BsPid, "up": Info["sess"], "alls": []}
if os.path.isfile(PidFile):
try:
- Cache = eval(get_file(PidFile))
+ cache = eval(get_file(PidFile))
except SyntaxError:
del_file(PidFile)
except:
pass
else:
try:
- if BsPid == Cache["PID"]:
- Cache["alls"].append(strfTime())
- elif oSlist[0]:
- get_pipe(sys_cmds[4] % (Cache["PID"])); raise SelfExc()
+ if BsPid == cache["PID"]:
+ cache["alls"].append(strfTime())
+ elif OSList[0]:
+ get_pipe(cmdsDb[4] % (cache["PID"])); raise SelfExc()
else:
- os.kill(Cache["PID"], 9); raise SelfExc()
+ os.kill(cache["PID"], 9); raise SelfExc()
except:
- Cache = Base
- apply(cat_file, (PidFile, str(Cache)))
- del Cache["PID"]; Info.update(Cache)
+ cache = base
+ apply(cat_file, (PidFile, str(cache)))
+ del cache["PID"]; Info.update(cache)
def join_chats():
if initialize_file(ChatsFile):
try:
try:
- Confs = eval(get_file(ChatsFile))
+ confs = eval(get_file(ChatsFile))
except SyntaxError:
- Confs = eval(get_file(ChatsFileBackup))
+ confs = eval(get_file(ChatsFileBackup))
except Exception:
- Confs = {}
- Print("\n\nThere are %d rooms in the list..." % len(Confs.keys()), color4)
- for conf, desc in Confs.iteritems():
+ confs = {}
+ Print("\n\nThere are %d rooms in the list..." % len(confs.keys()), color4)
+ for conf, desc in confs.iteritems():
Chats[conf] = Chat = sConf(conf, added = True, **desc)
Chat.load_all()
if Chat.disp in Clients:
@@ -1281,7 +1271,7 @@ def XmppPresenceCB(disp, stanza):
(source, conf, stype, nick) = sAttrs(stanza)
if not enough_access(conf, nick):
xmpp_raise()
- if stype == Types[5]:
+ if stype == sBase[5]:
disp = disp._owner
if disp.Roster:
if enough_access(conf, nick, 7):
@@ -1293,11 +1283,11 @@ def XmppPresenceCB(disp, stanza):
disp.Roster.setItem(conf, conf, ["Users"])
disp.Roster.Subscribe(conf)
else:
- Sender(disp, xmpp.Presence(conf, Types[7]))
+ Sender(disp, xmpp.Presence(conf, sBase[7]))
xmpp_raise()
elif conf in Chats:
Chat = Chats[conf]
- if stype == Types[7]:
+ if stype == sBase[7]:
ecode = stanza.getErrorCode()
if ecode:
if ecode == eCodes[9]:
@@ -1306,23 +1296,23 @@ def XmppPresenceCB(disp, stanza):
elif ecode in (eCodes[5], eCodes[12]):
Chat.IamHere = False
TimerName = ejoinTimerName(conf)
- if TimerName not in iThr.getNames():
+ if TimerName not in ithr.getNames():
try:
composeTimer(360, ejoinTimer, TimerName, (conf,)).start()
- except iThr.error:
+ except ithr.error:
delivery(AnsBase[20] % (ecode, eCodesDesc[ecode], conf))
except:
- collectExc(iThr.Thread.start)
+ collectExc(ithr.Thread.start)
elif ecode == eCodes[4]:
Chat.full_leave(eCodesDesc[ecode])
delivery(AnsBase[21] % (ecode, eCodesDesc[ecode], conf))
elif ecode in (eCodes[2], eCodes[6]):
Chat.leave(eCodesDesc[ecode])
delivery(AnsBase[22] % (ecode, eCodesDesc[ecode], conf))
- elif stype in (Types[3], None):
+ elif stype in (sBase[3], None):
if Chat.nick == nick:
Chat.IamHere = True
- Role = GetRole(stanza)
+ role = GetRole(stanza)
inst = stanza.getJid()
if not inst:
if Chat.isModer:
@@ -1335,16 +1325,16 @@ def XmppPresenceCB(disp, stanza):
xmpp_raise()
else:
inst = (inst.split(chr(47)))[0].lower()
- if not Chat.isModer and Chat.nick == nick and aDesc.get(Role[0], 0) >= 2:
+ if not Chat.isModer and Chat.nick == nick and aDesc.get(role[0], 0) >= 2:
Chat.isModer = True
Chat.leave(AnsBase[25])
sleep(0.4)
Chat.join(); xmpp_raise()
if Chat.isHereTS(nick) and Chat.isHe(nick, inst):
- Chat.aroles_change(nick, Role, stanza)
+ Chat.aroles_change(nick, role, stanza)
else:
- Chat.sjoined(nick, Role, inst, stanza)
- elif stype == Types[4]:
+ Chat.sjoined(nick, role, inst, stanza)
+ elif stype == sBase[4]:
scode = stanza.getStatusCode()
if Chat.nick == nick and scode in (sCodes[0], sCodes[2]):
Chat.full_leave(sCodesDesc[scode])
@@ -1360,11 +1350,11 @@ def XmppPresenceCB(disp, stanza):
inst = stanza.getJid()
if inst:
inst = (inst.split(chr(47)))[0].lower()
- Role = GetRole(stanza)
+ role = GetRole(stanza)
if Chat.isHereTS(Nick) and Chat.isHe(Nick, inst):
- Chat.aroles_change(Nick, Role, stanza)
+ Chat.aroles_change(Nick, role, stanza)
else:
- Chat.sjoined(Nick, Role, inst, stanza)
+ Chat.sjoined(Nick, role, inst, stanza)
else:
Status = (stanza.getReason() or stanza.getStatus())
if Chat.isHereTS(nick):
@@ -1381,49 +1371,48 @@ def XmppIqCB(disp, stanza):
(source, inst, stype, nick) = sAttrs(stanza)
if not enough_access(inst, nick):
xmpp_raise()
- if stype == Types[10]:
- Name = stanza.getQueryNS()
- if not Name:
- Name = (stanza.getTag(Types[16]) or stanza.getTag(Types[17]))
- if Name:
- Name = Name.getNamespace()
- if Name in IqXEPs:
- answer = stanza.buildReply(Types[8])
- if Name == xmpp.NS_DISCO_INFO:
- anode = answer.getTag(Types[18])
+ if stype == sBase[10]:
+ ns = stanza.getQueryNS()
+ if not ns:
+ ns = stanza.getTag(sBase[16]) or stanza.getTag(sBase[17])
+ ns = ns and ns.getNamespace()
+ if ns in IqXEPs:
+ answer = stanza.buildReply(sBase[8])
+ if ns == xmpp.NS_DISCO_INFO:
+ anode = answer.getTag(sBase[18])
anode.addChild("identity", {"category": "client",
"type": "bot",
"name": ProdName[:10]})
for feature in XEPs:
anode.addChild("feature", {"var": feature})
- elif Name == xmpp.NS_LAST:
- anode = answer.getTag(Types[18])
+ elif ns == xmpp.NS_LAST:
+ anode = answer.getTag(sBase[18])
anode.setAttr("seconds", int(time.time() - VarCache["idle"]))
anode.setData(VarCache["action"])
- elif Name == xmpp.NS_VERSION:
- anode = answer.getTag(Types[18])
+ elif ns == xmpp.NS_VERSION:
+ anode = answer.getTag(sBase[18])
anode.setTagData("name", ProdName)
anode.setTagData("version", ProdVer)
Python = "{0} [{1}.{2}.{3}]".format(sys.subversion[0], *sys.version_info)
- if oSlist[0]:
- Os = get_pipe(sys_cmds[5]).strip()
- elif oSlist[1]:
+ if OSList[0]:
+ Os = get_pipe(cmdsDb[5]).strip()
+ elif OSList[1]:
Os = "{0} {2:.16} [{4}]".format(*os.uname())
else:
- Os = BotOs.capitalize()
+ Os = BotOS.capitalize()
anode.setTagData("os", "%s / %s" % (Os, Python))
- elif Name == xmpp.NS_URN_TIME:
- anode = answer.addChild(Types[17], namespace = xmpp.NS_URN_TIME)
+ elif ns == xmpp.NS_URN_TIME:
+ anode = answer.addChild(sBase[17], namespace = xmpp.NS_URN_TIME)
anode.setTagData("utc", strfTime("%Y-%m-%dT%H:%M:%SZ", False))
TimeZone = (time.altzone if time.daylight else time.timezone)
anode.setTagData("tzo", "%s%02d:%02d" % (((TimeZone < 0) and "+" or "-"),
abs(TimeZone) / 3600,
abs(TimeZone) / 60 % 60))
- elif Name == xmpp.NS_TIME:
- anode = answer.getTag(Types[18])
+ elif ns == xmpp.NS_TIME:
+ anode = answer.getTag(sBase[18])
anode.setTagData("utc", strfTime("%Y%m%dT%H:%M:%S", False))
tz = strfTime("%Z")
- if oSlist[0]:
+ if OSList[0]:
tz = tz.decode("cp1251")
anode.setTagData("tz", tz)
anode.setTagData("display", time.asctime())
@@ -1455,20 +1444,20 @@ def XmppMessageCB(disp, stanza):
if not Roster["on"]:
xmpp_raise()
CheckFlood(disp)
- BotNick = (Chat.nick if isConf else DefNick)
- if nick == BotNick:
+ botNick = (Chat.nick if isConf else DefNick)
+ if nick == botNick:
xmpp_raise()
- Subject = isConf and stanza.getSubject()
+ subject = isConf and stanza.getSubject()
body = stanza.getBody()
if body:
body = body.strip()
- elif Subject:
- body = Subject.strip()
+ elif subject:
+ body = subject.strip()
if not body:
xmpp_raise()
if len(body) > IncLimit:
body = "%s[...] %d symbols limit." % (body[:IncLimit].strip(), IncLimit)
- if stype == Types[7]:
+ if stype == sBase[7]:
code = stanza.getErrorCode()
if code in (eCodes[10], eCodes[7]):
if code == eCodes[7]:
@@ -1478,18 +1467,18 @@ def XmppMessageCB(disp, stanza):
sleep(0.6)
Message(source, body)
xmpp_raise()
- if Subject:
- call_efunctions("09eh", (inst, nick, Subject, body, disp,))
+ if subject:
+ call_efunctions("09eh", (inst, nick, subject, body, disp,))
else:
- temp, isToBs = body, (stype == Types[0])
- if stype != Types[1]:
- if (stanza.getTag(Types[14])):
+ temp, isToBs = body, (stype == sBase[0])
+ if stype != sBase[1]:
+ if (stanza.getTag(sBase[14])):
answer = xmpp.Message(source)
- answer.setTag(Types[15], namespace = xmpp.NS_RECEIPTS).setAttr("id", stanza.getID())
+ answer.setTag(sBase[15], namespace = xmpp.NS_RECEIPTS).setAttr("id", stanza.getID())
answer.setID(stanza.getID())
Sender(disp, answer)
- stype = Types[0]
- for app in [(BotNick + Key) for Key in (":", ",", ">")]:
+ stype = sBase[0]
+ for app in [(botNick + key) for key in (":", ",", ">")]:
if temp.startswith(app):
temp, isToBs = temp[len(app):].lstrip(), True
break
@@ -1517,44 +1506,43 @@ def XmppMessageCB(disp, stanza):
# Connecting & Dispatching
-def connect_client(source, InstanceAttrs):
- (server, cport, host, user, code) = InstanceAttrs
+def connect_client(inst, attrs):
+ (server, cport, host, user, password) = attrs
disp = xmpp.Client(host, cport, None)
- Print("\n\n'%s' connecting..." % (source), color4)
+ Print("\n\n'%s' connecting..." % inst, color4)
if ConTls:
- ConType = (None, False)
+ conType = (None, False)
else:
- ConType = (False, True)
+ conType = (False, True)
try:
- ConType = disp.connect((server, cport), None, *ConType)
- except Exception, exc:
- Print("\n'%s' can't connect to '%s' (Port: %s).\n\t%s\nI'll retry later..." % (source, server.upper(), cport, exc_str(exc)), color2)
+ conType = disp.connect((server, cport), None, *conType)
+ except Exception as exc:
+ Print("\n'%s' can't connect to '%s' (Port: %s).\n\t%s\nI'll retry later..." % (inst, server.upper(), cport, exc_str(exc)), color2)
return (False, None)
- if ConType:
- ConType = ConType.upper()
- if ConTls and ConType != "TLS":
- Print("\n'%s' was connected, but a connection isn't secure." % (source), color1)
+ if conType:
+ conType = conType.upper()
+ if ConTls and conType != "TLS":
+ Print("\n'%s' was connected, but a connection isn't secure." % inst, color1)
else:
- Print("\n'%s' was successfully connected!" % (source), color3)
- Print("\n'%s' using - '%s'" % (source, ConType), color4)
+ Print("\n'%s' was successfully connected!" % inst, color3)
+ Print("\n'%s' using - '%s'" % (inst, conType), color4)
else:
- Print("\n'%s' can't connect to '%s' (Port: %s). I'll retry later..." % (source, server.upper(), cport), color2)
+ Print("\n'%s' can't connect to '%s' (Port: %s). I'll retry later..." % (inst, server.upper(), cport), color2)
return (False, None)
- Print("\n'%s' authenticating..." % (source), color4)
+ Print("\n'%s' authenticating, wait..." % inst, color4)
try:
- Auth = disp.auth(user, code, GenResource)
- except Exception, exc:
- Print("Can't authenticate '%s'!\n\t%s" % (source, exc_str(exc)), color2)
+ auth = disp.auth(user, password, GenResource)
+ except Exception as exc:
+ Print("Can't authenticate '%s'!\n\t%s" % (inst, exc_str(exc)), color2)
return (False, eCodes[2])
- if Auth == "sasl":
- Print("\n'%s' was successfully authenticated!" % (source), color3)
- elif Auth:
- Print("\n'%s' was authenticated, but old authentication method used..." % (source), color1)
+ if auth == "sasl":
+ Print("\n'%s' was successfully authenticated!" % inst, color3)
+ elif auth:
+ Print("\n'%s' was authenticated, but old authentication method used..." % inst, color1)
else:
- eBody = str(disp.lastErr)
- eCode = str(disp.lastErrCode)
- Print("Can't authenticate '%s'! Error: '%s' (%s)" % (source, eCode, eBody), color2)
- return (False, eCode)
+ error, code = disp.lastErr, disp.lastErrCode
+ Print("Can't authenticate '%s'! Error: '%s' (%s)" % (inst, code, error), color2)
+ return (False, code)
try:
disp.getRoster()
except IOError:
@@ -1568,12 +1556,12 @@ def connect_client(source, InstanceAttrs):
disp.RegisterHandler(xmpp.NS_PRESENCE, XmppPresenceCB)
disp.RegisterHandler(xmpp.NS_IQ, XmppIqCB)
disp.RegisterHandler(xmpp.NS_MESSAGE, XmppMessageCB)
- Clients[source] = disp
+ Clients[inst] = disp
Sender(disp, caps_add(xmpp.Presence(show = sList[0], status = DefStatus)))
- return (True, source)
+ return (True, inst)
def connectAndDispatch(disp):
- if ReverseDisp(disp, False):
+ if reverseDisp(disp, False):
sleep(60)
for conf in Chats.itervalues():
if disp == conf.disp:
@@ -1583,16 +1571,16 @@ def connectAndDispatch(disp):
delivery(AnsBase[28] % (disp))
def connect_clients():
- for Inctance, Attrs in InstancesDesc.items():
- conn = connect_client(Inctance, Attrs)
+ for inst, attrs in InstancesDesc.items():
+ conn = connect_client(inst, attrs)
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, "%s-%s" % (sBase[13], inst), (inst,)).start()
-def ReverseDisp(disp, rejoin = True):
- Iters = itypes.Number()
- while 1440 > Iters.plus():
+def reverseDisp(disp, rejoin = True):
+ iters = itypes.Number()
+ while 1440 > iters.plus():
if connect_client(disp, InstancesDesc[disp])[0]:
if rejoin:
for conf in Chats.itervalues():
@@ -1612,11 +1600,11 @@ def Dispatcher(disp):
raise IOError("disconnected!")
except KeyboardInterrupt:
break
- except iThr.ThrKill:
+ except ithr.ThrKill:
break
except IOError:
disp = get_disp(disp)
- if not ReverseDisp(disp):
+ if not reverseDisp(disp):
delivery(AnsBase[28] % (disp))
break
disp = Clients[disp]
@@ -1626,7 +1614,7 @@ def Dispatcher(disp):
break
except xmpp.SystemShutdown:
disp = get_disp(disp)
- if not ReverseDisp(disp):
+ if not reverseDisp(disp):
delivery(AnsBase[28] % (disp))
break
disp = Clients[disp]
@@ -1653,16 +1641,16 @@ 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)
- if ThrName not in iThr.getNames():
- composeThr(Dispatcher, ThrName, (disp,)).start()
+ thrName = "%s-%s" % (sBase[13], disp)
+ if thrName not in ithr.getNames():
+ composeThr(Dispatcher, thrName, (disp,)).start()
while VarCache["alive"]:
sleep(180)
- Cls = itypes.Number()
- for Name in iThr.getNames():
- if Name.startswith(Types[13]):
- Cls.plus()
- if not int(Cls):
+ threads = 0
+ for name in ithr.getNames():
+ if name.startswith(sBase[13]):
+ threads += 1
+ if not threads:
sys_exit("All of the clients now fallen!")
sys.exc_clear()
gc.collect()
@@ -1672,7 +1660,7 @@ def load_mark2():
def sys_exit(exit_desclr = "Suicide!"):
VarCache["alive"] = False
Print("\n\n%s" % (exit_desclr), color2)
- iThr.killAllThreads()
+ ithr.killAllThreads()
for disp in Clients.keys():
if online(disp):
sUnavailable(disp, exit_desclr)
diff --git a/expansions/access/code.py b/expansions/access/code.py
index 282588d..58381ff 100644
--- a/expansions/access/code.py
+++ b/expansions/access/code.py
@@ -23,7 +23,7 @@ class expansion_temp(expansion):
"Owner", # 6
"Chief", # 7
"God" # 8
- )
+ )
def get_acc(self, access):
if access > 8:
@@ -55,26 +55,26 @@ class expansion_temp(expansion):
def command_get_galist(self, stype, source, body, disp):
if Galist:
ls = sorted([(acc, user) for user, acc in Galist.iteritems()], reverse = True)
- if stype == Types[1]:
+ if stype == sBase[1]:
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]
- if locals().has_key(Types[6]):
+ if locals().has_key(sBase[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:
ls = sorted([(acc, user) for user, acc in Chats[source[1]].alist.iteritems()], reverse = True)
- if stype == Types[1]:
+ if stype == sBase[1]:
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:
answer = AnsBase[0]
- if locals().has_key(Types[6]):
+ if locals().has_key(sBase[6]):
Answer(answer, stype, source, disp)
def command_set_access(self, stype, source, body, disp):
@@ -204,9 +204,9 @@ class expansion_temp(expansion):
(command_get_lalist, "acclist2", 4,),
(command_set_access, "gaccess", 8,),
(command_set_local_access, "laccess", 6,)
- )
+ )
handlers = (
(load_acclist, "00si"),
(load_local_acclist, "01si")
- )
+ )
diff --git a/expansions/access/insc.py b/expansions/access/insc.py
index 21c847b..4dc5db7 100644
--- a/expansions/access/insc.py
+++ b/expansions/access/insc.py
@@ -13,7 +13,7 @@ if DefLANG in ("RU", "UA"):
"Нельзя дать локальный доступ меньше 0 и больше 6.", # 8
"У «%s» глобальный доступ.", # 9
"Не могу дать доступ «%s»." # 10
- )])
+ )])
else:
AnsBase_temp = (
"Your access - %s.", # 0
@@ -27,4 +27,4 @@ else:
"You can't give local access < 0 & > 6.", # 8
"'%s' has global access.", # 9
"I can't give access to '%s'." # 10
- ) \ No newline at end of file
+ ) \ No newline at end of file
diff --git a/expansions/alive_keeper/code.py b/expansions/alive_keeper/code.py
index af8c6ea..2c8ae73 100644
--- a/expansions/alive_keeper/code.py
+++ b/expansions/alive_keeper/code.py
@@ -18,33 +18,33 @@ class expansion_temp(expansion):
while VarCache["alive"]:
sleep(120)
- ThrIds = iThr.getNames()
+ thrIds = ithr.getNames()
for disp_str, disp in Clients.iteritems():
if not hasattr(disp, "aKeeper"):
disp.aKeeper = itypes.Number()
- if disp.aKeeper._int() >= 3:
+ if disp.aKeeper > 2:
disp.aKeeper = itypes.Number()
- ThrName = "%s-%s" % (Types[13], disp_str)
- if ThrName in ThrIds:
- for Thr in iThr.enumerate():
- if ThrName == Thr.getName():
- Thr.kill()
+ thrName = "%s-%s" % (sBase[13], disp_str)
+ if thrName in thrIds:
+ for thr in ithr.enumerate():
+ if thrName == thr.getName():
+ thr.kill()
try:
- composeThr(connectAndDispatch, ThrName, (disp_str,)).start()
- except iThr.error:
+ composeThr(connectAndDispatch, thrName, (disp_str,)).start()
+ except ithr.error:
delivery(AnsBase[28] % (disp_str))
except:
- collectExc(iThr.Thread.start)
+ collectExc(ithr.Thread.start)
elif expansions.has_key(self.name):
disp.aKeeper.plus()
- iq = xmpp.Iq(Types[10], to = "%s/%s" % (disp_str, GenResource))
- iq.addChild(Types[16], namespace = xmpp.NS_PING)
+ iq = xmpp.Iq(sBase[10], to = "%s/%s" % (disp_str, GenResource))
+ iq.addChild(sBase[16], namespace = xmpp.NS_PING)
iq.setID("Bs-i%d" % Info["outiq"].plus())
CallForResponse(disp_str, iq, alive_keeper_answer)
del iq
else:
- raise iThr.ThrKill("exit")
- del ThrIds
+ raise ithr.ThrKill("exit")
+ del thrIds
def conf_alive_keeper(self):
@@ -58,39 +58,39 @@ class expansion_temp(expansion):
while VarCache["alive"]:
sleep(360)
- ThrIds = iThr.getNames()
+ thrIds = ithr.getNames()
for conf in Chats.itervalues():
if not (online(conf.disp) and conf.IamHere):
continue
if not hasattr(conf, "aKeeper"):
conf.aKeeper = itypes.Number()
- if conf.aKeeper._int() >= 3:
+ if conf.aKeeper > 2:
conf.aKeeper = itypes.Number()
TimerName = ejoinTimerName(conf.name)
- if TimerName not in ThrIds:
+ if TimerName not in thrIds:
try:
composeTimer(180, ejoinTimer, TimerName, (conf.name,)).start()
- except iThr.error:
+ except ithr.error:
pass
except:
- collectExc(iThr.Thread.start)
+ collectExc(ithr.Thread.start)
elif expansions.has_key(self.name):
conf.aKeeper.plus()
- iq = xmpp.Iq(Types[10], to = "%s/%s" % (conf.name, conf.nick))
- iq.addChild(Types[18], namespace = xmpp.NS_PING)
+ iq = xmpp.Iq(sBase[10], to = "%s/%s" % (conf.name, conf.nick))
+ iq.addChild(sBase[18], namespace = xmpp.NS_PING)
iq.setID("Bs-i%d" % Info["outiq"].plus())
CallForResponse(conf.disp, iq, conf_alive_keeper_answer, {"conf": conf.name})
del iq
else:
- raise iThr.ThrKill("exit")
- del ThrIds
+ raise ithr.ThrKill("exit")
+ del thrIds
def start_keepers(self):
- Name1 = self.alive_keeper.func_name
- Name2 = self.conf_alive_keeper.func_name
- for Thr in iThr.enumerate():
- if Thr.name.startswith((Name1, Name2)):
- Thr.kill()
+ Name1 = self.alive_keeper.__name__
+ Name2 = self.conf_alive_keeper.__name__
+ for thr in ithr.enumerate():
+ if thr.name.startswith((Name1, Name2)):
+ thr.kill()
composeThr(self.alive_keeper, Name1).start()
composeThr(self.conf_alive_keeper, Name2).start()
diff --git a/expansions/allweb/code.py b/expansions/allweb/code.py
index e9cf6c0..e5f41ca 100644
--- a/expansions/allweb/code.py
+++ b/expansions/allweb/code.py
@@ -32,7 +32,7 @@ class expansion_temp(expansion):
TagsDesc = {
"<br>": chr(10),
"<br />": chr(10)
- }
+ }
compile_st = compile__("<[^<>]+?>")
compile_ehtmls = compile__("&(#?[xX]?(?:[0-9a-fA-F]+|\w{1,8}));")
@@ -77,7 +77,7 @@ class expansion_temp(expansion):
Opener = Web("http://jc.jabber.ru/search.html?", [("search", cName.encode("utf-8"))])
try:
data = Opener.get_page(self.UserAgent)
- except Web.Two.HTTPError, exc:
+ except Web.Two.HTTPError as exc:
answer = str(exc)
except:
answer = self.AnsBase[0]
@@ -108,7 +108,7 @@ class expansion_temp(expansion):
Opener = Web("http://ajax.googleapis.com/ajax/services/search/web?", [("v", "1.0"), ("q", body.encode("utf-8"))])
try:
data = Opener.get_page(self.UserAgent)
- except Web.Two.HTTPError, exc:
+ except Web.Two.HTTPError as exc:
answer = str(exc)
except:
answer = self.AnsBase[0]
@@ -183,7 +183,7 @@ class expansion_temp(expansion):
Opener = Web("http://translate.google.com/translate_a/t?", desc, headers = {"Accept-Charset": "utf-8"})
try:
data = Opener.get_page(self.UserAgent_Moz)
- except Web.Two.HTTPError, exc:
+ except Web.Two.HTTPError as exc:
answer = str(exc)
except:
answer = self.AnsBase[0]
@@ -246,7 +246,7 @@ class expansion_temp(expansion):
answer = self.AnsBase[3]
else:
answer = self.AnsBase[8] + str.join(chr(10), ["%s - %s" % (k, l) for k, l in sorted(self.LangMap.items())])
- if stype == Types[1]:
+ if stype == sBase[1]:
Message(source[0], answer, disp)
answer = AnsBase[11]
Answer(answer, stype, source, disp)
@@ -256,7 +256,7 @@ class expansion_temp(expansion):
"Accept": "text/html",
"Accept-Charset": "cp1251",
"Accept-Language": "ru"
- }
+ }
C3oP = "СЗоР"
@@ -276,7 +276,7 @@ class expansion_temp(expansion):
Opener = Web("http://www.kinopoisk.ru/level/20/", headers = kinoHeaders)
try:
data = Opener.get_page(self.UserAgent_Moz)
- except Web.Two.HTTPError, exc:
+ except Web.Two.HTTPError as exc:
answer = str(exc)
except:
answer = self.AnsBase[0]
@@ -294,7 +294,7 @@ class expansion_temp(expansion):
if limit and limit <= Number:
break
if not limit or limit > 25:
- if stype == Types[1]:
+ if stype == sBase[1]:
Answer(AnsBase[11], stype, source, disp)
Top250 = str.join(chr(10), ls)
Message(source[0], Top250, disp)
@@ -308,7 +308,7 @@ class expansion_temp(expansion):
Opener = Web("http://m.kinopoisk.ru/movie/%d" % int(body), headers = self.kinoHeaders.copy())
try:
data = Opener.get_page(self.UserAgent_Moz)
- except Web.Two.HTTPError, exc:
+ except Web.Two.HTTPError as exc:
answer = str(exc)
except:
answer = self.AnsBase[0]
@@ -336,7 +336,7 @@ class expansion_temp(expansion):
Opener = Web("http://m.kinopoisk.ru/search/%s" % Web.One.quote_plus(body), headers = self.kinoHeaders.copy())
try:
data = Opener.get_page(self.UserAgent_Moz)
- except Web.Two.HTTPError, exc:
+ except Web.Two.HTTPError as exc:
answer = str(exc)
except:
answer = self.AnsBase[0]
@@ -357,7 +357,7 @@ class expansion_temp(expansion):
answer = AnsBase[2]
else:
answer = AnsBase[1]
- if locals().has_key(Types[6]):
+ if locals().has_key(sBase[6]):
Answer(answer, stype, source, disp)
IMDbHeaders = {"Accept-Language": "%s,en" % UserAgents.get(DefLANG, "en-US")}
@@ -372,7 +372,7 @@ class expansion_temp(expansion):
"lang": UserAgents.get(DefLANG, "en-US"),
"aka": "simple", # or "full"
"release": "simple", # or "full"
- }
+ }
def command_imdb(self, stype, source, body, disp):
if body:
@@ -388,7 +388,7 @@ class expansion_temp(expansion):
Opener = Web("http://m.imdb.com/chart/top_json", headers = self.IMDbHeaders)
try:
data = Opener.get_page(self.UserAgent_Moz)
- except Web.Two.HTTPError, exc:
+ except Web.Two.HTTPError as exc:
answer = str(exc)
except:
answer = self.AnsBase[0]
@@ -406,9 +406,9 @@ class expansion_temp(expansion):
ls = ["\n[#] [Name, Year] [Rating] (Votes)"]
comp = compile__("([\d\.,]+).*\s([\d\.,]+)")
try:
-
+
assert isinstance(data, list)
-
+
for Number, desc in enumerate(data, 1):
Name = desc["title"]
Year = desc["extra"]
@@ -420,7 +420,7 @@ class expansion_temp(expansion):
answer = self.AnsBase[5]
else:
if not limit or limit > 25:
- if stype == Types[1]:
+ if stype == sBase[1]:
Answer(AnsBase[11], stype, source, disp)
Top250 = str.join(chr(10), ls)
Message(source[0], Top250, disp)
@@ -433,7 +433,7 @@ class expansion_temp(expansion):
Opener = Web("http://imdbapi.org/?", IMDbRequest.items())
try:
data = Opener.get_page(self.UserAgent_Moz)
- except Web.Two.HTTPError, exc:
+ except Web.Two.HTTPError as exc:
answer = str(exc)
except:
answer = self.AnsBase[0]
@@ -480,7 +480,7 @@ class expansion_temp(expansion):
Opener = Web("http://imdbapi.org/?", IMDbRequest.items())
try:
data = Opener.get_page(self.UserAgent_Moz)
- except Web.Two.HTTPError, exc:
+ except Web.Two.HTTPError as exc:
answer = str(exc)
except:
answer = self.AnsBase[0]
@@ -509,14 +509,14 @@ class expansion_temp(expansion):
answer = AnsBase[2]
else:
answer = AnsBase[1]
- if locals().has_key(Types[6]):
+ if locals().has_key(sBase[6]):
Answer(answer, stype, source, disp)
def command_python(self, stype, source, body, disp):
Opener = Web("http://python.org/")
try:
data = Opener.get_page(self.UserAgent)
- except Web.Two.HTTPError, exc:
+ except Web.Two.HTTPError as exc:
answer = str(exc)
except:
answer = self.AnsBase[0]
@@ -539,7 +539,7 @@ class expansion_temp(expansion):
Opener = Web("http://is.gd/create.php?", [("format", "json"), ("url", body.encode("utf-8"))])
try:
data = Opener.get_page(self.UserAgent)
- except Web.Two.HTTPError, exc:
+ except Web.Two.HTTPError as exc:
answer = str(exc)
except:
answer = self.AnsBase[0]
@@ -560,7 +560,7 @@ class expansion_temp(expansion):
answer = AnsBase[1]
Answer(answer, stype, source, disp)
- downloadLock = iThr.allocate_lock()
+ downloadLock = ithr.allocate_lock()
def download_process(self, info, blockNumb, blockSize, size, fb):
if not blockNumb:
@@ -626,9 +626,9 @@ class expansion_temp(expansion):
Opener = Web(link)
try:
data = Opener.download(filename, folder, self.download_process, [source[0], time.time(), disp, 0, 0], self.UserAgent)
- except Web.Two.HTTPError, exc:
+ except Web.Two.HTTPError as exc:
answer = str(exc)
- except SelfExc, exc:
+ except SelfExc as exc:
answer = "Error! %s." % exc[0].capitalize()
except:
answer = self.AnsBase[0]
@@ -662,13 +662,13 @@ class expansion_temp(expansion):
fp = Opener.open(self.UserAgent)
answer = fp.url
fp.close()
- except Web.Two.HTTPError, exc:
+ except Web.Two.HTTPError as exc:
answer = str(exc)
except:
answer = self.AnsBase[0]
else:
answer = self.AnsBase[8] + str.join(chr(10), ["%s - %s" % (k, l) for k, l in sorted(self.PasteLangs.items())])
- if stype == Types[1]:
+ if stype == sBase[1]:
Message(source[0], answer, disp)
answer = AnsBase[11]
Answer(answer, stype, source, disp)
@@ -682,7 +682,7 @@ class expansion_temp(expansion):
Opener = Web("http://chucknorrisfacts.ru/random")
try:
data = Opener.get_page(self.UserAgent)
- except Web.Two.HTTPError, exc:
+ except Web.Two.HTTPError as exc:
answer = str(exc)
except:
answer = self.AnsBase[0]
@@ -703,7 +703,7 @@ class expansion_temp(expansion):
Opener = Web("http://bash.im/random")
try:
data = Opener.get_page(self.UserAgent)
- except Web.Two.HTTPError, exc:
+ except Web.Two.HTTPError as exc:
answer = str(exc)
except:
answer = self.AnsBase[0]
@@ -723,7 +723,7 @@ class expansion_temp(expansion):
Opener = 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 = Opener.get_page(self.UserAgent)
- except Web.Two.HTTPError, exc:
+ except Web.Two.HTTPError as exc:
answer = str(exc)
except:
answer = self.AnsBase[0]
@@ -744,7 +744,7 @@ class expansion_temp(expansion):
Opener = Web("http://bash.org/?random")
try:
data = Opener.get_page(self.UserAgent)
- except Web.Two.HTTPError, exc:
+ except Web.Two.HTTPError as exc:
answer = str(exc)
except:
answer = self.AnsBase[0]
@@ -772,7 +772,7 @@ class expansion_temp(expansion):
else:
answer = AnsBase[2]
elif Code in ("list", "список".decode("utf-8")):
- if stype == Types[1]:
+ if stype == sBase[1]:
Answer(AnsBase[11], stype, source, disp)
Curls = ["\->"] + ["%s: %s" % desc for desc in sorted(self.CurrencyDesc.items())]
Message(source[0], str.join(chr(10), Curls), disp)
@@ -788,7 +788,7 @@ class expansion_temp(expansion):
Opener = Web("http://www.cbr.ru/scripts/XML_daily.asp")
try:
data = Opener.get_page(self.UserAgent)
- except Web.Two.HTTPError, exc:
+ except Web.Two.HTTPError as exc:
answer = str(exc)
except:
answer = self.AnsBase[0]
@@ -820,7 +820,7 @@ class expansion_temp(expansion):
Opener = Web("http://www.cbr.ru/scripts/XML_daily.asp")
try:
data = Opener.get_page(self.UserAgent)
- except Web.Two.HTTPError, exc:
+ except Web.Two.HTTPError as exc:
answer = str(exc)
except:
answer = self.AnsBase[0]
@@ -841,7 +841,7 @@ class expansion_temp(expansion):
Opener = Web("http://www.cbr.ru/scripts/XML_daily.asp")
try:
data = Opener.get_page(self.UserAgent)
- except Web.Two.HTTPError, exc:
+ except Web.Two.HTTPError as exc:
answer = str(exc)
except:
answer = self.AnsBase[0]
@@ -853,13 +853,13 @@ class expansion_temp(expansion):
ls, Number = ["\->"], itypes.Number()
for Code, No, Numb in sorted(list):
ls.append("%d) %s/RUB - %s/%s" % (Number.plus(), Code, No, Numb))
- if stype == Types[1]:
+ if stype == sBase[1]:
Answer(AnsBase[11], stype, source, disp)
Curls = str.join(chr(10), ls)
Message(source[0], Curls, disp)
else:
answer = self.AnsBase[1]
- if locals().has_key(Types[6]):
+ if locals().has_key(sBase[6]):
Answer(answer, stype, source, disp)
def command_jquote(self, stype, source, body, disp):
@@ -869,7 +869,7 @@ class expansion_temp(expansion):
Opener = Web("http://jabber-quotes.ru/api/read/?id=random")
try:
data = Opener.get_page(self.UserAgent)
- except Web.Two.HTTPError, exc:
+ except Web.Two.HTTPError as exc:
answer = str(exc)
except:
answer = self.AnsBase[0]
@@ -894,7 +894,7 @@ class expansion_temp(expansion):
Opener = Web("http://ithappens.ru/random")
try:
data = Opener.get_page(self.UserAgent)
- except Web.Two.HTTPError, exc:
+ except Web.Two.HTTPError as exc:
answer = str(exc)
except:
answer = self.AnsBase[0]
@@ -921,7 +921,7 @@ class expansion_temp(expansion):
Opener = Web("http://m.gismeteo.ru/citysearch/by_name/?", [("gis_search", City.encode("utf-8"))])
try:
data = Opener.get_page(self.UserAgent)
- except Web.Two.HTTPError, exc:
+ except Web.Two.HTTPError as exc:
answer = str(exc)
except:
answer = self.AnsBase[0]
@@ -934,7 +934,7 @@ class expansion_temp(expansion):
Opener = Web("http://m.gismeteo.ru/weather/%s/" % data)
try:
data = Opener.get_page(self.UserAgent)
- except Web.Two.HTTPError, exc:
+ except Web.Two.HTTPError as exc:
answer = str(exc)
except:
answer = self.AnsBase[0]
@@ -982,7 +982,7 @@ class expansion_temp(expansion):
Opener = Web("http://m.market.yandex.ru/spec.xml?hid=%d&modelid=%d" % (int(c1st), int(c2nd)))
try:
data = Opener.get_page(self.UserAgent_Moz)
- except Web.Two.HTTPError, exc:
+ except Web.Two.HTTPError as exc:
answer = str(exc)
except:
answer = self.AnsBase[0]
@@ -1004,7 +1004,7 @@ class expansion_temp(expansion):
Opener = Web("http://m.market.yandex.ru/search.xml?", [("nopreciser", "1"), ("text", body)])
try:
data = Opener.get_page(self.UserAgent_Moz)
- except Web.Two.HTTPError, exc:
+ except Web.Two.HTTPError as exc:
answer = str(exc)
except:
answer = self.AnsBase[0]
@@ -1038,7 +1038,7 @@ class expansion_temp(expansion):
(command_paste, "paste", 2,),
(command_chuck, "chuck", 2,),
(command_bash, "bash", 2,)
- )
+ )
if DefLANG in ("RU", "UA"):
commands = commands.__add__((
@@ -1048,7 +1048,7 @@ class expansion_temp(expansion):
(command_ithappens, "ithappens", 2,),
(command_gismeteo, "gismeteo", 2,),
(command_yandex_market, "market", 2,)
- ))
+ ))
CurrencyDesc = CurrencyDesc
else:
del kinoHeaders, C3oP, command_kino, command_currency, command_jquote, command_ithappens, command_gismeteo
diff --git a/expansions/allweb/insc.py b/expansions/allweb/insc.py
index 56b9ec2..ba35269 100644
--- a/expansions/allweb/insc.py
+++ b/expansions/allweb/insc.py
@@ -5,7 +5,7 @@ UserAgents = {
"UA": "ua-UA",
"FI": "fi_SE",
"EN": "en-US"
- }
+}
PasteLangs = {
"apacheconf": "ApacheConf",
@@ -105,7 +105,7 @@ PasteLangs = {
"xml+myghty": "XML+Myghty",
"xml+php": "XML+PHP",
"xml+smarty": "XML+Smarty"
- }
+}
if DefLANG in ("RU", "UA"):
AnsBase_temp = tuple([line.decode("utf-8") for line in (
@@ -123,7 +123,7 @@ if DefLANG in ("RU", "UA"):
"Сейчас в процессе другая загрузка. Попробуй позже.", # 11
"\n* Погода предоставлена Gismeteo.ru", # -2
"Запрос блокирован Кинопоиском." # -1
- )])
+ )])
LangMap = {
"af": "Африкаанс", "ar": "Арабский", "be": "Белорусский",
@@ -143,7 +143,7 @@ if DefLANG in ("RU", "UA"):
"sv": "Шведский", "sw": "Суахили", "th": "Тайский",
"tl": "Тагальский", "tr": "Турецкий", "uk": "Украинский",
"vi": "Вьетнамский", "yi": "Идиш", "zh-CN": "Китайский"
- }
+ }
CurrencyDesc = {
"AMD": "Армянский драм",
@@ -182,7 +182,7 @@ if DefLANG in ("RU", "UA"):
"UZS": "Узбекский сум",
"XDR": "Специальные права заимствования (¤)",
"ZAR": "Южноафриканский рэнд"
- }
+ }
else:
AnsBase_temp = (
"No access to the resource.", # 0
@@ -197,7 +197,7 @@ else:
"loaded - {0}%", # 9
"Download can take several minutes...", # 10
"Now I'm busy with another load. Try again later." # 11
- )
+ )
LangMap = {
"af": "Afrikaans", "ar": "Arabic", "be": "Byelorussian",
@@ -217,4 +217,4 @@ else:
"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
+} \ No newline at end of file
diff --git a/expansions/basic_control/code.py b/expansions/basic_control/code.py
index 0969e6c..19935f1 100644
--- a/expansions/basic_control/code.py
+++ b/expansions/basic_control/code.py
@@ -19,7 +19,7 @@ class expansion_temp(expansion):
if Numb.plus() >= 50:
break
- compile_chat = compile__("^[^\s'\"@<>&]+?@(?:conference|muc|chat|room|group)\.[\w-]+?\.[\.\w-]+?$")
+ compile_chat = compile__("^[^\s'\"@<>&]+?@(?:conference|muc|conf|chat|group)\.[\w-]+?\.[\.\w-]+?$")
def command_join(self, stype, source, body, disp):
if body:
@@ -74,7 +74,7 @@ class expansion_temp(expansion):
else:
answer = self.AnsBase[3] % (conf)
sleep(3.6)
- if ejoinTimerName(conf) in iThr.getNames():
+ if ejoinTimerName(conf) in ithr.getNames():
answer += self.AnsBase[13]
else:
answer = self.AnsBase[15] % (conf)
@@ -127,7 +127,7 @@ class expansion_temp(expansion):
answer = AnsBase[8]
else:
answer = AnsBase[10]
- if locals().has_key(Types[6]):
+ if locals().has_key(sBase[6]):
Answer(answer, stype, source, disp)
def command_reconnect(self, stype, source, body, disp):
@@ -136,11 +136,11 @@ class expansion_temp(expansion):
else:
Name = get_disp(disp)
if InstancesDesc.has_key(Name):
- ThrName = "%s-%s" % (Types[13], Name)
+ thrName = "%s-%s" % (sBase[13], Name)
if Clients.has_key(Name):
- for Thr in iThr.enumerate():
- if ThrName == Thr.getName():
- Thr.kill()
+ for thr in ithr.enumerate():
+ if thrName == thr.getName():
+ thr.kill()
if online(Name):
try:
Clients[Name].disconnect()
@@ -148,7 +148,7 @@ class expansion_temp(expansion):
pass
if connect_client(Name, InstancesDesc[Name])[0]:
try:
- StartThr(composeThr(Dispatcher, ThrName, (Name,)), -1)
+ startThr(composeThr(Dispatcher, thrName, (Name,)), -1)
except RuntimeError:
answer = self.AnsBase[16]
else:
@@ -171,7 +171,7 @@ class expansion_temp(expansion):
Message(conf.name, exit_desclr, conf.disp)
sleep(6)
VarCache["alive"] = False
- iThr.killAllThreads()
+ ithr.killAllThreads()
for disp in Clients.keys():
if online(disp):
sUnavailable(disp, exit_desclr)
@@ -187,7 +187,7 @@ class expansion_temp(expansion):
Message(conf.name, exit_desclr, conf.disp)
sleep(6)
VarCache["alive"] = False
- iThr.killAllThreads()
+ ithr.killAllThreads()
for disp in Clients.keys():
if online(disp):
sUnavailable(disp, exit_desclr)
@@ -201,4 +201,4 @@ class expansion_temp(expansion):
(command_reconnect, "reconnect", 8,),
(command_reload, "reload", 8,),
(command_exit, "exit", 8,)
- )
+ )
diff --git a/expansions/basic_control/insc.py b/expansions/basic_control/insc.py
index f496d5f..78d5b43 100644
--- a/expansions/basic_control/insc.py
+++ b/expansions/basic_control/insc.py
@@ -20,7 +20,7 @@ if DefLANG in ("RU", "UA"):
"Не могу создать директорию, вероятно «%s» содержит запрещённые символы. Соответственно, я не могу обслуживать эту конференцию.", # 15
"Система не может выделить ресурсы на ещё один клиент.", # 16
"«%s» нет в списке клиентов." # 17
- )])
+ )])
else:
AnsBase_temp = (
"Attention! %s (%s) sent me in to -> '%s'", # 0
@@ -41,4 +41,4 @@ else:
"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 the clients-list." # 17
- ) \ No newline at end of file
+ ) \ No newline at end of file
diff --git a/expansions/books/code.py b/expansions/books/code.py
index 9089aad..af78669 100644
--- a/expansions/books/code.py
+++ b/expansions/books/code.py
@@ -106,7 +106,7 @@ class expansion_temp(expansion):
"жанр".decode("utf-8"): ls[1],
"серию".decode("utf-8"): ls[2],
"cycle": ls[2]
- }
+ }
if desc.has_key(a2):
a2 = desc.get(a2, None)
if a2 in ls and args:
@@ -242,7 +242,7 @@ class expansion_temp(expansion):
db("update readers set book=?, page=? where jid=?", (book, page, jid))
else:
db("insert into readers values (?,?,?)", (jid, book, page))
- if stype == Types[1]:
+ if stype == sBase[1]:
Message(source[0], answer, disp)
answer = AnsBase[11]
else:
@@ -272,7 +272,7 @@ class expansion_temp(expansion):
if os.path.isfile(Path):
try:
self.importFB2(Path, source[2].strip())
- except SelfExc, exc:
+ except SelfExc as exc:
answer = exc[0]
except:
if AsciiSys:
@@ -319,7 +319,7 @@ class expansion_temp(expansion):
"number": ls[4],
"cover_ext": ls[9],
"cycle": ls[3]
- }
+ }
if desc.has_key(a4):
a4 = desc.get(a4, None)
if a4 in ls:
@@ -472,6 +472,6 @@ class expansion_temp(expansion):
commands = (
(command_get_books, "books", 2,),
(command_set_books, "library", 7,)
- )
+ )
handlers = ((init_books_base, "00si"),)
diff --git a/expansions/books/insc.py b/expansions/books/insc.py
index 005f447..d704b77 100644
--- a/expansions/books/insc.py
+++ b/expansions/books/insc.py
@@ -18,7 +18,7 @@ if DefLANG in ("RU", "UA"):
"Неверный номер страницы.", # 13
"Нет такой страницы.", # 14
"Неверное название." # 15
- )])
+ )])
else:
AnsBase_temp = (
"The library is empty.", # 0
@@ -37,4 +37,4 @@ else:
"Incorrect page number.", # 13
"No such page.", # 14
"Incorrect name." # 15
- ) \ No newline at end of file
+ ) \ No newline at end of file
diff --git a/expansions/bot_sends/code.py b/expansions/bot_sends/code.py
index b048826..6612601 100644
--- a/expansions/bot_sends/code.py
+++ b/expansions/bot_sends/code.py
@@ -1,9 +1,9 @@
# coding: utf-8
# BlackSmith mark.2
-# exp_name = "bot_sends" # /code.py v.x8
-# Id: 18~7c
-# Code © (2010-2012) by WitcherGeralt [alkorgun@gmail.com]
+# exp_name = "bot_sends" # /code.py v.x9
+# Id: 18~8c
+# Code © (2010-2013) by WitcherGeralt [alkorgun@gmail.com]
class expansion_temp(expansion):
@@ -14,25 +14,26 @@ class expansion_temp(expansion):
if Chats.has_key(source[1]):
if ChatsAttrs[source[1]]["dirt"]:
ChatsAttrs[source[1]]["dirt"] = None
- if stype == Types[1]:
+ if stype == sBase[1]:
s1_backup = Chats[source[1]].state
s2_backup = Chats[source[1]].status
Chats[source[1]].change_status(sList[2], self.AnsBase[0])
- zero = xmpp.Message(source[1], typ = Types[1])
+ zero = xmpp.Message(source[1], typ = sBase[1])
+ zero.setBody("")
for Numb in xrange(24):
if not Chats.has_key(source[1]):
raise SelfExc("exit")
Sender(disp, zero); Info["omsg"].plus()
if (Numb != 23):
sleep(1.4)
- if stype == Types[1]:
+ if stype == sBase[1]:
Chats[source[1]].change_status(s1_backup, s2_backup)
ChatsAttrs[source[1]]["dirt"] = True
else:
answer = self.AnsBase[9]
else:
answer = AnsBase[0]
- if locals().has_key(Types[6]):
+ if locals().has_key(sBase[6]):
Answer(answer, stype, source, disp)
def command_test(self, stype, source, body, disp):
@@ -63,6 +64,8 @@ class expansion_temp(expansion):
else:
Answer(AnsBase[0], stype, source, disp)
+ compile_chat = compile__("^[^\s'\"@<>&]+?@(?:conference|muc|conf|chat|group)\.[\w-]+?\.[\.\w-]+?$")
+
def command_send(self, stype, source, body, disp):
if body:
body = body.split(None, 1)
@@ -70,7 +73,7 @@ class expansion_temp(expansion):
sTo, body = body
if isSource(sTo):
conf = (sTo.split(chr(47)))[0].lower()
- if Chats.has_key(conf) or not conf.count("@conf"):
+ if conf in Chats or not self.compile_chat.match(conf):
Message(sTo, self.AnsBase[5] % (source[2], body))
answer = AnsBase[4]
else:
@@ -113,7 +116,7 @@ class expansion_temp(expansion):
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(arg0):
source_ = arg0.lower()
@@ -139,11 +142,10 @@ class expansion_temp(expansion):
answer = AnsBase[0]
Answer(answer, stype, source, disp)
- def init_bot_sender(self, conf):
- if not ChatsAttrs.has_key(conf):
- ChatsAttrs[conf] = {}
- ChatsAttrs[conf]["intr"] = 0
- ChatsAttrs[conf]["dirt"] = True
+ def init_bot_sender(self, chat):
+ desc = ChatsAttrs.setdefault(chat, {})
+ desc["intr"] = 0
+ desc["dirt"] = True
commands = (
(command_clear, "clear", 3,),
@@ -154,6 +156,6 @@ class expansion_temp(expansion):
(command_toadmin, "toadmin", 1,),
(command_echo, "echo", 6,),
(command_invite, "invite", 4,)
- )
+ )
handlers = ((init_bot_sender, "01si"),)
diff --git a/expansions/bot_sends/insc.py b/expansions/bot_sends/insc.py
index 955d628..303e6c0 100644
--- a/expansions/bot_sends/insc.py
+++ b/expansions/bot_sends/insc.py
@@ -12,7 +12,7 @@ if DefLANG in ("RU", "UA"):
"Адресат неопределён.", # 7
"Не более 1го приглащения за 12 минут! (Осталось: %s)", # 8
"Чистка итак в процессе!" # 9
- )])
+ )])
else:
AnsBase_temp = (
"cleaning conference...", # 0
@@ -25,4 +25,4 @@ else:
"Unknown target.", # 7
"Users can send only one invite in 12 minutes! (Remain: %s)", # 8
"Cleaning already in the process!" # 9
- ) \ No newline at end of file
+ ) \ No newline at end of file
diff --git a/expansions/clear_stats/code.py b/expansions/clear_stats/code.py
index 5d332b2..8991179 100644
--- a/expansions/clear_stats/code.py
+++ b/expansions/clear_stats/code.py
@@ -31,4 +31,4 @@ class expansion_temp(expansion):
handlers = (
(join_clear, "04eh"),
(exit_clear, "05eh")
- )
+ )
diff --git a/expansions/cmd_control/insc.py b/expansions/cmd_control/insc.py
index a7af727..905ac01 100644
--- a/expansions/cmd_control/insc.py
+++ b/expansions/cmd_control/insc.py
@@ -6,11 +6,11 @@ if DefLANG in ("RU", "UA"):
"Команда «%s» запрещена.", # 1
"Эта команда не может быть запрещена.", # 2
"Нет запрещенных команд." # 3
- )])
+ )])
else:
AnsBase_temp = (
"Command '%s' is allowed.", # 0
"Command '%s' is forbidden.", # 1
"This command can't be forbidden.", # 2
"No forbidden commands." # 3
- ) \ No newline at end of file
+ ) \ No newline at end of file
diff --git a/expansions/config/code.py b/expansions/config/code.py
index 5de2fb3..7bfb240 100644
--- a/expansions/config/code.py
+++ b/expansions/config/code.py
@@ -1,8 +1,8 @@
# coding: utf-8
# BlackSmith mark.2
-# exp_name = "config" # /code.py v.x9
-# Id: 19~8c
+# exp_name = "config" # /code.py v.x10
+# Id: 19~9c
# Code © (2011-2013) by WitcherGeralt [alkorgun@gmail.com]
class expansion_temp(expansion):
@@ -14,13 +14,13 @@ class expansion_temp(expansion):
cfg = []
for s in config.sections():
cfg.append("[%s]" % (s.upper()))
- for (op, i) in config.items(s):
- cfg.append("%s = %s" % (op.upper(), str(i)))
+ for (opt, i) in config.items(s):
+ cfg.append("%s = %s" % (opt.upper(), str(i)))
return "\r\n".join(cfg)
- ops = ("memory", "incoming", "chat", "private", "tls", "mserve", "getexc", "status", "resource")
+ opts = ("memory", "incoming", "chat", "private", "tls", "mserve", "getexc", "status", "resource")
- opsGeq = ("MaxMemory", "IncLimit", "ConfLimit", "PrivLimit", "ConTls", "Mserve", "GetExc", "DefStatus", "GenResource")
+ optsGlobEq = ("MaxMemory", "IncLimit", "ConfLimit", "PrivLimit", "ConTls", "Mserve", "GetExc", "DefStatus", "GenResource")
def command_config(self, stype, source, body, disp):
if body:
@@ -28,46 +28,44 @@ class expansion_temp(expansion):
for x in body.split():
if not x.count("="):
continue
- Name, data = x.split("=", 1)
+ opt, data = x.split("=", 1)
if not data:
continue
- Name = Name.lower()
- for Title in GenCon.sections():
- if Name in GenCon.options(Title):
- if Name in self.ops[:4]:
+ opt = opt.lower()
+ for title in GenCon.sections():
+ if opt in GenCon.options(title):
+ if opt in self.opts[:4]:
if not isNumber(data):
continue
- elif Name in self.ops[4:-2]:
+ elif opt in self.opts[4:-2]:
if data not in ("True", "False"):
continue
- elif Name in self.ops[-2:]:
- data = sub_desc(data, {chr(95): chr(32)})
- if not ConfigDesc.has_key(Title):
- ConfigDesc[Title] = {}
- ConfigDesc[Title][Name] = data
+ elif opt in self.opts[-2:]:
+ data = data.replace(chr(95), chr(32))
+ ConfigDesc.setdefault(title, {})[opt] = data
if ConfigDesc:
- for Title in ConfigDesc.keys():
- for (Name, data) in ConfigDesc[Title].items():
- GenCon.set(Title, Name, data)
- if Name in self.ops:
- if Name not in self.ops[-2:]:
+ for (title, opts) in ConfigDesc.items():
+ for (opt, data) in opts.items():
+ GenCon.set(title, opt, data)
+ if opt in self.opts:
+ if opt not in self.opts[-2:]:
data = eval(data)
- if Name == self.ops[0]:
+ if opt == self.opts[0]:
data *= 1024
data = (32768 if (data and data <= 32768) else data)
- globals()[self.opsGeq[self.ops.index(Name)]] = data
+ globals()[self.optsGlobEq[self.opts.index(opt)]] = data
cat_file(GenConFile, self.get_config(GenCon))
ls = []
- for Name in ConfigDesc.values():
- ls.extend(Name.keys())
- answer = self.AnsBase[0] % (", ".join([Name.upper() for Name in ls]))
+ for opts in ConfigDesc.values():
+ ls.extend(opts.keys())
+ answer = self.AnsBase[0] % (", ".join([opt.upper() for opt in ls]))
else:
answer = self.AnsBase[1]
else:
Message(source[0], self.AnsBase[2] + self.get_config(GenCon), disp)
- if stype == Types[1]:
+ if stype == sBase[1]:
answer = AnsBase[11]
- if locals().has_key(Types[6]):
+ if locals().has_key(sBase[6]):
Answer(answer, stype, source, disp)
def command_cls_config(self, stype, source, body, disp):
@@ -100,10 +98,10 @@ class expansion_temp(expansion):
if Gen == client_config(ConDisp, x)[0]:
ConDisp.remove_section(x)
if Clients.has_key(Name):
- ThrName = "%s-%s" % (Types[13], Name)
- for Thr in iThr.enumerate():
- if ThrName == Thr.getName():
- Thr.kill()
+ thrName = "%s-%s" % (sBase[13], Name)
+ for thr in ithr.enumerate():
+ if thrName == thr.getName():
+ thr.kill()
for conf in Chats.itervalues():
if conf.disp == Name:
if online(Name):
@@ -165,7 +163,7 @@ class expansion_temp(expansion):
InstancesDesc[Instance] = desc
cat_file(ConDispFile, self.get_config(ConDisp))
try:
- StartThr(composeThr(Dispatcher, "%s-%s" % (Types[13], Instance), (Instance,)), -1)
+ startThr(composeThr(Dispatcher, "%s-%s" % (sBase[13], Instance), (Instance,)), -1)
except RuntimeError:
answer = self.AnsBase[8]
else:
@@ -194,10 +192,10 @@ class expansion_temp(expansion):
for x in xrange(24):
code += choice(symbols)
if locals().has_key("changed"):
- self.answer_register(Name, xmpp.Iq(Types[8]), stype, source, code, disp)
+ self.answer_register(Name, xmpp.Iq(sBase[8]), stype, source, code, disp)
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])])
+ iq = xmpp.Iq(sBase[9], xmpp.NS_REGISTER, to = Disp.Server, payload = [xmpp.Node("username", payload = [Disp.User]), xmpp.Node("password", payload = [code])])
Info["outiq"].plus()
CallForResponse(Disp, iq, self.answer_register, {"stype": stype, "source": source, "code": code, "str_disp": get_disp(disp)})
else:
@@ -212,9 +210,9 @@ class expansion_temp(expansion):
answer = self.AnsBase[3]
else:
Message(source[0], self.AnsBase[2] + self.get_config(ConDisp), disp)
- if stype == Types[1]:
+ if stype == sBase[1]:
answer = AnsBase[11]
- if locals().has_key(Types[6]):
+ if locals().has_key(sBase[6]):
Answer(answer, stype, source)
def answer_register(self, disp, stanza, stype, source, code, str_disp):
@@ -242,4 +240,4 @@ class expansion_temp(expansion):
commands = (
(command_config, "config", 8,),
(command_cls_config, "client", 8,)
- )
+ )
diff --git a/expansions/config/insc.py b/expansions/config/insc.py
index d697573..af77fe8 100644
--- a/expansions/config/insc.py
+++ b/expansions/config/insc.py
@@ -15,7 +15,7 @@ if DefLANG in ("RU", "UA"):
"Этот jid уже есть в списках.", # 10
"«%s» нет в списке клиентов.", # 11
"«%s» сейчас оффлайн." # 12
- )])
+ )])
else:
AnsBase_temp = (
"Changed options: %s", # 0
@@ -31,4 +31,4 @@ else:
"This jid is already in the list.", # 10
"'%s' not in clients-list.", # 11
"'%s' is offline." # 12
- ) \ No newline at end of file
+ ) \ No newline at end of file
diff --git a/expansions/converter/code.py b/expansions/converter/code.py
index e3355cc..6942040 100644
--- a/expansions/converter/code.py
+++ b/expansions/converter/code.py
@@ -19,7 +19,7 @@ class expansion_temp(expansion):
"hour": 8766.0, # Час
"minute": 525960.0, # Минута
"second": 31557600.0, # Секунда
- },
+ },
"info": { # Информация
"bit": 1.0, # Бит !# Base
"kbit": 9.765625e-04, # 2^10
@@ -39,7 +39,7 @@ class expansion_temp(expansion):
"ebyte": 1.08420217249e-19, # 2^60
"zbyte": 1.05879118407e-22, # 2^70
"ybyte": 1.03397576569e-25, # 2^80
- },
+ },
"magnetics": { # Магнитное Поле
"gauss": 1.0, # Gauss; Ггаусс (G; Гс) !# Base
"tesla": 1e-04, # Tesla; Тесла (T; Тл)
@@ -55,7 +55,7 @@ class expansion_temp(expansion):
"microtesla": 1e02, # 10^-06
"nanotesla": 1e05, # 10^-09
"picotesla": 1e08, # 10^-12
- },
+ },
"power": { # Мощность
"watt": 1.0, # Watt; Ватт (W; Вт) !# Base
"kwatt": 1e-03, # 10^03
@@ -63,12 +63,12 @@ class expansion_temp(expansion):
"gwatt": 1e-09, # 10^09
"twatt": 1e-12, # 10^12
"hpwr": 0.0013596216173, # Horse Power; Лошадиная Сила
- },
+ },
"radiation": { # Радиационное Излучение
"bq": 1.0, # Becquerel; Беккерель (Bq; Бк) !# Base (Базовое Значение)
"ci": 2.7027e-11, # Curie; Кюри (Ci; Ки)
"rad": 1e-06, # Radiation Absorbed Dose (rad; Рад)
- },
+ },
"temperature": { # Температура
"c": ((lambda Numb: Numb), # °C (Celsius; Цельсий) !# Base
(lambda Numb: Numb)),
@@ -86,14 +86,14 @@ class expansion_temp(expansion):
(lambda Numb: (Numb * 5.0 / 4.0))), # to Celsius
"ro": ((lambda Numb: (Numb * 21.0 / 40.0 + 7.5)), # from Celsius to °Ro (Romer; Рёмер)
(lambda Numb: ((Numb - 7.5) * 40.0 / 21.0))), # to Celsius
- },
+ },
"pressure": { # Давление
"atm": 1.0, # Standard Atmosphere; Атмосферное Давление (atm; атм) !# Base
"bar": 1.01325, # bar; бар
"pa": 101325.0, # Pascal; Паскаль (Pa; Па)
"torr": 760.0, # Torr; Миллиметр Ртутного Столба
"psi": 14.696, # Pound per Square Inch; Фунт на Квадратный Дюйм
- },
+ },
"volume": { # Объем
"usbushel": 1.0, # U.S. Bushel; Американский Бушель !# Base
"bushel": 0.968938622, # U.K. Bushel; Имперский Бушель
@@ -113,7 +113,7 @@ class expansion_temp(expansion):
"metre^3": 0.035239072, # Cubic Metre; Кубический Метр
"foot^3": 1.24445608, # Cubic Foot; Кубический Фут
"inch^3": 2150.42011, # Cubic Inch; Кубический Дюйм
- },
+ },
"weight": { # Масса
"g": 1.0, # Gram; Грамм !# Base
"kg": 1e-03, # KiloGram; Килограмм
@@ -124,7 +124,7 @@ class expansion_temp(expansion):
"lbt": 0.002679229, # Troyes Pound; Тройский Фунт
"pd": 6.10482666e-05, # Russian Pood; Пуд
"carat": 5.0, # Carat; Карат
- },
+ },
"distance": { # Длина
"angstrom": 1.0, # Angström; Ангстрём !# Base
"nanometre": 1e-01, # 10^-09
@@ -144,7 +144,7 @@ class expansion_temp(expansion):
"au": 6.68458712267e-22, # Astronomical Unit; Астрономическая Единица (средний радиус земной орбиты)
"ly": 1.05700083402e-26, # Light-Year; Световой Год
"pc": 3.24077927001e-27, # Parsec; Парсек
- },
+ },
"speed": { # Скорость
"km/h": 1.0, # KiloMetres per Hour; Километры в Час !# Base
"m/s": 0.2778, # Metres per Second; Метры в Секунду
@@ -152,7 +152,7 @@ class expansion_temp(expansion):
"mph": 0.621371192, # Miles per Hour; Мили в Час
"fps": 0.911344415281, # Feet per Second; Футы в Секунду
"ls": 9.26566930076e-10, # Light-Speed; Скорость Света
- },
+ },
"angle": { # Угол
"degree": 1.0, # Degree; Градус ° !# Base
"second": 3600.0, # Arc Second; Угловая Секунда
@@ -160,7 +160,7 @@ class expansion_temp(expansion):
"rad": 0.0174532925, # Radians; Радиан
"turn": 0.00277777777778, # Turn; Оборот
"gon": 1.111111111111111, # Gradian; Градон
- },
+ },
"square": { # Площадь
"acre": 1.0, # Acre; Акр !# Base
"milimetre^2": 4046856420.0, # Square MilliMetre; Квадратный Миллиметр
@@ -173,7 +173,7 @@ class expansion_temp(expansion):
"hectare": 0.404685642, # Hectare; Гектар
"are": 40.4685642, # Are; Ар
"barn": 4.04685642e31, # Barn; Барн
- },
+ },
"energy": { # Энергия
"btu": 1.0, # British Thermal Unit; Британская Термическая Единица !# Base
"mbtu": 1000000.0, # Million British Thermal Unit; Миллион Британских Термических Единиц
@@ -184,8 +184,8 @@ class expansion_temp(expansion):
"joule": 1055.05585, # Joule (Watt per Second); Джоуль (Ватт Секунда)
"watt/h": 0.29307107, # Watt per Hour; Ватт Час
"kwatt/h": 0.00029307107, # KiloWatt per Hour; Киловатт Час
- },
- }
+ },
+ }
ConvertTemp = lambda self, Numb, Type, ToType, Desc = CrDesc["temperature"]: Desc[ToType][0](Desc[Type][1](Numb))
diff --git a/expansions/converter/insc.py b/expansions/converter/insc.py
index 330387f..af3d4ab 100644
--- a/expansions/converter/insc.py
+++ b/expansions/converter/insc.py
@@ -5,10 +5,10 @@ if DefLANG in ("RU", "UA"):
"Неверно указана единица измерения.", # 0
"Oops...", # 1
"Неверно указана категория." # 2
- )])
+ )])
else:
AnsBase_temp = (
"Incorrect unit.", # 0
"Oops...", # 1
"Incorrect category." # 2
- ) \ No newline at end of file
+ ) \ No newline at end of file
diff --git a/expansions/cron/code.py b/expansions/cron/code.py
index cbea63a..870816f 100644
--- a/expansions/cron/code.py
+++ b/expansions/cron/code.py
@@ -143,7 +143,7 @@ class expansion_temp(expansion):
date[0] = int(Date.pop(0))
except:
answer = AnsBase[2]
- if not locals().has_key(Types[6]):
+ if not locals().has_key(sBase[6]):
try:
date = time.struct_time(date)
except:
@@ -195,10 +195,10 @@ class expansion_temp(expansion):
Answer(answer, stype, source, disp)
def start_cron(self):
- Name = self.def_cron.func_name
- for Thr in iThr.enumerate():
- if Thr.name.startswith(Name):
- Thr.kill()
+ Name = self.def_cron.__name__
+ for thr in ithr.enumerate():
+ if thr.name.startswith(Name):
+ thr.kill()
if initialize_file(self.CronFile, "({}, 0)"):
cdesc, ccnt = eval(get_file(self.CronFile))
Time = time.mktime(time.gmtime())
@@ -236,4 +236,4 @@ class expansion_temp(expansion):
handlers = (
(start_cron, "02si"),
(cdesc_save, "03si")
- )
+ )
diff --git a/expansions/cron/insc.py b/expansions/cron/insc.py
index 35ba169..5010d53 100644
--- a/expansions/cron/insc.py
+++ b/expansions/cron/insc.py
@@ -12,7 +12,7 @@ if DefLANG in ("RU", "UA"):
"Нет запланированных заданий.", # 7
"\n[№][ID][Команда][Deadline]\n%s", # 8
"Дата/Время введены некорректно." # 9
- )])
+ )])
else:
AnsBase_temp = (
"You asked to execute '%s'.", # 0
@@ -25,4 +25,4 @@ else:
"There are no tasks.", # 7
"\n[#][ID][Command][Deadline]\n%s", # 8
"Date/Time is incorrect." # 9
- ) \ No newline at end of file
+ ) \ No newline at end of file
diff --git a/expansions/dns/code.py b/expansions/dns/code.py
index 84ab832..d7b618a 100644
--- a/expansions/dns/code.py
+++ b/expansions/dns/code.py
@@ -59,4 +59,4 @@ class expansion_temp(expansion):
commands = (
(command_dns, "dns", 1,),
(command_port, "port", 1,)
- )
+ )
diff --git a/expansions/exp_control/code.py b/expansions/exp_control/code.py
index 80740be..f18c21e 100644
--- a/expansions/exp_control/code.py
+++ b/expansions/exp_control/code.py
@@ -23,7 +23,7 @@ class expansion_temp(expansion):
if expansions[exp_name].cmds:
answer += self.AnsBase[4] % (", ".join(expansions[exp_name].cmds))
if expansions[exp_name].desc:
- answer += self.AnsBase[5] % ("; ".join(["%s: (%s)" % (eh, ", ".join([inst.func_name for inst in ls])) for eh, ls in sorted(expansions[exp_name].desc.items())]))
+ answer += self.AnsBase[5] % ("; ".join(["%s: (%s)" % (eh, ", ".join([inst.__name__ for inst in ls])) for eh, ls in sorted(expansions[exp_name].desc.items())]))
else:
exp = expansion(exp_name)
if os.path.exists(exp.path):
@@ -55,7 +55,7 @@ class expansion_temp(expansion):
answer += self.AnsBase[9] % (elexps_len, chr(10).join(elexps))
Answer(answer, stype, source, disp)
- ReloadSemaphore = iThr.Semaphore()
+ ReloadSemaphore = ithr.Semaphore()
def command_expload(self, stype, source, body, disp):
if body:
@@ -104,14 +104,14 @@ class expansion_temp(expansion):
list = []
for ls in expansions[exp_name].desc.values():
for instance in ls:
- inst = instance.func_name
+ inst = instance.__name__
list.append(inst)
if inst == Name:
handler = instance
break
if handler:
with self.ReloadSemaphore:
- expansions[exp_name].funcs_del(handler)
+ expansions[exp_name].clear_handlers(handler)
answer = AnsBase[4]
elif list:
answer = self.AnsBase[14] % (", ".join(sorted(list)))
@@ -172,4 +172,4 @@ class expansion_temp(expansion):
(command_expload, "expload", 8,),
(command_expunload, "expunload", 8,),
(command_tumbler, "tumbler", 8,)
- )
+ )
diff --git a/expansions/exp_control/insc.py b/expansions/exp_control/insc.py
index e2fa395..02ad352 100644
--- a/expansions/exp_control/insc.py
+++ b/expansions/exp_control/insc.py
@@ -21,7 +21,7 @@ if DefLANG in ("RU", "UA"):
"Команда «%s» включена.", # 16
"Команда «%s» отключена.", # 17
"Нет отключенных команд." # 18
- )])
+ )])
else:
AnsBase_temp = (
"\n[Name][state][code-file][lang-file]", # 0
@@ -43,4 +43,4 @@ else:
"Command '%s' is on.", # 16
"Command '%s' is off.", # 17
"No disabled commands." # 18
- ) \ No newline at end of file
+ ) \ No newline at end of file
diff --git a/expansions/extra_control/code.py b/expansions/extra_control/code.py
index 69ad8b7..4bc82ab 100644
--- a/expansions/extra_control/code.py
+++ b/expansions/extra_control/code.py
@@ -40,7 +40,7 @@ class expansion_temp(expansion):
answer = AnsBase[2]
else:
answer = AnsBase[1]
- if locals().has_key(Types[6]):
+ if locals().has_key(sBase[6]):
Answer(answer, stype, source, disp)
def command_remote(self, stype, source, body, disp):
@@ -62,9 +62,9 @@ class expansion_temp(expansion):
if conf:
st = (body.pop(0)).lower()
if st in ("chat", "чат".decode("utf-8")):
- stype_ = Types[1]
+ stype_ = sBase[1]
elif st in ("private", "приват".decode("utf-8")):
- stype_ = Types[0]
+ stype_ = sBase[0]
else:
stype_ = None
if stype_:
@@ -77,7 +77,7 @@ class expansion_temp(expansion):
if Cmds.has_key(cmd):
cmd = Cmds[cmd]
if cmd.isAvalable and cmd.handler:
- if stype_ == Types[1]:
+ if stype_ == sBase[1]:
disp_ = Chats[conf].disp
else:
disp_ = get_disp(disp)
@@ -101,7 +101,7 @@ class expansion_temp(expansion):
answer = AnsBase[2]
else:
answer = enumerated_list(confs)
- if locals().has_key(Types[6]):
+ if locals().has_key(sBase[6]):
Answer(answer, stype, source, disp)
def command_private(self, stype, source, body, disp):
@@ -114,14 +114,14 @@ class expansion_temp(expansion):
body = body[0]
else:
body = ""
- Cmds[cmd].execute(Types[0], source, body, disp)
+ Cmds[cmd].execute(sBase[0], source, body, disp)
else:
answer = AnsBase[6]
else:
answer = AnsBase[1]
else:
answer = AnsBase[0]
- if locals().has_key(Types[6]):
+ if locals().has_key(sBase[6]):
Answer(answer, stype, source, disp)
pointer = chr(62)*2
@@ -147,7 +147,7 @@ class expansion_temp(expansion):
body = ""
if Chats[source[1]].isHereTS(nick):
Info["cmd"].plus()
- sThread("command", cmd.handler, (cmd.exp, Types[0], ("%s/%s" % (source[1], nick), source[1], nick), body, disp), cmd.name)
+ sThread("command", cmd.handler, (cmd.exp, sBase[0], ("%s/%s" % (source[1], nick), source[1], nick), body, disp), cmd.name)
cmd.numb.plus()
source_ = get_source(source[1], source[2])
if source_:
@@ -176,4 +176,4 @@ class expansion_temp(expansion):
(command_remote, "remote", 8,),
(command_private, "private", 1,),
(command_redirect, "redirect", 5,)
- )
+ )
diff --git a/expansions/game/code.py b/expansions/game/code.py
index 4949ec3..468d3e6 100644
--- a/expansions/game/code.py
+++ b/expansions/game/code.py
@@ -14,24 +14,24 @@ class expansion_temp(expansion):
GameChrLS[0]: {
GameChrLS[1]: 9,
GameChrLS[3]: 2
- },
+ },
GameChrLS[1]: {
GameChrLS[2]: 0,
GameChrLS[3]: 5
- },
+ },
GameChrLS[2]: {
GameChrLS[0]: 1,
GameChrLS[4]: 7
- },
+ },
GameChrLS[3]: {
GameChrLS[2]: 6,
GameChrLS[4]: 3
- },
+ },
GameChrLS[4]: {
GameChrLS[0]: 8,
GameChrLS[1]: 4
- }
- }
+ }
+ }
GameRules = GameRules
diff --git a/expansions/game/insc.py b/expansions/game/insc.py
index ac3946d..2bf3b73 100644
--- a/expansions/game/insc.py
+++ b/expansions/game/insc.py
@@ -5,7 +5,7 @@ if DefLANG in ("RU", "UA"):
"Ничья.", # 0
"%s\n\t»» Я победил!", # 2
"%s\n\t»» Ты победил." # 3
- )])
+ )])
GameRules = tuple([Rule.decode("utf-8") for Rule in (
"Ножницы режут бумагу.", # 0
@@ -18,7 +18,7 @@ if DefLANG in ("RU", "UA"):
"Бумага компрометирует Спока.", # 7
"Спок испаряет камень.", # 8
"Камень ломает ножницы." # 9
- )])
+ )])
GameChrLS = tuple([Char.decode("utf-8") for Char in (
"камень", # 0
@@ -26,7 +26,7 @@ if DefLANG in ("RU", "UA"):
"бумага", # 2
"ящерица", # 3
"спок" # 4
- )])
+ )])
del Char, Rule
else:
@@ -34,7 +34,7 @@ else:
"Draw.", # 1
"%s\n\t>> I won!", # 2
"%s\n\t>> You won." # 3
- )
+ )
GameRules = (
"Scissors cut paper.", # 0
@@ -47,7 +47,7 @@ else:
"Paper disproves Spock.", # 7
"Spock vaporizes rock.", # 8
"Rock crushes scissors." # 9
- )
+ )
GameChrLS = (
"rock", # 0
@@ -55,4 +55,4 @@ else:
"paper", # 2
"lizard", # 3
"spock" # 4
- ) \ No newline at end of file
+ ) \ No newline at end of file
diff --git a/expansions/get_iq/code.py b/expansions/get_iq/code.py
index 2d1e920..529cd7e 100644
--- a/expansions/get_iq/code.py
+++ b/expansions/get_iq/code.py
@@ -1,9 +1,9 @@
# coding: utf-8
# BlackSmith mark.2
-# exp_name = "get_iq" # /code.py v.x11
-# Id: 13~10c
-# Code © (2010-2012) by WitcherGeralt [alkorgun@gmail.com]
+# exp_name = "get_iq" # /code.py v.x12
+# Id: 13~11c
+# Code © (2010-2013) by WitcherGeralt [alkorgun@gmail.com]
class expansion_temp(expansion):
@@ -18,11 +18,11 @@ 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(Types[10], to = instance)
- iq.addChild(Types[16], namespace = xmpp.NS_PING)
+ iq = xmpp.Iq(sBase[10], to = instance)
+ iq.addChild(sBase[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,8 +37,8 @@ class expansion_temp(expansion):
self.PingStats[source_].append(answer)
Answer(self.AnsBase[0] % str(answer), stype, source, disp)
else:
- iq = xmpp.Iq(Types[10], to = instance)
- iq.addChild(Types[18], namespace = xmpp.NS_VERSION)
+ iq = xmpp.Iq(sBase[10], to = instance)
+ iq.addChild(sBase[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()})
@@ -87,11 +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(Types[10], to = instance)
- iq.addChild(Types[17], namespace = xmpp.NS_URN_TIME)
+ iq = xmpp.Iq(sBase[10], to = instance)
+ iq.addChild(sBase[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})
@@ -129,8 +129,8 @@ class expansion_temp(expansion):
answer = self.AnsBase[6]
Answer(answer, stype, source, disp)
else:
- iq = xmpp.Iq(Types[10], to = instance)
- iq.addChild(Types[18], namespace = xmpp.NS_TIME)
+ iq = xmpp.Iq(sBase[10], to = instance)
+ iq.addChild(sBase[18], namespace = xmpp.NS_TIME)
iq.setID("Bs-i%d" % Info["outiq"].plus())
CallForResponse(disp, iq, self.answer_time0090, {"stype": stype, "source": source})
@@ -149,11 +149,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(Types[10], to = instance)
- iq.addChild(Types[18], namespace = xmpp.NS_VERSION)
+ iq = xmpp.Iq(sBase[10], to = instance)
+ iq.addChild(sBase[18], namespace = xmpp.NS_VERSION)
iq.setID("Bs-i%d" % Info["outiq"].plus())
CallForResponse(disp, iq, self.answer_version, {"stype": stype, "source": source})
@@ -181,10 +181,10 @@ 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(Types[10], to = instance)
+ iq = xmpp.Iq(sBase[10], to = instance)
iq.addChild("vCard", namespace = xmpp.NS_VCARD)
iq.setID("Bs-i%d" % Info["outiq"].plus())
CallForResponse(disp, iq, self.answer_vcard, {"stype": stype, "source": source})
@@ -205,7 +205,7 @@ class expansion_temp(expansion):
"CTRY": "Country",
"ORGNAME": "Organization",
"ORGUNIT": "Department"
- }
+ }
def parse_vcard(self, node, ls):
if node.kids:
@@ -228,21 +228,21 @@ class expansion_temp(expansion):
if ls:
ls.insert(0, "\->")
answer = str.join(chr(10), ls)
- if stype == Types[1]:
+ if stype == sBase[1]:
Message(source[1], answer, disp)
del answer
else:
answer = self.AnsBase[10]
else:
answer = self.AnsBase[6]
- if locals().has_key(Types[6]):
+ if locals().has_key(sBase[6]):
Answer(answer, stype, source, disp)
def command_uptime(self, stype, source, server, disp):
if not server:
server = disp._owner.Server
- iq = xmpp.Iq(Types[10], to = server)
- iq.addChild(Types[18], namespace = xmpp.NS_LAST)
+ iq = xmpp.Iq(sBase[10], to = server)
+ iq.addChild(sBase[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})
@@ -254,22 +254,22 @@ class expansion_temp(expansion):
instance = "%s/%s" % (source[1], instance)
else:
answer = self.AnsBase[5] % (instance)
- if not locals().has_key(Types[6]):
- iq = xmpp.Iq(Types[10], to = instance)
- iq.addChild(Types[18], namespace = xmpp.NS_LAST)
+ if not locals().has_key(sBase[6]):
+ iq = xmpp.Iq(sBase[10], to = instance)
+ iq.addChild(sBase[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})
else:
answer = AnsBase[1]
- if locals().has_key(Types[6]):
+ if locals().has_key(sBase[6]):
Answer(answer, stype, source, disp)
def answer_idle(self, disp, stanza, stype, source, instance, typ):
if xmpp.isResultNode(stanza):
- seconds = stanza.getTagAttr(Types[18], "seconds")
+ seconds = stanza.getTagAttr(sBase[18], "seconds")
if seconds and seconds != "0" and isNumber(seconds):
answer = (self.AnsBase[8] if typ else self.AnsBase[7]) % (instance, Time2Text(int(seconds)))
- if not locals().has_key(Types[6]):
+ if not locals().has_key(sBase[6]):
answer = self.AnsBase[6]
Answer(answer, stype, source, disp)
@@ -294,8 +294,8 @@ class expansion_temp(expansion):
data = (ls.pop(0)).lower()
desc = {}
for role in self.affs:
- iq = xmpp.Iq(Types[10], to = source[1])
- query = xmpp.Node(Types[18])
+ iq = xmpp.Iq(sBase[10], to = source[1])
+ query = xmpp.Node(sBase[18])
query.setNamespace(xmpp.NS_MUC_ADMIN)
query.addChild("item", {aRoles[0]: role})
iq.addChild(node = query)
@@ -314,7 +314,7 @@ class expansion_temp(expansion):
ls.append("%d) %s" % (Number.plus(), jid))
if ls:
Message(source[0], str.join(chr(10), ls), disp)
- if stype == Types[1]:
+ if stype == sBase[1]:
answer = AnsBase[11]
else:
answer = self.AnsBase[9]
@@ -331,8 +331,8 @@ class expansion_temp(expansion):
Numb = 20
else:
Numb = x
- iq = xmpp.Iq(Types[10], to = source[1])
- query = xmpp.Node(Types[18])
+ iq = xmpp.Iq(sBase[10], to = source[1])
+ query = xmpp.Node(sBase[18])
query.setNamespace(xmpp.NS_MUC_ADMIN)
query.addChild("item", {aRoles[0]: body})
iq.addChild(node = query)
@@ -344,7 +344,7 @@ class expansion_temp(expansion):
answer = AnsBase[1]
else:
answer = AnsBase[0]
- if locals().has_key(Types[6]):
+ if locals().has_key(sBase[6]):
Answer(answer, stype, source, disp)
def answer_aflist_search(self, disp, stanza, desc, role, data):
@@ -367,7 +367,7 @@ class expansion_temp(expansion):
if node and node != "None":
jid = node.getAttr("jid")
if jid:
- if Numb and Numb <= Number._int():
+ if Numb and Numb <= Number:
Number.plus()
else:
signature = node.getTagData("reason")
@@ -375,16 +375,16 @@ class expansion_temp(expansion):
jid = "%s (%s)" % (jid, signature)
jids.append("%d) %s" % (Number.plus(), jid))
if jids:
- if Numb and Numb < Number._int():
- jids.append("...\nTotal: %s items." % (Number._str()))
+ if Numb and Numb < Number:
+ jids.append("...\nTotal: %s items." % Number)
Message(source[0], str.join(chr(10), jids), disp)
- if stype == Types[1]:
+ if stype == sBase[1]:
answer = AnsBase[11]
else:
answer = self.AnsBase[6]
else:
answer = self.AnsBase[6]
- if locals().has_key(Types[6]):
+ if locals().has_key(sBase[6]):
Answer(answer, stype, source, disp)
XEPs.add(xmpp.NS_STATS)
@@ -392,15 +392,15 @@ class expansion_temp(expansion):
def command_server_stats(self, stype, source, server, disp):
if not server:
server = disp._owner.Server
- iq = xmpp.Iq(Types[10], to = server)
- iq.addChild(Types[18], namespace = xmpp.NS_STATS)
+ iq = xmpp.Iq(sBase[10], to = server)
+ iq.addChild(sBase[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(Types[10], to = stanza.getFrom())
- iq.addChild(Types[18], {}, stanza.getQueryChildren() or [], xmpp.NS_STATS)
+ iq = xmpp.Iq(sBase[10], to = stanza.getFrom())
+ iq.addChild(sBase[18], {}, stanza.getQueryChildren() or [], xmpp.NS_STATS)
iq.setID("Bs-i%d" % Info["outiq"].plus())
CallForResponse(disp, iq, self.answer_server_stats_get, {"stype": stype, "source": source})
else:
@@ -412,8 +412,9 @@ class expansion_temp(expansion):
for node in stanza.getQueryChildren() or ():
name = node.getAttr("name")
value = node.getAttr("value")
+ units = node.getAttr("units")
if name and value:
- ls.append("%s: %s" % (name, value))
+ ls.append("%s: %s %s" % (name, value, units))
if ls:
ls.insert(0, "Stats of %s ->" % stanza.getFrom())
answer = str.join(chr(10), ls)
@@ -435,7 +436,7 @@ class expansion_temp(expansion):
if isNumber(limit):
limit = int(limit)
if limit > 2:
- if stype == Types[0]:
+ if stype == sBase[0]:
if limit > 256:
limit = 256
elif limit > 24:
@@ -445,8 +446,8 @@ class expansion_temp(expansion):
desc["body"] = ls.pop(0)
else:
desc["body"] = body[len(server):].strip()
- iq = xmpp.Iq(Types[10], to = server)
- iq.addChild(Types[18], namespace = xmpp.NS_DISCO_ITEMS)
+ iq = xmpp.Iq(sBase[10], to = server)
+ iq.addChild(sBase[18], namespace = xmpp.NS_DISCO_ITEMS)
iq.setID("Bs-i%d" % Info["outiq"].plus())
CallForResponse(disp, iq, self.answer_disco, desc)
else:
@@ -526,4 +527,4 @@ class expansion_temp(expansion):
(command_aflist, "list", 4,),
(command_server_stats, "servstat", 1,),
(command_disco, "disco", 2,)
- )
+ )
diff --git a/expansions/get_iq/insc.py b/expansions/get_iq/insc.py
index b1c450b..7a6754c 100644
--- a/expansions/get_iq/insc.py
+++ b/expansions/get_iq/insc.py
@@ -14,7 +14,7 @@ if DefLANG in ("RU", "UA"):
"Нет cовпадений.", # 9
"Вкард не заполнен.", # 10
"\n\n** Всего %d пунктов." # 11
- )])
+ )])
else:
AnsBase_temp = (
"Pong - %s sec.", # 0
@@ -29,4 +29,4 @@ else:
"No matches.", # 9
"The vCard is empty.", # 10
"\n\n** Total %d results." # 11
- ) \ No newline at end of file
+ ) \ No newline at end of file
diff --git a/expansions/help/code.py b/expansions/help/code.py
index 05d29ec..3e1ec8c 100644
--- a/expansions/help/code.py
+++ b/expansions/help/code.py
@@ -1,9 +1,9 @@
# coding: utf-8
# BlackSmith mark.2
-# exp_name = "help" # /code.py v.x6
-# Id: 03~3c
-# Code © (2010-2012) by WitcherGeralt [alkorgun@gmail.com]
+# exp_name = "help" # /code.py v.x7
+# Id: 03~4c
+# Code © (2010-2013) by WitcherGeralt [alkorgun@gmail.com]
class expansion_temp(expansion):
@@ -83,30 +83,28 @@ class expansion_temp(expansion):
lcmds[x] = itypes.Number()
for cmd in Cmds.keys():
access = Cmds[cmd].access
- if not cmds.has_key(access):
- cmds[access] = []
- cmds[access].append(cmd)
+ cmds.setdefault(access, []).append(cmd)
for x in lcmds.keys():
if x >= access:
lcmds[x].plus()
- for x in cmds.keys():
- cmds[x].sort()
+ for ls in cmds.itervalues():
+ ls.sort()
if cmds.has_key(8):
- answer += self.AnsBase[8] % (lcmds[8]._str(), ", ".join(cmds[8]))
+ answer += self.AnsBase[8] % (lcmds[8], ", ".join(cmds[8]))
if cmds.has_key(7):
- answer += self.AnsBase[9] % (lcmds[7]._str(), ", ".join(cmds[7]))
+ answer += self.AnsBase[9] % (lcmds[7], ", ".join(cmds[7]))
if cmds.has_key(6):
- answer += self.AnsBase[10] % (lcmds[6]._str(), ", ".join(cmds[6]))
+ answer += self.AnsBase[10] % (lcmds[6], ", ".join(cmds[6]))
if cmds.has_key(5):
- answer += self.AnsBase[11] % (lcmds[5]._str(), ", ".join(cmds[5]))
+ answer += self.AnsBase[11] % (lcmds[5], ", ".join(cmds[5]))
if cmds.has_key(4):
- answer += self.AnsBase[12] % (lcmds[4]._str(), ", ".join(cmds[4]))
+ answer += self.AnsBase[12] % (lcmds[4], ", ".join(cmds[4]))
if cmds.has_key(3):
- answer += self.AnsBase[13] % (lcmds[3]._str(), ", ".join(cmds[3]))
+ answer += self.AnsBase[13] % (lcmds[3], ", ".join(cmds[3]))
if cmds.has_key(2):
- answer += self.AnsBase[14] % (lcmds[2]._str(), ", ".join(cmds[2]))
+ answer += self.AnsBase[14] % (lcmds[2], ", ".join(cmds[2]))
if cmds.has_key(1):
- answer += self.AnsBase[15] % (lcmds[1]._str(), ", ".join(cmds[1]))
+ answer += self.AnsBase[15] % (lcmds[1], ", ".join(cmds[1]))
access = get_access(source[1], source[2])
if access > 8:
access = "%d (Gandalf)" % (access)
@@ -117,7 +115,7 @@ class expansion_temp(expansion):
else:
access = str(access)
answer += self.AnsBase[16] % (access)
- if stype == Types[1]:
+ if stype == sBase[1]:
Answer(AnsBase[11], stype, source, disp)
Message(source[0], answer, disp)
@@ -126,4 +124,4 @@ class expansion_temp(expansion):
(command_comacc, "comacc", 1,),
(command_help, "help", 1, False),
(command_commands, "commands", 1, False)
- )
+ )
diff --git a/expansions/help/insc.py b/expansions/help/insc.py
index 2c48bfa..c1c4c9c 100644
--- a/expansions/help/insc.py
+++ b/expansions/help/insc.py
@@ -20,7 +20,7 @@ if DefLANG in ("RU", "UA"):
"\n\n• Команды для Участников [доступ 1] - %s:\n%s", # 15
"\n\nТвой уровень доступа - %s.", # 16
"Файл со справкой повреждён!" # 17
- )])
+ )])
else:
AnsBase_temp = (
"Command '%s' is located in expansion -> %s", # 0
@@ -41,4 +41,4 @@ else:
"\n\n# User's commands [access 1] - %s:\n%s", # 15
"\n\nYour access level - %s.", # 16
"Help file is damaged!" # 17
- ) \ No newline at end of file
+ ) \ No newline at end of file
diff --git a/expansions/info/code.py b/expansions/info/code.py
index b23f4ee..8ff8872 100644
--- a/expansions/info/code.py
+++ b/expansions/info/code.py
@@ -11,14 +11,14 @@ class expansion_temp(expansion):
expansion.__init__(self, name)
def command_online(self, stype, source, body, disp):
- ls, ThrIds = self.AnsBase[7], iThr.getNames()
+ ls, thrIds = self.AnsBase[7], ithr.getNames()
for numb, disp_ in enumerate(sorted(InstancesDesc.keys()), 1):
- alive = str("%s-%s" % (Types[13], disp_) in ThrIds)
+ alive = str("%s-%s" % (sBase[13], disp_) in thrIds)
connect = online(disp_)
if not connect:
connect = None
ls += "\n%d) %s - %s - %s" % (numb, disp_, str(connect), alive)
- if stype == Types[1]:
+ if stype == sBase[1]:
Answer(AnsBase[11], stype, source, disp)
Message(source[0], ls, disp)
@@ -33,9 +33,9 @@ class expansion_temp(expansion):
for nick in conf.get_users():
if nick.ishere:
online.plus()
- ls.append("%d) %s/%s [%s] \"%s\" (%s) - %s" % (Numb.plus(), cName, conf.nick, disp_, cPref, online._str(), ("%s/%s" % arole if arole else str(arole))))
+ ls.append("%d) %s/%s [%s] \"%s\" (%s) - %s" % (Numb.plus(), cName, conf.nick, disp_, cPref, online, ("%s/%s" % arole if arole else str(arole))))
if ls:
- if stype == Types[1]:
+ if stype == sBase[1]:
Answer(AnsBase[11], stype, source, disp)
ls.insert(0, self.AnsBase[5])
Message(source[0], str.join(chr(10), ls), disp)
@@ -75,7 +75,7 @@ class expansion_temp(expansion):
ls += "\n\nOthers:"
for x in none:
ls += "\n%d) %s" % (Numb.plus(), x)
- if stype == Types[1]:
+ if stype == sBase[1]:
Answer(AnsBase[11], stype, source, disp)
Message(source[0], ls, disp)
else:
@@ -100,9 +100,9 @@ class expansion_temp(expansion):
else:
Numb.plus()
if Number._int():
- if stype == Types[1]:
+ if stype == sBase[1]:
answer = AnsBase[11]
- Message(source[0], self.AnsBase[0] % (Number._str(), str.join(chr(10), ls), Numb._str()), disp)
+ Message(source[0], self.AnsBase[0] % (Number, str.join(chr(10), ls), Numb), disp)
else:
answer = self.AnsBase[1]
elif body in ("dates", "даты".decode("utf-8")):
@@ -110,9 +110,9 @@ class expansion_temp(expansion):
ls = []
for nick in Chats[source[1]].sorted_users():
ls.append("%d. %s\t\t%s" % (Number.plus(), nick.nick, nick.date[2]))
- if stype == Types[1]:
+ if stype == sBase[1]:
answer = AnsBase[11]
- Message(source[0], self.AnsBase[2] % (Number._str(), str.join(chr(10), ls)), disp)
+ Message(source[0], self.AnsBase[2] % (Number, str.join(chr(10), ls)), disp)
elif body in ("roles", "роли".decode("utf-8")):
Number = itypes.Number()
Numb = itypes.Number()
@@ -123,14 +123,14 @@ class expansion_temp(expansion):
else:
Numb.plus()
if Number._int():
- if stype == Types[1]:
+ if stype == sBase[1]:
answer = AnsBase[11]
- Message(source[0], self.AnsBase[3] % (Number._str(), str.join(chr(10), ls), Numb._str()), disp)
+ Message(source[0], self.AnsBase[3] % (Number, str.join(chr(10), ls), Numb), disp)
else:
answer = self.AnsBase[4]
elif body in ("list", "лист".decode("utf-8")):
ls = sorted(Chats[source[1]].get_nicks())
- if stype == Types[1]:
+ if stype == sBase[1]:
answer = AnsBase[11]
Message(source[0], self.AnsBase[2] % (str(len(ls)), ", ".join(ls)), disp)
else:
@@ -146,14 +146,14 @@ class expansion_temp(expansion):
else:
Numb.plus()
if Number._int():
- if stype == Types[1]:
+ if stype == sBase[1]:
answer = AnsBase[11]
- Message(source[0], self.AnsBase[3] % (Number._str(), str.join(chr(10), ls), Numb._str()), disp)
+ Message(source[0], self.AnsBase[3] % (Number, str.join(chr(10), ls), Numb), disp)
else:
answer = self.AnsBase[4]
else:
answer = AnsBase[0]
- if locals().has_key(Types[6]):
+ if locals().has_key(sBase[6]):
Answer(answer, stype, source, disp)
CharsCY = "етуоранкхсвм".decode("utf-8")
@@ -175,17 +175,17 @@ class expansion_temp(expansion):
ls.append("%d) %s (%s) [%s]" % (Numb.plus(), user.nick, conf_str, user.source))
else:
ls.append("%d) %s (%s)" % (Numb.plus(), user.nick, conf_str))
- if Numb._int() >= 20:
+ if Numb >= 20:
break
if Numb._int():
- if stype == Types[1]:
+ if stype == sBase[1]:
answer = AnsBase[11]
- Message(source[0], self.AnsBase[9] % (Numb._str(), str.join(chr(10), ls)), disp)
+ Message(source[0], self.AnsBase[9] % (Numb, str.join(chr(10), ls)), disp)
else:
answer = self.AnsBase[10]
else:
answer = AnsBase[1]
- if locals().has_key(Types[6]):
+ if locals().has_key(sBase[6]):
Answer(answer, stype, source, disp)
commands = (
@@ -194,4 +194,4 @@ class expansion_temp(expansion):
(command_inmuc, "inmuc", 2,),
(command_visitors, "visitors", 4,),
(command_search, "search", 2,)
- )
+ )
diff --git a/expansions/info/insc.py b/expansions/info/insc.py
index 8e0a4c8..6b5e830 100644
--- a/expansions/info/insc.py
+++ b/expansions/info/insc.py
@@ -13,7 +13,7 @@ if DefLANG in ("RU", "UA"):
"Список юзеров в чате:", # 8
"Нашел %s похожих пользователей:\n%s", # 9
"Не знаю." # 10
- )])
+ )])
else:
AnsBase_temp = (
"Today there were %s visitors here:\n%s\n+ %s are still here.", # 0
@@ -27,4 +27,4 @@ else:
"Users-list:", # 8
"Total %s similar users:\n%s", # 9
"No result." # 10
- ) \ No newline at end of file
+ ) \ No newline at end of file
diff --git a/expansions/interpreter/code.py b/expansions/interpreter/code.py
index 0a792a2..7cf5cc1 100644
--- a/expansions/interpreter/code.py
+++ b/expansions/interpreter/code.py
@@ -12,7 +12,7 @@ class expansion_temp(expansion):
def __init__(self, name):
expansion.__init__(self, name)
- opts = ("-l", "-r", "-s")
+ opts = ("-l", "-r", "-s")
opt_locals = opts[0]
opt_result = opts[1]
@@ -29,9 +29,9 @@ class expansion_temp(expansion):
try:
answer = unicode(eval(unicode(body)))
if not answer.strip():
- answer = `answer`
- except Exception, exc:
- answer = exc_str(exc)
+ answer = repr(answer)
+ except:
+ answer = "%s - %s" % exc_info()
else:
answer = AnsBase[1]
if not silent:
@@ -60,7 +60,7 @@ class expansion_temp(expansion):
else:
try:
answer = unicode(result) if self.opt_result in opts else AnsBase[4]
- except Exception, exc:
+ except Exception as exc:
answer = exc_str(exc)
else:
answer = AnsBase[2]
@@ -71,8 +71,8 @@ class expansion_temp(expansion):
def command_sh(self, stype, source, body, disp):
if body:
- if oSlist[1]:
- command = sys_cmds[6] % (body.encode("utf-8"))
+ if OSList[1]:
+ command = cmdsDb[6] % (body.encode("utf-8"))
else:
command = body.encode("cp1251")
answer = get_pipe(command)
@@ -109,4 +109,4 @@ class expansion_temp(expansion):
(command_exec, "exec", 8,),
(command_sh, "sh", 8,),
(command_calc, "calc", 2,)
- )
+ )
diff --git a/expansions/muc/code.py b/expansions/muc/code.py
index 9ae989e..9fb0519 100644
--- a/expansions/muc/code.py
+++ b/expansions/muc/code.py
@@ -22,7 +22,7 @@ class expansion_temp(expansion):
answer = AnsBase[1]
else:
answer = AnsBase[0]
- if locals().has_key(Types[6]):
+ if locals().has_key(sBase[6]):
Answer(answer, stype, source, disp)
sep = chr(47)
@@ -56,7 +56,7 @@ class expansion_temp(expansion):
answer = AnsBase[1]
else:
answer = AnsBase[0]
- if locals().has_key(Types[6]):
+ if locals().has_key(sBase[6]):
Answer(answer, stype, source, disp)
def command_none(self, stype, source, body, disp):
@@ -88,7 +88,7 @@ class expansion_temp(expansion):
answer = AnsBase[1]
else:
answer = AnsBase[0]
- if locals().has_key(Types[6]):
+ if locals().has_key(sBase[6]):
Answer(answer, stype, source, disp)
def command_member(self, stype, source, body, disp):
@@ -120,7 +120,7 @@ class expansion_temp(expansion):
answer = AnsBase[1]
else:
answer = AnsBase[0]
- if locals().has_key(Types[6]):
+ if locals().has_key(sBase[6]):
Answer(answer, stype, source, disp)
def command_admin(self, stype, source, body, disp):
@@ -149,7 +149,7 @@ class expansion_temp(expansion):
answer = AnsBase[1]
else:
answer = AnsBase[0]
- if locals().has_key(Types[6]):
+ if locals().has_key(sBase[6]):
Answer(answer, stype, source, disp)
def command_owner(self, stype, source, body, disp):
@@ -178,7 +178,7 @@ class expansion_temp(expansion):
answer = AnsBase[1]
else:
answer = AnsBase[0]
- if locals().has_key(Types[6]):
+ if locals().has_key(sBase[6]):
Answer(answer, stype, source, disp)
def command_kick(self, stype, source, body, disp):
@@ -209,7 +209,7 @@ class expansion_temp(expansion):
answer = AnsBase[1]
else:
answer = AnsBase[0]
- if locals().has_key(Types[6]):
+ if locals().has_key(sBase[6]):
Answer(answer, stype, source, disp)
def command_visitor(self, stype, source, body, disp):
@@ -240,7 +240,7 @@ class expansion_temp(expansion):
answer = AnsBase[1]
else:
answer = AnsBase[0]
- if locals().has_key(Types[6]):
+ if locals().has_key(sBase[6]):
Answer(answer, stype, source, disp)
def command_participant(self, stype, source, body, disp):
@@ -267,7 +267,7 @@ class expansion_temp(expansion):
answer = AnsBase[1]
else:
answer = AnsBase[0]
- if locals().has_key(Types[6]):
+ if locals().has_key(sBase[6]):
Answer(answer, stype, source, disp)
def command_moder(self, stype, source, body, disp):
@@ -290,7 +290,7 @@ class expansion_temp(expansion):
answer = AnsBase[1]
else:
answer = AnsBase[0]
- if locals().has_key(Types[6]):
+ if locals().has_key(sBase[6]):
Answer(answer, stype, source, disp)
PerfDesc = {"done": 0, "fail": 0}
@@ -310,9 +310,9 @@ class expansion_temp(expansion):
sl = sum(desc.values())
if cl > sl:
desc["none"] = (cl - sl)
- answer = self.AnsBase[2] % desc
+ answer = self.AnsBase[2] % desc
elif desc["fail"]:
- answer = self.AnsBase[3] % desc
+ answer = self.AnsBase[3] % desc
else:
answer = self.AnsBase[4]
return answer
@@ -382,4 +382,4 @@ class expansion_temp(expansion):
(command_moder, "moder", 5,),
(command_fullban, "fullban", 7,),
(command_fullunban, "fullunban", 7,)
- )
+ )
diff --git a/expansions/muc/insc.py b/expansions/muc/insc.py
index 33fb1f9..2f4a5d3 100644
--- a/expansions/muc/insc.py
+++ b/expansions/muc/insc.py
@@ -7,7 +7,7 @@ if DefLANG in ("RU", "UA"):
"Задача выполнена в %(done)d, отклонена в %(fail)d, а также нет ответа из %(none)d конференций.", # 2
"Задача выполнена в %(done)d, отклонена в %(fail)d конференциях.", # 3
"Задача выполнена во всех конференциях." # 4
- )])
+ )])
else:
AnsBase_temp = (
"Security protocols are prohibits this action.", # 0
@@ -15,4 +15,4 @@ else:
"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
+ ) \ No newline at end of file
diff --git a/expansions/new_year/code.py b/expansions/new_year/code.py
index 7cf1547..a77e759 100644
--- a/expansions/new_year/code.py
+++ b/expansions/new_year/code.py
@@ -14,7 +14,7 @@ class expansion_temp(expansion):
list = ["Until the New Year (UTC) left:"]
Time = time.gmtime()
dr = lambda Numb: (Numb, ("s" if Numb >= 2 else ""))
- t0 = (365 if (Time.tm_year%4) else 366)
+ t0 = (365 if (Time.tm_year % 4) else 366)
t1 = (t0 - Time.tm_yday)
t2 = (23 - Time.tm_hour)
t3 = (59 - Time.tm_min)
diff --git a/expansions/note/code.py b/expansions/note/code.py
index ed2630f..cc3928b 100644
--- a/expansions/note/code.py
+++ b/expansions/note/code.py
@@ -38,14 +38,14 @@ class expansion_temp(expansion):
db("select * from note where jid=?", (source_,))
db_desc = db.fetchone()
if db_desc:
- Numb = itypes.Number()
+ numb = itypes.Number()
for line in db_desc:
if not line:
- db("update note set line_%s=? where jid=?" % (Numb._str()), ("[%s] %s" % (date, body), source_))
+ db("update note set line_%s=? where jid=?" % (numb._str()), ("[%s] %s" % (date, body), source_))
db.commit()
- answer = self.AnsBase[7] % (Numb._str())
+ answer = self.AnsBase[7] % (numb._str())
break
- Numb.plus()
+ numb.plus()
else:
answer = self.AnsBase[3]
else:
@@ -55,23 +55,23 @@ class expansion_temp(expansion):
else:
answer = self.AnsBase[1]
elif arg0 in ("-", "*"):
- Numb = ls.pop(0)
- if isNumber(Numb):
- Numb = int(Numb)
- if Numb in xrange(1, 17):
+ numb = ls.pop(0)
+ if isNumber(numb):
+ numb = int(numb)
+ if numb in xrange(1, 17):
with database(self.NoteFile) as db:
db("select * from note where jid=?", (source_,))
db_desc = db.fetchone()
if db_desc:
if arg0 == "*":
- if db_desc[Numb]:
- answer = db_desc[Numb]
+ if db_desc[numb]:
+ answer = db_desc[numb]
else:
answer = self.AnsBase[5]
- elif not db_desc[Numb]:
+ elif not db_desc[numb]:
answer = self.AnsBase[8]
else:
- db("update note set line_%d=? where jid=?" % (Numb), ("", source_))
+ db("update note set line_%d=? where jid=?" % (numb), ("", source_))
db.commit()
answer = AnsBase[4]
else:
@@ -95,7 +95,7 @@ class expansion_temp(expansion):
notes.append("Line[%s] %s" % (numb, line))
if notes:
answer = self.AnsBase[6] + str.join(chr(10), notes)
- if stype == Types[1]:
+ if stype == sBase[1]:
Message(source[0], answer, disp)
answer = AnsBase[11]
else:
@@ -112,7 +112,7 @@ class expansion_temp(expansion):
def init_note_file(self):
if not os.path.isfile(self.NoteFile):
with database(self.NoteFile) as db:
- db("create table note (jid text, %s)" % (", ".join(["line_%s text" % (Numb) for Numb in xrange(1, 17)])))
+ db("create table note (jid text, %s)" % (", ".join(["line_%s text" % (numb) for numb in xrange(1, 17)])))
db.commit()
commands = ((command_note, "note", 2,),)
diff --git a/expansions/note/insc.py b/expansions/note/insc.py
index caff575..5f6a712 100644
--- a/expansions/note/insc.py
+++ b/expansions/note/insc.py
@@ -11,7 +11,7 @@ if DefLANG in ("RU", "UA"):
"Твои записи:\n", # 6
"Запись добавлена под номером - %s.", # 7
"Эта строка итак пуста." # 8
- )])
+ )])
else:
AnsBase_temp = (
"Your note is empty.", # 0
@@ -23,4 +23,4 @@ else:
"Your notes:\n", # 6
"Recorded in line - %s.", # 7
"This line is already empty." # 8
- ) \ No newline at end of file
+ ) \ No newline at end of file
diff --git a/expansions/roster_control/code.py b/expansions/roster_control/code.py
index bc70056..bb49d78 100644
--- a/expansions/roster_control/code.py
+++ b/expansions/roster_control/code.py
@@ -100,7 +100,7 @@ class expansion_temp(expansion):
answer = self.AnsBase[2]
else:
answer = enumerated_list(cls)
- if locals().has_key(Types[6]):
+ if locals().has_key(sBase[6]):
Answer(answer, stype, source, disp)
def command_roster_state(self, stype, source, body, disp):
@@ -133,6 +133,6 @@ class expansion_temp(expansion):
commands = (
(command_roster, "roster", 7,),
(command_roster_state, "roster2", 7,)
- )
+ )
handlers = ((init_roster_state, "00si"),)
diff --git a/expansions/roster_control/insc.py b/expansions/roster_control/insc.py
index 826aea2..82ec92f 100644
--- a/expansions/roster_control/insc.py
+++ b/expansions/roster_control/insc.py
@@ -7,7 +7,7 @@ if DefLANG in ("RU", "UA"):
"У меня нет такого jid'а.", # 2
"Доступ в ростер свободный.", # 3
"Доступ в ростер ограничен." # 4
- )])
+ )])
else:
AnsBase_temp = (
"This jid isn't in that client's roster.", # 0
@@ -15,4 +15,4 @@ else:
"It isn't my jid.", # 2
"Access to the roster is free.", # 3
"Access to the roster is blocked." # 4
- ) \ No newline at end of file
+ ) \ No newline at end of file
diff --git a/expansions/sconf_attrs/code.py b/expansions/sconf_attrs/code.py
index b46e9c8..4bb839d 100644
--- a/expansions/sconf_attrs/code.py
+++ b/expansions/sconf_attrs/code.py
@@ -156,6 +156,6 @@ class expansion_temp(expansion):
(command_status, "botstatus", 7,),
(command_password, "password", 6,),
(command_prefix, "prefix", 1, False)
- )
+ )
handlers = ((load_status, "01si"),)
diff --git a/expansions/sconf_attrs/insc.py b/expansions/sconf_attrs/insc.py
index ed4f337..56f4f43 100644
--- a/expansions/sconf_attrs/insc.py
+++ b/expansions/sconf_attrs/insc.py
@@ -16,7 +16,7 @@ if DefLANG in ("RU", "UA"):
"'%s' является здесь префиксом.", # 11
"Префикс не установлен.", # 12
"Статус '%s' мне неизвестен." # 13
- )])
+ )])
else:
AnsBase_temp = (
"I can't, because '%s' is offline.", # 0
@@ -33,4 +33,4 @@ else:
"'%s' is current prefix here.", # 11
"The prefix wasn't set.", # 12
"'%s' isn't a status." # 13
- ) \ No newline at end of file
+ ) \ No newline at end of file
diff --git a/expansions/session_stats/code.py b/expansions/session_stats/code.py
index f9a04a1..18aec63 100644
--- a/expansions/session_stats/code.py
+++ b/expansions/session_stats/code.py
@@ -17,10 +17,10 @@ class expansion_temp(expansion):
if Number in xrange(len(VarCache["errors"])):
try:
exc = VarCache["errors"][Number]
- if oSlist[0]:
+ if OSList[0]:
exc = exc.decode("cp1251")
exc = str(exc)
- if stype == Types[1]:
+ if stype == sBase[1]:
Answer(AnsBase[11], stype, source, disp)
Message(source[0], exc, disp)
except:
@@ -31,7 +31,7 @@ class expansion_temp(expansion):
answer = AnsBase[30]
else:
answer = self.AnsBase[22] % len(VarCache["errors"])
- if locals().has_key(Types[6]):
+ if locals().has_key(sBase[6]):
Answer(answer, stype, source, disp)
def command_botup(self, stype, source, body, disp):
@@ -39,7 +39,7 @@ class expansion_temp(expansion):
answer = self.AnsBase[15] % (Time2Text(NowTime - Info["up"]))
if Info["alls"]:
answer += self.AnsBase[16] % (Time2Text(NowTime - Info["sess"]), str(len(Info["alls"])), ", ".join(sorted(Info["alls"])))
- elif not oSlist[0]:
+ elif not OSList[0]:
answer += self.AnsBase[17]
Answer(answer, stype, source, disp)
@@ -50,17 +50,17 @@ class expansion_temp(expansion):
if len(Info["alls"]):
answer += self.AnsBase[2] % (Time2Text(NowTime - Info["sess"]))
answer += self.AnsBase[7] % len(Chats.keys())
- answer += self.AnsBase[3] % (Info["msg"]._str())
- answer += self.AnsBase[4] % (Info["cmd"]._str())
- answer += self.AnsBase[5] % (Info["prs"]._str(), Info["iq"]._str())
- answer += self.AnsBase[6] % (Info["omsg"]._str(), Info["outiq"]._str())
+ answer += self.AnsBase[3] % (Info["msg"])
+ answer += self.AnsBase[4] % (Info["cmd"])
+ answer += self.AnsBase[5] % (Info["prs"], Info["iq"])
+ answer += self.AnsBase[6] % (Info["omsg"], Info["outiq"])
Number = itypes.Number()
for conf in Chats.itervalues():
Number.plus(len(conf.get_nicks()))
answer += self.AnsBase[8] % (int(Number))
- answer += self.AnsBase[10] % (len(VarCache["errors"]), Info["errors"]._str())
- answer += self.AnsBase[11] % (Info["cfw"]._str())
- answer += self.AnsBase[12] % (iThr.Counter._str(), len(iThr.enumerate()))
+ answer += self.AnsBase[10] % (len(VarCache["errors"]), Info["errors"])
+ answer += self.AnsBase[11] % (Info["cfw"])
+ answer += self.AnsBase[12] % (ithr.Counter, len(ithr.enumerate()))
answer += self.AnsBase[13] % os.times()[0]
Number = calculate()
if Number:
@@ -71,7 +71,7 @@ class expansion_temp(expansion):
if body:
cmd = body.lower()
if Cmds.has_key(cmd):
- answer = self.AnsBase[18] % (cmd, Cmds[cmd].numb._str(), len(Cmds[cmd].desc))
+ answer = self.AnsBase[18] % (cmd, Cmds[cmd].numb, len(Cmds[cmd].desc))
else:
answer = AnsBase[6]
else:
@@ -88,4 +88,4 @@ class expansion_temp(expansion):
(command_botup, "botup", 1,),
(command_session, "stat", 1,),
(command_stats, "comstat", 1,)
- )
+ )
diff --git a/expansions/session_stats/insc.py b/expansions/session_stats/insc.py
index ef433f8..88c82e9 100644
--- a/expansions/session_stats/insc.py
+++ b/expansions/session_stats/insc.py
@@ -25,7 +25,7 @@ if DefLANG in ("RU", "UA"):
"Невозможно отправить ошибку, смотри к крешлогах.", # 20
"Ошибки №%s не существует!", # 21
"Всего произошло %d ошибок." # 22
- )])
+ )])
else:
AnsBase_temp = (
"\n*// Session's statistics (Pid: %d):", # 0
@@ -51,4 +51,4 @@ else:
"Unable to send error, look for crash logs.", # 20
"Exception #%s isn't exists!", # 21
"Total %d exceptions happened." # 22
- ) \ No newline at end of file
+ ) \ No newline at end of file
diff --git a/expansions/sheriff/code.py b/expansions/sheriff/code.py
index b104840..33c58b0 100644
--- a/expansions/sheriff/code.py
+++ b/expansions/sheriff/code.py
@@ -53,22 +53,22 @@ class expansion_temp(expansion):
def command_order(self, stype, source, body, disp):
- def change_cfg(conf, Name, mode):
- if mode in ("on", "1", "вкл".decode("utf-8")):
- ChatsAttrs[conf]["laws"][Name] = True
+ def change_cfg(chat, opt, state):
+ if state in ("on", "1", "вкл".decode("utf-8")):
+ ChatsAttrs[chat]["laws"][opt] = True
answer = AnsBase[4]
- elif mode in ("off", "0", "выкл".decode("utf-8")):
- ChatsAttrs[conf]["laws"][Name] = False
+ elif state in ("off", "0", "выкл".decode("utf-8")):
+ ChatsAttrs[chat]["laws"][opt] = False
answer = AnsBase[4]
else:
answer = AnsBase[2]
return answer
- def alt_change_cfg(conf, Name, mode, drange):
- if isNumber(mode):
- mode = int(mode)
- if mode in xrange(*drange):
- ChatsAttrs[conf]["laws"][Name] = mode
+ def alt_change_cfg(chat, opt, state, drange):
+ if isNumber(state):
+ state = int(state)
+ if state in xrange(*drange):
+ ChatsAttrs[chat]["laws"][opt] = state
answer = AnsBase[4]
else:
answer = AnsBase[2]
@@ -79,22 +79,22 @@ class expansion_temp(expansion):
if Chats.has_key(source[1]):
if body:
ls = (body.lower()).split()
- Name = ls.pop(0)
+ arg0 = ls.pop(0)
if ls:
- mode = ls.pop(0)
- if Name in ("servers", "сервера".decode("utf-8")):
+ arg1 = ls.pop(0)
+ if arg0 in ("servers", "сервера".decode("utf-8")):
if ls:
- jid = ls.pop(0)
- if jid.count(chr(46)):
- if mode in ("add", "+"):
- if jid not in (self.GoodServers + ChatsAttrs[source[1]]["laws"]["list"]):
- ChatsAttrs[source[1]]["laws"]["list"].append(jid)
+ server = ls.pop(0)
+ if server.count(chr(46)):
+ if arg1 in ("add", "+"):
+ if server not in (self.GoodServers + ChatsAttrs[source[1]]["laws"]["list"]):
+ ChatsAttrs[source[1]]["laws"]["list"].append(server)
answer = AnsBase[4]
else:
answer = self.AnsBase[34]
- elif mode in ("del", "-"):
- if ChatsAttrs[source[1]]["laws"]["list"].count(jid):
- ChatsAttrs[source[1]]["laws"]["list"].remove(jid)
+ elif arg1 in ("del", "-"):
+ if server in ChatsAttrs[source[1]]["laws"]["list"]:
+ ChatsAttrs[source[1]]["laws"]["list"].remove(server)
answer = AnsBase[4]
else:
answer = self.AnsBase[35]
@@ -104,37 +104,37 @@ class expansion_temp(expansion):
answer = self.AnsBase[36]
else:
answer = AnsBase[2]
- elif Name in ("awipe", "антивайп".decode("utf-8")):
- answer = change_cfg(source[1], "awipe", mode)
- elif Name in ("aspace", "антиспэйс".decode("utf-8")):
- answer = change_cfg(source[1], "space", mode)
- elif Name in ("sparta", "спарта".decode("utf-8")):
- answer = change_cfg(source[1], "sparta", mode)
- elif Name in ("verif", "авторизация".decode("utf-8")):
- answer = change_cfg(source[1], "verif", mode)
- elif Name in ("atiser", "антиреклама".decode("utf-8")):
- answer = change_cfg(source[1], "tiser", mode)
- elif Name in ("aobscene", "антимат".decode("utf-8")):
- answer = change_cfg(source[1], "obscene", mode)
- elif Name in ("acaps", "антикапс".decode("utf-8")):
- answer = change_cfg(source[1], "lower", mode)
- elif Name in ("lnick", "никлен".decode("utf-8")):
- answer = alt_change_cfg(source[1], "lnick", mode, (12, 33))
- elif Name in ("aban", "автобан".decode("utf-8")):
- answer = alt_change_cfg(source[1], "aban", mode, (2, 7))
- elif Name in ("loyalty", "лояльность".decode("utf-8")):
- answer = alt_change_cfg(source[1], "loyalty", mode, (1, 6))
- elif Name in ("devoice", "девойс".decode("utf-8")):
- answer = alt_change_cfg(source[1], "dtime", mode, (60, 361))
- elif Name in ("msglen", "мсглен".decode("utf-8")):
- answer = alt_change_cfg(source[1], "len", mode, (512, 2049))
- elif Name in ("prslen", "прзлен".decode("utf-8")):
- answer = alt_change_cfg(source[1], "prlen", mode, (128, 513))
+ elif arg0 in ("awipe", "антивайп".decode("utf-8")):
+ answer = change_cfg(source[1], "awipe", arg1)
+ elif arg0 in ("aspace", "антиспэйс".decode("utf-8")):
+ answer = change_cfg(source[1], "space", arg1)
+ elif arg0 in ("sparta", "спарта".decode("utf-8")):
+ answer = change_cfg(source[1], "sparta", arg1)
+ elif arg0 in ("verif", "авторизация".decode("utf-8")):
+ answer = change_cfg(source[1], "verif", arg1)
+ elif arg0 in ("atiser", "антиреклама".decode("utf-8")):
+ answer = change_cfg(source[1], "tiser", arg1)
+ elif arg0 in ("aobscene", "антимат".decode("utf-8")):
+ answer = change_cfg(source[1], "obscene", arg1)
+ elif arg0 in ("acaps", "антикапс".decode("utf-8")):
+ answer = change_cfg(source[1], "lower", arg1)
+ elif arg0 in ("lnick", "никлен".decode("utf-8")):
+ answer = alt_change_cfg(source[1], "lnick", arg1, (12, 33))
+ elif arg0 in ("aban", "автобан".decode("utf-8")):
+ answer = alt_change_cfg(source[1], "aban", arg1, (2, 7))
+ elif arg0 in ("loyalty", "лояльность".decode("utf-8")):
+ answer = alt_change_cfg(source[1], "loyalty", arg1, (1, 6))
+ elif arg0 in ("devoice", "девойс".decode("utf-8")):
+ answer = alt_change_cfg(source[1], "dtime", arg1, (60, 361))
+ elif arg0 in ("msglen", "мсглен".decode("utf-8")):
+ answer = alt_change_cfg(source[1], "len", arg1, (512, 2049))
+ elif arg0 in ("prslen", "прзлен".decode("utf-8")):
+ answer = alt_change_cfg(source[1], "prlen", arg1, (128, 513))
else:
answer = AnsBase[2]
if answer == AnsBase[4]:
cat_file(chat_file(source[1], self.LawsFile), str(ChatsAttrs[source[1]]["laws"]))
- elif Name in ("servers", "сервера".decode("utf-8")):
+ elif arg0 in ("servers", "сервера".decode("utf-8")):
answer = "\nDefault:\n%s" % enumerated_list(sorted(self.GoodServers))
if ChatsAttrs[source[1]]["laws"]["list"]:
answer += "\n\nDefined:\n%s" % enumerated_list(sorted(ChatsAttrs[source[1]]["laws"]["list"]))
@@ -180,18 +180,18 @@ class expansion_temp(expansion):
answer = AnsBase[0]
Answer(answer, stype, source, disp)
- def special_kick(self, conf, nick, text):
- Chats[conf].kick(nick, "%s: %s" % (get_nick(conf), text))
- raise iThr.ThrKill("exit")
+ def special_kick(self, chat, nick, text):
+ Chats[chat].kick(nick, "%s: %s" % (get_nick(chat), text))
+ raise ithr.ThrKill("exit")
- def sheriffs_loyalty(self, conf):
- access = loy = ChatsAttrs[conf]["laws"]["loyalty"]
+ def sheriffs_loyalty(self, chat):
+ access = loy = ChatsAttrs[chat]["laws"]["loyalty"]
if access > 2:
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)
+ compile_chat = compile__("[^\s]+?@(?:conference|muc|conf|chat|group)\.[\w-]+?\.[\w-]+", 64)
def tiser_checker(self, body):
body = body.lower()
@@ -199,8 +199,8 @@ class expansion_temp(expansion):
return True
return False
- def lower_checker(self, conf, body):
- numb, body = 0, sub_desc(body, [chr(32), chr(10), chr(13), chr(9)] + Chats[conf].get_nicks()).strip()
+ def lower_checker(self, chat, body):
+ numb, body = 0, sub_desc(body, [chr(32), chr(10), chr(13), chr(9)] + Chats[chat].get_nicks()).strip()
for char in body:
if char.isupper():
numb += 1
@@ -212,30 +212,30 @@ class expansion_temp(expansion):
obscene_checker = lambda self, body: self.Obscene.search(chr(32) + body + chr(32))
- def check_nick(self, conf, nick):
+ def check_nick(self, chat, nick):
- def nick_checker(conf, nick):
+ def nick_checker(chat, nick):
if ("%" in nick) or ("/" in nick):
return True
nick = nick.split()[0].lower()
if Cmds.has_key(nick):
return True
- if Chats[conf].cPref and nick.startswith(Chats[conf].cPref):
+ if Chats[chat].cPref and nick.startswith(Chats[chat].cPref):
if Cmds.has_key(nick[1:]):
return True
return False
if (nick.strip()):
- if len(nick) > ChatsAttrs[conf]["laws"]["lnick"]:
- self.special_kick(conf, nick, self.AnsBase[0] % (ChatsAttrs[conf]["laws"]["lnick"]))
- if nick_checker(conf, nick):
- self.special_kick(conf, nick, self.AnsBase[1])
- if ChatsAttrs[conf]["laws"]["space"]:
+ if len(nick) > ChatsAttrs[chat]["laws"]["lnick"]:
+ self.special_kick(chat, nick, self.AnsBase[0] % (ChatsAttrs[chat]["laws"]["lnick"]))
+ if nick_checker(chat, nick):
+ self.special_kick(chat, nick, self.AnsBase[1])
+ if ChatsAttrs[chat]["laws"]["space"]:
if len(nick) != len(nick.strip()):
- self.special_kick(conf, nick, self.AnsBase[2])
- if ChatsAttrs[conf]["laws"]["obscene"]:
+ self.special_kick(chat, nick, self.AnsBase[2])
+ if ChatsAttrs[chat]["laws"]["obscene"]:
if self.obscene_checker(nick):
- self.special_kick(conf, nick, self.AnsBase[3])
+ self.special_kick(chat, nick, self.AnsBase[3])
def sheriff_set(self, stype, source, source_, access, loyalty, body, disp):
if access <= loyalty:
@@ -243,19 +243,19 @@ 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()
Message(source[0], self.AnsBase[16] % (body, ChatsAttrs[source[1]]["laws"]["dtime"]), disp)
- raise iThr.ThrKill("exit")
+ raise ithr.ThrKill("exit")
else:
prisoner.setDevoice()
self.special_kick(source[1], source[2], body)
else:
self.special_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:
@@ -274,9 +274,9 @@ class expansion_temp(expansion):
self.special_kick(source[1], source[2], self.AnsBase[4])
else:
Answer(self.AnsBase[4], stype, source, disp)
- raise iThr.ThrKill("exit")
+ raise ithr.ThrKill("exit")
if ChatsAttrs[source[1]]["laws"]["verif"]:
- if access < 2 and prisoner.vakey and stype == Types[0]:
+ if access < 2 and prisoner.vakey and stype == sBase[0]:
if prisoner.vakey == body.lower():
prisoner.autenticated()
Chats[source[1]].participant(source[2], self.AnsBase[20] % get_nick(source[1]))
@@ -286,7 +286,7 @@ class expansion_temp(expansion):
self.special_kick(source[1], source[2], self.AnsBase[22])
else:
Message(source[0], self.AnsBase[23], disp)
- raise iThr.ThrKill("exit")
+ raise ithr.ThrKill("exit")
list = prisoner.msdates
if len(list) >= 4:
if (list[-1] - list[0]) <= 6:
@@ -296,7 +296,7 @@ class expansion_temp(expansion):
else:
prisoner.msdates.pop(0)
del list
- if stype == Types[1]:
+ if stype == sBase[1]:
if ChatsAttrs[source[1]]["laws"]["obscene"]:
if self.obscene_checker(body):
self.sheriff_set(stype, source, source_, access, loyalty[1], self.AnsBase[5], disp)
@@ -307,18 +307,18 @@ class expansion_temp(expansion):
if self.lower_checker(source[1], body):
self.sheriff_set(stype, source, source_, access, loyalty[1], self.AnsBase[7], disp)
- def awipeClear(self, conf, list):
- if Chats.has_key(conf):
- self.Antiwipe[conf]["clear"] = []
- for sUser in Chats[conf].get_users():
+ def awipeClear(self, chat, list):
+ if chat in Chats:
+ self.Antiwipe[chat]["clear"] = []
+ for sUser in Chats[chat].get_users():
if sUser.source in list:
if not sUser.ishere:
- if Chats[conf].isHere(sUser.nick):
- del Chats[conf].desc[sUser.nick]
- if self.Prison[conf].has_key(sUser.source):
- del self.Prison[conf][sUser.source]
+ if Chats[chat].isHere(sUser.nick):
+ del Chats[chat].desc[sUser.nick]
+ if sUser.source in self.Prison[chat]:
+ del self.Prison[chat][sUser.source]
for source_ in list:
- Chats[conf].none(source_); sleep(0.4)
+ Chats[chat].none(source_); sleep(0.4)
def get_server(self, source, state = False):
at = chr(64)
@@ -328,196 +328,195 @@ class expansion_temp(expansion):
source = source.split(chr(46), 1)[1]
return source
- GoodServers__ = lambda self, conf: (self.GoodServers + ChatsAttrs[conf]["laws"]["list"] + [self.get_server(conf, True)])
+ GoodServers__ = lambda self, chat: (self.GoodServers + ChatsAttrs[chat]["laws"]["list"] + [self.get_server(chat, True)])
- def check_wipe(self, conf, nick, role, inst):
+ def check_wipe(self, chat, nick, role, inst):
if role == aRoles[2]:
- BsNick = get_nick(conf)
- if ChatsAttrs[conf]["laws"]["sparta"]:
+ BsNick = get_nick(chat)
+ if ChatsAttrs[chat]["laws"]["sparta"]:
jid = self.get_server(inst)
- if jid not in self.GoodServers__(conf):
+ if jid not in self.GoodServers__(chat):
Reason = ("%s: This is SPARTA!!" % BsNick)
- Chats[conf].outcast(jid, Reason); Chats[conf].kick(nick, Reason)
- elif ChatsAttrs[conf]["laws"]["awipe"]:
+ Chats[chat].outcast(jid, Reason); Chats[chat].kick(nick, Reason)
+ elif ChatsAttrs[chat]["laws"]["awipe"]:
Time = time.time()
- if (Time - Chats[conf].sdate) >= 60:
- difference = (Time - self.Antiwipe[conf]["ltime"])
- if difference > 360 and self.Antiwipe[conf]["clear"]:
- sThread(self.awipeClear.func_name, self.awipeClear, (conf, self.Antiwipe[conf]["clear"],))
+ if (Time - Chats[chat].sdate) >= 60:
+ difference = (Time - self.Antiwipe[chat]["ltime"])
+ if difference > 360 and self.Antiwipe[chat]["clear"]:
+ sThread(self.awipeClear.__name__, self.awipeClear, (chat, self.Antiwipe[chat]["clear"],))
if difference > 15:
- self.Antiwipe[conf]["ltime"] = Time
- self.Antiwipe[conf]["jids"] = [inst]
+ self.Antiwipe[chat]["ltime"] = Time
+ self.Antiwipe[chat]["jids"] = [inst]
else:
- self.Antiwipe[conf]["jids"].append(inst)
- joined = self.Antiwipe[conf]["jids"]
+ self.Antiwipe[chat]["jids"].append(inst)
+ joined = self.Antiwipe[chat]["jids"]
Numb = len(joined)
if Numb >= 3:
- self.Antiwipe[conf]["ltime"] = Time
+ self.Antiwipe[chat]["ltime"] = Time
jid = self.get_server(inst)
if jid == self.get_server(joined[Numb - 2]) and jid == self.get_server(joined[Numb - 3]):
- if jid not in self.GoodServers__(conf):
+ if jid not in self.GoodServers__(chat):
ls = []
- for sUser in Chats[conf].get_users():
+ for sUser in Chats[chat].get_users():
if sUser.source and sUser.ishere:
if sUser.nick != BsNick and sUser.role[0] == aRoles[2]:
if jid == self.get_server(sUser.source):
- if self.Prison[conf].has_key(sUser.source):
- if not self.Prison[conf][sUser.source].verif:
+ if sUser.source in self.Prison[chat]:
+ if not self.Prison[chat][sUser.source].verif:
ls.append(sUser)
- Chats[conf].outcast(jid, self.AnsBase[12] % (BsNick))
+ Chats[chat].outcast(jid, self.AnsBase[12] % (BsNick))
if ls:
for sUser in ls:
- Chats[conf].kick(sUser.nick, self.AnsBase[12] % (BsNick))
+ Chats[chat].kick(sUser.nick, self.AnsBase[12] % (BsNick))
else:
- for sUser in Chats[conf].get_users():
+ for sUser in Chats[chat].get_users():
if sUser.source and sUser.ishere:
if sUser.nick != BsNick and sUser.role[0] == aRoles[2]:
if jid == self.get_server(sUser.source):
- if self.Prison[conf].has_key(sUser.source):
- if not self.Prison[conf][sUser.source].verif:
- self.Antiwipe[conf]["clear"].append(sUser.source)
- Chats[conf].outcast(sUser.source, self.AnsBase[12] % (BsNick))
+ if sUser.source in self.Prison[chat]:
+ if not self.Prison[chat][sUser.source].verif:
+ self.Antiwipe[chat]["clear"].append(sUser.source)
+ Chats[chat].outcast(sUser.source, self.AnsBase[12] % (BsNick))
else:
- self.Antiwipe[conf]["clear"].append(inst)
- Chats[conf].outcast(inst, self.AnsBase[12] % (BsNick))
- raise iThr.ThrKill("exit")
+ self.Antiwipe[chat]["clear"].append(inst)
+ Chats[chat].outcast(inst, self.AnsBase[12] % (BsNick))
+ raise ithr.ThrKill("exit")
Questions = []
- def sheriff_04eh(self, conf, nick, source_, role, stanza, disp):
- if source_ and nick != get_nick(conf):
- access = get_access(conf, nick)
- if access <= self.sheriffs_loyalty(conf)[1]:
- prisoner = self.Prison[conf].get(source_)
+ def sheriff_04eh(self, chat, nick, source_, role, stanza, disp):
+ if source_ and nick != get_nick(chat):
+ access = get_access(chat, nick)
+ if access <= self.sheriffs_loyalty(chat)[1]:
+ prisoner = self.Prison[chat].get(source_)
if prisoner:
prisoner.addPrTime()
if prisoner.devoice:
eTime = prisoner.getDevoice()
- if (eTime < ChatsAttrs[conf]["laws"]["dtime"]):
- Chats[conf].visitor(nick, self.AnsBase[11] % get_nick(conf))
- Message("%s/%s" % (conf, nick), self.AnsBase[14] % Time2Text(ChatsAttrs[conf]["laws"]["dtime"] - eTime), disp)
+ if (eTime < ChatsAttrs[chat]["laws"]["dtime"]):
+ Chats[chat].visitor(nick, self.AnsBase[11] % get_nick(chat))
+ Message("%s/%s" % (chat, nick), self.AnsBase[14] % Time2Text(ChatsAttrs[chat]["laws"]["dtime"] - eTime), disp)
else:
prisoner.devoice = 0
else:
- self.Prison[conf][source_] = prisoner = self.Convict()
+ self.Prison[chat][source_] = prisoner = self.Convict()
if not prisoner.verif and access >= 2:
prisoner.autenticated()
- self.check_wipe(conf, nick, role[0], source_)
- self.check_nick(conf, nick)
- if ChatsAttrs[conf]["laws"]["verif"] and access < 2 and aRoles[2] == role[0]:
+ self.check_wipe(chat, nick, role[0], source_)
+ self.check_nick(chat, nick)
+ if ChatsAttrs[chat]["laws"]["verif"] and access < 2 and aRoles[2] == role[0]:
if not prisoner.verif and not prisoner.devoice:
- Chats[conf].visitor(nick, self.AnsBase[17] % get_nick(conf))
+ Chats[chat].visitor(nick, self.AnsBase[17] % get_nick(chat))
if not self.Questions:
for qu in self.AnsBase[19].splitlines():
qu, an = qu.split(chr(124), 1)
self.Questions.append((qu.strip(), (an.strip()).lower()))
qu, an = choice(self.Questions)
prisoner.vakey = an
- Message("%s/%s" % (conf, nick), self.AnsBase[18] % (qu), disp)
+ Message("%s/%s" % (chat, nick), self.AnsBase[18] % (qu), disp)
del qu, an
list = prisoner.prdates
if len(list) >= 4:
if (list[-1] - list[0]) <= 10:
prisoner.prdates = [list.pop()]
- self.special_kick(conf, nick, self.AnsBase[13])
+ self.special_kick(chat, nick, self.AnsBase[13])
else:
prisoner.prdates.pop(0)
del list
status = stanza.getStatus()
if status:
- if ChatsAttrs[conf]["laws"]["tiser"]:
+ if ChatsAttrs[chat]["laws"]["tiser"]:
if self.tiser_checker(status):
- self.special_kick(conf, nick, self.AnsBase[4])
- if ChatsAttrs[conf]["laws"]["obscene"]:
+ self.special_kick(chat, nick, self.AnsBase[4])
+ if ChatsAttrs[chat]["laws"]["obscene"]:
if self.obscene_checker(status):
- self.special_kick(conf, nick, self.AnsBase[8])
- if ChatsAttrs[conf]["laws"]["prlen"]:
- if len(status) > ChatsAttrs[conf]["laws"]["prlen"]:
- self.special_kick(conf, nick, self.AnsBase[9])
-
- def sheriff_05eh(self, conf, nick, sbody, scode, disp):
- if nick != get_nick(conf):
- source_ = get_source(conf, nick)
+ self.special_kick(chat, nick, self.AnsBase[8])
+ if ChatsAttrs[chat]["laws"]["prlen"]:
+ if len(status) > ChatsAttrs[chat]["laws"]["prlen"]:
+ self.special_kick(chat, nick, self.AnsBase[9])
+
+ def sheriff_05eh(self, chat, nick, sbody, scode, disp):
+ if nick != get_nick(chat):
+ source_ = get_source(chat, nick)
if source_:
- prisoner = self.Prison[conf].get(source_)
+ prisoner = self.Prison[chat].get(source_)
if prisoner:
- if not Chats[conf].isModer or scode in (sCodes[0], sCodes[3]):
- del self.Prison[conf][source_]
+ if not Chats[chat].isModer or scode in (sCodes[0], sCodes[3]):
+ del self.Prison[chat][source_]
else:
prisoner.leaved()
- if scode == sCodes[2] and prisoner.kicks.plus() >= ChatsAttrs[conf]["laws"]["aban"]:
- if ChatsAttrs[conf]["laws"]["aban"]:
- del self.Prison[conf][source_]
- Chats[conf].outcast(source_, self.AnsBase[10] % (get_nick(conf), ChatsAttrs[conf]["laws"]["aban"]))
-
- def sheriff_06eh(self, conf, old_nick, nick, disp):
- if nick != get_nick(conf) and Chats[conf].isModer:
- sUser = Chats[conf].get_user(nick)
+ if scode == sCodes[2] and prisoner.kicks.plus() >= ChatsAttrs[chat]["laws"]["aban"]:
+ if ChatsAttrs[chat]["laws"]["aban"]:
+ del self.Prison[chat][source_]
+ Chats[chat].outcast(source_, self.AnsBase[10] % (get_nick(chat), ChatsAttrs[chat]["laws"]["aban"]))
+
+ def sheriff_06eh(self, chat, old_nick, nick, disp):
+ if nick != get_nick(chat) and Chats[chat].isModer:
+ sUser = Chats[chat].get_user(nick)
if getattr(sUser, "source", None):
- prisoner = self.Prison[conf].get(sUser.source)
+ prisoner = self.Prison[chat].get(sUser.source)
if prisoner:
prisoner.addPrTime()
- self.check_wipe(conf, nick, sUser.role[0], sUser.source)
- self.check_nick(conf, nick)
+ self.check_wipe(chat, nick, sUser.role[0], sUser.source)
+ self.check_nick(chat, nick)
list = prisoner.prdates
if len(list) >= 4:
if (list[-1] - list[0]) <= 10:
prisoner.prdates = [list.pop()]
- self.special_kick(conf, nick, self.AnsBase[13])
+ self.special_kick(chat, nick, self.AnsBase[13])
else:
prisoner.prdates.pop(0)
- def sheriff_07eh(self, conf, nick, role, disp):
- if nick != get_nick(conf):
- sUser = Chats[conf].get_user(nick)
+ def sheriff_07eh(self, chat, nick, role, disp):
+ if nick != get_nick(chat):
+ sUser = Chats[chat].get_user(nick)
if getattr(sUser, "source", None):
- prisoner = ((sUser.access <= self.sheriffs_loyalty(conf)[1]) and Chats[conf].isModer)
- if self.Prison[conf].has_key(sUser.source):
+ prisoner = ((sUser.access <= self.sheriffs_loyalty(chat)[1]) and Chats[chat].isModer)
+ if sUser.source in self.Prison[chat]:
if not prisoner:
- del self.Prison[conf][sUser.source]
+ del self.Prison[chat][sUser.source]
elif prisoner:
- self.Prison[conf][sUser.source] = self.Convict()
+ self.Prison[chat][sUser.source] = self.Convict()
- def sheriff_08eh(self, conf, nick, stanza, disp):
- if nick != get_nick(conf) and Chats[conf].isModer:
- source_ = get_source(conf, nick)
+ def sheriff_08eh(self, chat, nick, stanza, disp):
+ if nick != get_nick(chat) and Chats[chat].isModer:
+ source_ = get_source(chat, nick)
if source_:
- prisoner = self.Prison[conf].get(source_)
+ prisoner = self.Prison[chat].get(source_)
if prisoner:
prisoner.addPrTime()
list = prisoner.prdates
if len(list) >= 4:
if (list[-1] - list[0]) <= 10:
prisoner.prdates = [list.pop()]
- self.special_kick(conf, nick, self.AnsBase[13])
+ self.special_kick(chat, nick, self.AnsBase[13])
else:
prisoner.prdates.pop(0)
del list
status = stanza.getStatus()
if status:
- if ChatsAttrs[conf]["laws"]["tiser"]:
+ if ChatsAttrs[chat]["laws"]["tiser"]:
if self.tiser_checker(status):
- self.special_kick(conf, nick, self.AnsBase[4])
- if ChatsAttrs[conf]["laws"]["obscene"]:
+ self.special_kick(chat, nick, self.AnsBase[4])
+ if ChatsAttrs[chat]["laws"]["obscene"]:
if self.obscene_checker(status):
- self.special_kick(conf, nick, self.AnsBase[8])
- if ChatsAttrs[conf]["laws"]["prlen"]:
- if len(status) > ChatsAttrs[conf]["laws"]["prlen"]:
- self.special_kick(conf, nick, self.AnsBase[9])
-
- def sheriff_01si(self, conf):
- self.Prison[conf] = {}
- self.Antiwipe[conf] = {"ltime": 0, "jids": [], "clear": []}
- if not ChatsAttrs.has_key(conf):
- ChatsAttrs[conf] = {}
- ChatsAttrs[conf]["laws"] = {"awipe": True, "space": True, "verif": False, "tiser": True, "obscene": False, "lower": False, "sparta": False, "list": [], "dtime": 180, "loyalty": 1, "aban": 3, "prlen": 256, "lnick": 24, "len": 1024}
- Name = chat_file(conf, self.LawsFile)
- if initialize_file(Name, str(ChatsAttrs[conf]["laws"])):
- ChatsAttrs[conf]["laws"] = eval(get_file(Name))
-
- def sheriff_04si(self, conf):
- del self.Prison[conf]
- del self.Antiwipe[conf]
+ self.special_kick(chat, nick, self.AnsBase[8])
+ if ChatsAttrs[chat]["laws"]["prlen"]:
+ if len(status) > ChatsAttrs[chat]["laws"]["prlen"]:
+ self.special_kick(chat, nick, self.AnsBase[9])
+
+ def sheriff_01si(self, chat):
+ self.Prison[chat] = {}
+ self.Antiwipe[chat] = {"ltime": 0, "jids": [], "clear": []}
+ desc = ChatsAttrs.setdefault(chat, {})
+ desc["laws"] = {"awipe": True, "space": True, "verif": False, "tiser": True, "obscene": False, "lower": False, "sparta": False, "list": [], "dtime": 180, "loyalty": 1, "aban": 3, "prlen": 256, "lnick": 24, "len": 1024}
+ filename = chat_file(chat, self.LawsFile)
+ if initialize_file(filename, str(desc["laws"])):
+ desc["laws"] = eval(get_file(filename))
+
+ def sheriff_04si(self, chat):
+ del self.Prison[chat]
+ del self.Antiwipe[chat]
commands = ((command_order, "order", 6,),)
@@ -530,6 +529,6 @@ class expansion_temp(expansion):
(sheriff_06eh, "06eh"),
(sheriff_07eh, "07eh"),
(sheriff_08eh, "08eh")
- )
+ )
del Obscene
diff --git a/expansions/sheriff/insc.py b/expansions/sheriff/insc.py
index 505d6f4..30c2902 100644
--- a/expansions/sheriff/insc.py
+++ b/expansions/sheriff/insc.py
@@ -48,7 +48,7 @@ if DefLANG in ("RU", "UA"):
"Сервер в белом списке.", # 34
"Сервера нет в дополнительном белом списке.", # 35
"Это не сервер." # 36
- )])
+ )])
Obscene = "(?:бляд|\sблят|\sбля\s|\sблять\s|\sплять\s|хуй|\sибал|\sебал|\sхуи|хуител|хуя|\sхую|\sхуе|\sахуе|\sохуе|хуев|хер|\sпох\s|\sнах\s|писд|пизд|рizd|\sпздц\s|\sеб|\sепана\s|\sепать\s|\sипать\s|\sвыепать\s|\sибаш|\sуеб|проеб|праеб|приеб|съеб|взъеб|взьеб|въеб|вьеб|выебан|перееб|недоеб|долбоеб|долбаеб|\sниибац|\sнеебац|\sнеебат|\sниибат|\sпидар|\sрidаr|\sпидар|\sпидор|педор|пидор|пидарас|пидараз|\sпедар|педри|пидри|\sзаеп|\sзаип|\sзаеб|ебучий|ебучка\s|епучий|епучка\s|\sзаиба|заебан|заебис|\sвыеб|выебан|\sпоеб|\sнаеб|\sнаеб|сьеб|взьеб|вьеб|\sгандон|\sгондон|пахуи|похуис|\sманда\s|мандав|залупа|\sзалупог)".decode("utf-8")
else:
@@ -99,6 +99,6 @@ else:
"Server already in the white list.", # 34
"Server not in extra white list.", # 35
"This is not a server." # 36
- )
+ )
Obscene = "(?:\sfuck\s|\sshit\s|\sbitch\s|\sfaggot\s|\scock\s|\scunt\s)" \ No newline at end of file
diff --git a/expansions/talkers/code.py b/expansions/talkers/code.py
index 34e96b6..0762c2f 100644
--- a/expansions/talkers/code.py
+++ b/expansions/talkers/code.py
@@ -63,7 +63,7 @@ class expansion_temp(expansion):
Top_list.reverse()
for x in Top_list:
answer += "\n%d. %s\t\t%d\t%d\t%s" % (Numb.plus(), x[2], x[0], x[1], str(round((float(x[1]) / x[0]), 1)))
- if Numb._int() >= limit:
+ if Numb >= limit:
break
else:
answer = self.AnsBase[1]
@@ -124,7 +124,7 @@ class expansion_temp(expansion):
Usr_list.reverse()
for x in Usr_list:
answer += "\n%d. %s\t\t%d\t%d\t%s" % (Numb.plus(), x[2], x[0], x[1], str(round((float(x[1]) / x[0]), 1)))
- if Numb._int() >= 10:
+ if Numb >= 10:
break
answer += self.AnsBase[3]
else:
@@ -179,7 +179,7 @@ class expansion_temp(expansion):
Answer(answer, stype, source, disp)
def calculate_talkers(self, stanza, isConf, stype, source, body, isToBs, disp):
- if isConf and stype == Types[1] and source[2]:
+ if isConf and stype == sBase[1] and source[2]:
source_ = get_source(source[1], source[2])
if source_:
nick = source[2].strip()
@@ -198,7 +198,7 @@ class expansion_temp(expansion):
with database(filename) as db:
db("create table talkers (jid text, lastnick text, msgs integer, words integer)")
db.commit()
- self.TalkersDesc[conf] = iThr.Semaphore()
+ self.TalkersDesc[conf] = ithr.Semaphore()
def edit_talkers_desc(self, conf):
del self.TalkersDesc[conf]
@@ -209,4 +209,4 @@ class expansion_temp(expansion):
(init_talkers_base, "01si"),
(edit_talkers_desc, "04si"),
(calculate_talkers, "01eh")
- )
+ )
diff --git a/expansions/talkers/insc.py b/expansions/talkers/insc.py
index 071554f..65235b6 100644
--- a/expansions/talkers/insc.py
+++ b/expansions/talkers/insc.py
@@ -6,11 +6,11 @@ if DefLANG in ("RU", "UA"):
"Нет статистики.", # 1
"\n[Фраз][Слов][Коэф.]\n%d\t%d\t%s", # 2
"\n*! Поиск в базе произведён по ключу." # 3
- )])
+ )])
else:
AnsBase_temp = (
"\n[#][User][Messages][Words][Coef.]", # 0
"No statistics.", # 1
"\n[Messages][Words][Coef.]\n%d\t%d\t%s", # 2
"\n*! Search the database produced by the key." # 3
- ) \ No newline at end of file
+ ) \ No newline at end of file
diff --git a/expansions/turn/code.py b/expansions/turn/code.py
index 8b2591e..5ff0e08 100644
--- a/expansions/turn/code.py
+++ b/expansions/turn/code.py
@@ -20,44 +20,44 @@ class expansion_temp(expansion):
TurnBase = {}
def command_turn(self, stype, source, body, disp):
-
- def Turn(conf, body):
+
+ def turn(conf, body):
desc = {}
for user in Chats[conf].get_users():
if user.ishere:
- for app in ([(user.nick + Key) for Key in (":", ",", ">")] + [user.nick]):
+ for app in ([(user.nick + key) for key in (":", ",", ">")] + [user.nick]):
if app in body:
Numb = "*%s*" % str(len(desc.keys()) + 1)
desc[Numb] = app
body = body.replace(app, Numb)
- Turned = str()
+ turned = str()
for smb in body:
if smb in self.TableLA:
- Turned += self.TableRU[self.TableLA.index(smb)]
+ turned += self.TableRU[self.TableLA.index(smb)]
elif smb in self.TableRU:
- Turned += self.TableLA[self.TableRU.index(smb)]
+ turned += self.TableLA[self.TableRU.index(smb)]
else:
- Turned += smb
- return sub_desc(Turned, desc)
-
+ turned += smb
+ return sub_desc(turned, desc)
+
if Chats.has_key(source[1]):
if body:
- answer = "Turn\->\n" + 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))
+ body = "Turn\->\n[%s] <%s>: %s" % (Time, source[2], turn(source[1], body))
Message(source[1], body, disp)
else:
answer = AnsBase[7]
else:
answer = AnsBase[0]
- if locals().has_key(Types[6]):
+ if locals().has_key(sBase[6]):
Answer(answer, stype, source, disp)
def collect_turnable(self, stanza, isConf, stype, source, body, isToBs, disp):
- if isConf and stype == Types[1] and source[2]:
+ if isConf and stype == sBase[1] and source[2]:
source_ = get_source(source[1], source[2])
if source_:
self.TurnBase[source[1]][source_] = (strfTime("%H:%M:%S", False), body)
@@ -74,4 +74,4 @@ class expansion_temp(expansion):
(init_turn_base, "01si"),
(edit_turn_base, "04si"),
(collect_turnable, "01eh")
- )
+ )
diff --git a/expansions/user_stats/code.py b/expansions/user_stats/code.py
index b454c0c..97d389a 100644
--- a/expansions/user_stats/code.py
+++ b/expansions/user_stats/code.py
@@ -75,7 +75,7 @@ class expansion_temp(expansion):
if nick != get_nick(conf):
source_ = get_source(conf, nick)
if source_:
- sbody = UnicodeType(sbody)
+ sbody = str(sbody)
if scode == sCodes[0]:
sbody = "banned:(%s)" % (sbody)
elif scode == sCodes[2]:
@@ -118,7 +118,7 @@ class expansion_temp(expansion):
with database(filename) as db:
db("create table stat (jid text, arole text, joined text, joins integer, seen text, leave text, nicks text)")
db.commit()
- self.UstatsDesc[conf] = iThr.Semaphore()
+ self.UstatsDesc[conf] = ithr.Semaphore()
def edit_stat_desc(self, conf):
del self.UstatsDesc[conf]
@@ -126,7 +126,7 @@ class expansion_temp(expansion):
commands = (
(command_user_stats, "userstat", 2,),
(command_here, "here", 1,)
- )
+ )
handlers = (
(init_stat_base, "01si"),
@@ -135,4 +135,4 @@ class expansion_temp(expansion):
(calc_stat_05eh, "05eh"),
(calc_stat_06eh, "06eh"),
(calc_stat_07eh, "07eh")
- )
+ )
diff --git a/expansions/user_stats/insc.py b/expansions/user_stats/insc.py
index d7d3229..ec465ae 100644
--- a/expansions/user_stats/insc.py
+++ b/expansions/user_stats/insc.py
@@ -9,7 +9,7 @@ if DefLANG in ("RU", "UA"):
"«%s» сидит здесь - %s.", # 4
"Ты провёл здесь - %s.", # 5
"Здесь нет такого юзера." # 6
- )])
+ )])
else:
AnsBase_temp = (
"\nTotal joins - %d\nThe Last join-time - %s\nThe last role - %s", # 0
@@ -19,4 +19,4 @@ else:
"'%s' spent here - %s.", # 4
"You spent here - %s.", # 5
"No such user here." # 6
- ) \ No newline at end of file
+ ) \ No newline at end of file
diff --git a/expansions/wtf/code.py b/expansions/wtf/code.py
index ab3575f..534bfdb 100644
--- a/expansions/wtf/code.py
+++ b/expansions/wtf/code.py
@@ -177,9 +177,9 @@ class expansion_temp(expansion):
commands = (
(command_wtf, "wtf", 2,),
(command_def, "def", 4,)
- )
+ )
handlers = (
(init_wtf_base, "00si"),
(init_local_wtf_base, "01si")
- )
+ )
diff --git a/expansions/wtf/insc.py b/expansions/wtf/insc.py
index 690dc48..8ac3b0a 100644
--- a/expansions/wtf/insc.py
+++ b/expansions/wtf/insc.py
@@ -14,7 +14,7 @@ if DefLANG in ("RU", "UA"):
"Определение «%s» уже есть в глобальной базе.", # 9
"Не существует локальной базы для ростера.", # 10
"\->\n" # -1
- )])
+ )])
else:
AnsBase_temp = (
"There are %d definition(s) in global base:\n%s", # 0
@@ -29,4 +29,4 @@ else:
"'%s' is already in the global base.", # 9
"There is no local base for the roster.", # 10
"\->\n" # -1
- ) \ No newline at end of file
+ ) \ No newline at end of file
diff --git a/librarys.zip b/librarys.zip
index 119239b..1ebb194 100644
--- a/librarys.zip
+++ b/librarys.zip
Binary files differ
diff --git a/static/insc.py b/static/insc.py
index 09f2dfd..66a39bf 100644
--- a/static/insc.py
+++ b/static/insc.py
@@ -33,7 +33,7 @@ if DefLANG in ("RU", "UA"):
"Клиент «%s» упал!", # 28
"JID «%s» используется в другом клиенте! (отключаю его)", # 29
"Это не число." # 30
- )])
+ )])
else:
AnsBase = (
"This command is available only in the conferences.", # 0
@@ -67,4 +67,4 @@ else:
"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
+ ) \ No newline at end of file