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

github.com/alkorgun/blacksmith-2.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAl Korgun <alkorgun@gmail.com>2012-11-28 21:56:00 +0400
committerAl Korgun <alkorgun@gmail.com>2012-11-28 21:56:00 +0400
commit6859929406b0cde290f9ec9b0d72d2bb9d93d308 (patch)
treee3217937a9ceef4802cd38e035ca7691abcad97d
parent07306bf3c49891896c5f88eef94244a5d57023a0 (diff)
refactoring of expansions ("expansion_register" deprecated)
-rw-r--r--BlackSmith.py528
-rw-r--r--expansions/access/code.py36
-rw-r--r--expansions/access/globaccess.en6
-rw-r--r--expansions/access/globaccess.ru6
-rw-r--r--expansions/access/locaccess.en6
-rw-r--r--expansions/access/locaccess.ru6
-rw-r--r--expansions/alive_keeper/code.py54
-rw-r--r--expansions/allweb/code.py256
-rw-r--r--expansions/allweb/insc.py2
-rw-r--r--expansions/apocalypse/code.py10
-rw-r--r--expansions/basic_control/code.py52
-rw-r--r--expansions/books/code.py18
-rw-r--r--expansions/bot_sends/code.py62
-rw-r--r--expansions/calendar/code.py10
-rw-r--r--expansions/clear_stats/code.py6
-rw-r--r--expansions/cmd_control/code.py10
-rw-r--r--expansions/config/client.en4
-rw-r--r--expansions/config/client.ru4
-rw-r--r--expansions/config/code.py159
-rw-r--r--expansions/config/insc.py6
-rw-r--r--expansions/converter/code.py10
-rw-r--r--expansions/cron/code.py20
-rw-r--r--expansions/exp_control/code.py98
-rw-r--r--expansions/exp_control/insc.py8
-rw-r--r--expansions/exp_control/unload.en6
-rw-r--r--expansions/exp_control/unload.ru6
-rw-r--r--expansions/extra_control/code.py31
-rw-r--r--expansions/game/code.py14
-rw-r--r--expansions/get_iq/code.py134
-rw-r--r--expansions/get_iq/uptime.en6
-rw-r--r--expansions/get_iq/uptime.ru4
-rw-r--r--expansions/help/code.py24
-rw-r--r--expansions/info/code.py198
-rw-r--r--expansions/info/insc.py4
-rw-r--r--expansions/interpreter/code.py22
-rw-r--r--expansions/muc/code.py138
-rw-r--r--expansions/new_year/code.py10
-rw-r--r--expansions/note/code.py18
-rw-r--r--expansions/roster_control/code.py14
-rw-r--r--expansions/sconf_attrs/code.py32
-rw-r--r--expansions/session_stats/code.py32
-rw-r--r--expansions/sheriff/code.py54
-rw-r--r--expansions/talkers/code.py14
-rw-r--r--expansions/turn/code.py18
-rw-r--r--expansions/user_stats/code.py26
-rw-r--r--expansions/wtf/code.py14
-rw-r--r--librarys.zipbin98997 -> 98999 bytes
47 files changed, 1054 insertions, 1142 deletions
diff --git a/BlackSmith.py b/BlackSmith.py
index 23432b1..707a00d 100644
--- a/BlackSmith.py
+++ b/BlackSmith.py
@@ -46,31 +46,27 @@ sys_cmds = [
'sh -c "%s" 2>&1' # 6
]
-Types = [
+Types = (
"chat", # 0
"groupchat", # 1
"normal", # 2
"available", # 3
"unavailable", # 4
"subscribe", # 5
- "private", # 6
+ "answer", # 6
"error", # 7
"result", # 8
"set", # 9
"get", # 10
- "received", # 11
- "answer", # 12
- "dispatch-", # 13
- "чат".decode("utf-8"), # 14
- "приват".decode("utf-8"), # 15
+ "jid", # 11
+ "nick", # 12
+ "dispatch", # 13
+ "request", # 14
+ "received", # 15
"ping", # 16
"time", # 17
- "query", # 18
- "jid", # 19
- "nick", # 20
- "can't start new thread", # 21
- "request" # 22
- ]
+ "query" # 18
+ )
aRoles = (
"affiliation", # 0
@@ -128,25 +124,25 @@ eCodesDesc = {
eCodes = sorted(eCodesDesc.keys())
-Features = [
+IqXEPs = (
xmpp.NS_VERSION, # 0
xmpp.NS_PING, # 1
xmpp.NS_TIME, # 2
xmpp.NS_URN_TIME, # 3
xmpp.NS_LAST, # 4
xmpp.NS_DISCO_INFO # 5
- ]
+ )
-aFeatures = Features + [
- xmpp.NS_DISCO_ITEMS,
+XEPs = set(IqXEPs + (
+ xmpp.NS_CAPS,
+ xmpp.NS_SASL,
+ xmpp.NS_TLS,
xmpp.NS_MUC,
- xmpp.NS_PRIVACY,
xmpp.NS_ROSTER,
- xmpp.NS_DATA,
xmpp.NS_RECEIPTS
- ]
+ ))
-IsJID = compile__(".+?@[\w-]+?\.[\w-]+?", 32)
+isJID = compile__(".+?@[\w-]+?\.[\w-]+?", 32)
VarCache = {
"idle": 0.24,
@@ -164,7 +160,7 @@ Info = {
"omsg": itypes.Number(), "outiq": itypes.Number()
}
-# Helpful functions
+# Useful features
class SelfExc(Exception):
pass
@@ -264,7 +260,7 @@ GenConFile = static % ("config.ini")
ConDispFile = static % ("clients.ini")
ChatsFile = dynamic % ("chats.db")
-(BsMark, BsVer, BsRev) = (2, 36, 0)
+(BsMark, BsVer, BsRev) = (2, 37, 0)
if os.access(SvnCache, os.R_OK):
Cache = open(SvnCache).readlines()
@@ -283,7 +279,7 @@ FullName = "HellDev's %s Ver.%s (%s)" % (ProdName, ProdVer, Caps)
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()
@@ -299,8 +295,8 @@ def client_config(config, section):
try:
GenCon = ConfigParser.ConfigParser()
GenCon.read(GenConFile)
- Gen_disp, Instance = client_config(GenCon, "CLIENT")
- InstansesDesc = {Gen_disp: Instance}
+ GenDisp, Instance = client_config(GenCon, "CLIENT")
+ InstansesDesc = {GenDisp: Instance}
ConTls = eval(GenCon.get("STATES", "TLS"))
Mserve = eval(GenCon.get("STATES", "MSERVE"))
GetExc = eval(GenCon.get("STATES", "GETEXC"))
@@ -335,7 +331,7 @@ if oSlist[0]:
os.system(sys_cmds[2])
os.system("%s %s" % (sys_cmds[3], FullName))
-# lists & clients
+# lists & dicts
expansions = {}
Cmds = {}
@@ -403,18 +399,15 @@ def sThread_Run(Thr, handler, command = None):
try:
Thr.start()
except iThr.ThrFail:
- if (exc_info()[1] == Types[21]):
+ try:
+ Try_Thr(Thr)
+ except RuntimeError:
try:
- Try_Thr(Thr)
- except RuntimeError:
- try:
- Thr._run_backup()
- except KeyboardInterrupt:
- raise KeyboardInterrupt("Interrupt (Ctrl+C)")
- except:
- collectExc(handler, command)
- else:
- collectExc(sThread_Run, command)
+ Thr._run_backup()
+ except KeyboardInterrupt:
+ raise KeyboardInterrupt("Interrupt (Ctrl+C)")
+ except:
+ collectExc(handler, command)
except:
collectExc(sThread_Run, command)
@@ -425,7 +418,7 @@ def call_efunctions(ls, list = ()):
for inst in Handlers[ls]:
sThread(ls, inst, list)
-# exceptions, register handlers & commands
+# expansions & commands
class expansion(object):
@@ -433,23 +426,26 @@ class expansion(object):
def __init__(self, name):
self.name = name
- self.path = "%s/%s" % (ExpsDir, self.name)
- self.file = "%s/code.py" % (self.path)
+ self.path = os.path.join(ExpsDir, self.name)
+ self.file = os.path.join(self.path, "code.py")
self.isExp = os.path.isfile(self.file)
- self.insc = "%s/insc.py" % (self.path)
+ self.insc = os.path.join(self.path, "insc.py")
+ if not os.path.isfile(self.insc):
+ self.insc = None
self.cmds = []
self.desc = {}
def initialize_exp(self):
expansions[self.name] = (self)
+ if self.insc:
+ try:
+ self.AnsBase = AnsBase_temp
+ except NameError:
+ pass
for ls in self.commands:
command_handler(self, *ls)
for inst, ls in self.handlers:
self.handler_register(getattr(self, inst.func_name), ls)
- try:
- self.AnsBase = AnsBase_temp
- except NameError:
- pass
def dels(self, full = False):
while self.cmds:
@@ -506,17 +502,18 @@ class expansion(object):
self.desc[ls].append(inst)
def load(self):
+ if expansions.has_key(self.name):
+ expansions[self.name].dels()
try:
+ if self.insc:
+ execfile(self.insc, globals())
execfile(self.file, globals())
+ exp_inst = expansion_temp(self.name)
except:
- result = (self.name, None, exc_info())
+ exp = (None, exc_info())
else:
- result = (self.name, True, ())
- return result
-
- def load_insc(self):
- if os.path.isfile(self.insc):
- execfile(self.insc, globals())
+ exp = (exp_inst, ())
+ return exp
def inst_add(self, ls, inst):
if inst not in Handlers[ls]:
@@ -534,11 +531,6 @@ class expansion(object):
self.inst_add(ls, inst)
self.func_add(ls, inst)
-def expansion_register(name):
- if expansions.has_key(name):
- expansions[name].dels()
- expansions[name].load_insc()
-
class Command(object):
def __init__(self, inst, name, access, help, exp):
@@ -562,22 +554,22 @@ class Command(object):
self.isAvalable = False
self.handler = None
- def execute(self, ltype, source, body, disp):
+ def execute(self, stype, source, body, disp):
if enough_access(source[1], source[2], self.access):
if self.isAvalable and self.handler:
Info["cmd"].plus()
- sThread("command", self.handler, (self.exp, ltype, source, body, disp), self.name)
+ sThread("command", self.handler, (self.exp, stype, source, body, disp), self.name)
self.numb.plus()
source = get_source(source[1], source[2])
if source and source not in self.desc:
self.desc.append(source)
else:
- Answer(AnsBase[19] % (self.name), ltype, source, disp)
+ Answer(AnsBase[19] % (self.name), stype, source, disp)
else:
- Answer(AnsBase[10], ltype, source, disp)
+ Answer(AnsBase[10], stype, source, disp)
-def command_handler(exp_link, handler, name, access, pfx = True):
- Path = os.path.join(ExpsDir, exp_link.name, name)
+def command_handler(exp_inst, handler, name, access, prefix = True):
+ Path = os.path.join(ExpsDir, exp_inst.name, name)
try:
commands = eval(get_file("%s.name" % Path).decode("utf-8"))
except:
@@ -588,12 +580,12 @@ def command_handler(exp_link, handler, name, access, pfx = True):
else:
help = "%s.en" % (Path)
if Cmds.has_key(name):
- Cmds[name].reload(handler, access, help, exp_link)
+ Cmds[name].reload(handler, access, help, exp_inst)
else:
- Cmds[name] = Command(handler, name, access, help, exp_link)
- if not pfx and name not in sCmds:
+ Cmds[name] = Command(handler, name, access, help, exp_inst)
+ if not prefix and name not in sCmds:
sCmds.append(name)
- expansions[exp_link.name].cmds.append(name)
+ exp_inst.cmds.append(name)
# Chats, Users & Other
@@ -604,7 +596,7 @@ class sUser(object):
self.source = source
self.role = role
self.ishere = True
- self.date = (time.time(), Yday(), strTime(local = False))
+ self.date = (time.time(), Yday(), strfTime(local = False))
self.access = access
if not access and access != 0:
self.calc_acc()
@@ -681,7 +673,7 @@ class sConf(object):
call_efunctions("06eh", (self.name, old_nick, nick, self.disp,))
def sleaved(self, nick):
- self.desc[nick].ishere = None
+ self.desc[nick].ishere = False
def composePres(self):
stanza = xmpp.Presence("%s/%s" % (self.name, self.nick))
@@ -691,13 +683,15 @@ class sConf(object):
def join(self):
for sUser in self.get_users():
- sUser.ishere = None
+ sUser.ishere = False
stanza = self.composePres()
self.sdate = time.time()
- query = stanza.setTag("x", namespace = xmpp.NS_MUC)
- query.addChild("history", {"maxchars": "0"})
+ node = xmpp.Node("x")
+ node.setNamespace(xmpp.NS_MUC)
+ node.addChild("history", {"maxchars": "0"})
if self.code:
- query.setTagData("password", self.code)
+ node.setTagData("password", self.code)
+ stanza.addChild(node = node)
self.csend(stanza)
def subject(self, body):
@@ -738,19 +732,19 @@ class sConf(object):
if list.has_key(self.name):
del list[self.name]
else:
- list[self.name] = {"disp": self.disp, Types[20]: self.nick, "cPref": self.cPref, "code": self.code}
+ list[self.name] = {"disp": self.disp, Types[12]: self.nick, "cPref": self.cPref, "code": self.code}
cat_file(ChatsFile, str(list))
else:
delivery(self.name)
- def iq_sender(self, attr, data, afrls, role, text = str(), handler = None):
+ def iq_sender(self, attr, data, afrls, role, reason = str(), handler = None):
stanza = xmpp.Iq(to = self.name, typ = Types[9])
stanza.setID("Bs-i%d" % Info["outiq"].plus())
query = xmpp.Node(Types[18])
query.setNamespace(xmpp.NS_MUC_ADMIN)
arole = query.addChild("item", {attr: data, afrls: role})
- if text:
- arole.setTagData("reason", text)
+ if reason:
+ arole.setTagData("reason", reason)
stanza.addChild(node = query)
if not handler:
self.csend(stanza)
@@ -761,67 +755,61 @@ class sConf(object):
kdesc = {"source": kdesc}
CallForResponse(self.disp, stanza, handler, kdesc)
- def outcast(self, jid, text = str(), handler = ()):
- self.iq_sender(Types[19], jid, aRoles[0], aRoles[1], text, handler)
+ def outcast(self, jid, reason = str(), handler = ()):
+ self.iq_sender(Types[11], jid, aRoles[0], aRoles[1], reason, handler)
- def none(self, jid, text = str(), handler = ()):
- self.iq_sender(Types[19], jid, aRoles[0], aRoles[2], text, handler)
+ def none(self, jid, reason = str(), handler = ()):
+ self.iq_sender(Types[11], jid, aRoles[0], aRoles[2], reason, handler)
- def member(self, jid, text = str(), handler = ()):
- self.iq_sender(Types[19], jid, aRoles[0], aRoles[3], text, handler)
+ def member(self, jid, reason = str(), handler = ()):
+ self.iq_sender(Types[11], jid, aRoles[0], aRoles[3], reason, handler)
- def admin(self, jid, text = str(), handler = ()):
- self.iq_sender(Types[19], jid, aRoles[0], aRoles[4], text, handler)
+ def admin(self, jid, reason = str(), handler = ()):
+ self.iq_sender(Types[11], jid, aRoles[0], aRoles[4], reason, handler)
- def owner(self, jid, text = str(), handler = ()):
- self.iq_sender(Types[19], jid, aRoles[0], aRoles[5], text, handler)
+ def owner(self, jid, reason = str(), handler = ()):
+ self.iq_sender(Types[11], jid, aRoles[0], aRoles[5], reason, handler)
- def kick(self, nick, text = str(), handler = ()):
- self.iq_sender(Types[20], nick, aRoles[6], aRoles[2], text, handler)
+ def kick(self, nick, reason = str(), handler = ()):
+ self.iq_sender(Types[12], nick, aRoles[6], aRoles[2], reason, handler)
- def visitor(self, nick, text = str(), handler = ()):
- self.iq_sender(Types[20], nick, aRoles[6], aRoles[7], text, handler)
+ def visitor(self, nick, reason = str(), handler = ()):
+ self.iq_sender(Types[12], nick, aRoles[6], aRoles[7], reason, handler)
- def participant(self, nick, text = str(), handler = ()):
- self.iq_sender(Types[20], nick, aRoles[6], aRoles[8], text, handler)
+ def participant(self, nick, reason = str(), handler = ()):
+ self.iq_sender(Types[12], nick, aRoles[6], aRoles[8], reason, handler)
- def moder(self, nick, text = str(), handler = ()):
- self.iq_sender(Types[20], nick, aRoles[6], aRoles[9], text, handler)
+ def moder(self, nick, reason = str(), handler = ()):
+ self.iq_sender(Types[12], nick, aRoles[6], aRoles[9], reason, handler)
def get_source(source, nick):
- if Chats.has_key(source):
- if Chats[source].isHere(nick):
- source = getattr(Chats[source].get_user(nick), "source")
- else:
- source = None
+ if source in Chats:
+ access = getattr(Chats[source].get_user(nick), "source", None)
return source
def get_access(source, nick):
- if Chats.has_key(source):
- if Chats[source].isHere(nick):
- access = getattr(Chats[source].get_user(nick), "access")
- else:
- access = 0
+ if source in Chats:
+ access = getattr(Chats[source].get_user(nick), "access", 0)
else:
access = Galist.get(source, 2)
return access
-enough_access = lambda conf, nick, Numb = int(): (Numb <= get_access(conf, nick))
+enough_access = lambda conf, nick, access = 0: (access <= get_access(conf, nick))
-object_encode = lambda body: (body if isinstance(body, UnicodeType) else body.decode("utf-8", str.replace.__name__))
+object_encode = lambda obj: (obj if isinstance(obj, UnicodeType) else str(obj).decode("utf-8", "replace"))
def delivery(body):
try:
- disp, body = Gen_disp, object_encode(body)
- if not online(Gen_disp):
- for desp in Clients.keys():
- if Gen_disp != desp and online(desp):
- disp = desp
+ Disp, body = GenDisp, object_encode(body)
+ if not online(Disp):
+ for disp in Clients.keys():
+ if GenDisp != disp and online(disp):
+ Disp = disp
break
- if Gen_disp == disp:
+ 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, Types[0]))
except IOError:
Print("\n\n%s" % (body), color1)
except SelfExc:
@@ -829,45 +817,44 @@ def delivery(body):
except:
exc_info_()
-def Message(instance, body, disp = None):
+def Message(inst, body, disp = None):
body = object_encode(body)
- if Chats.has_key(instance):
- ltype = Types[1]
+ if Chats.has_key(inst):
+ stype = Types[1]
if not disp:
- disp = Chats[instance].disp
+ disp = Chats[inst].disp
if len(body) > ConfLimit:
- Chats[instance].more = body[ConfLimit:].strip()
- body = (AnsBase[18] % (body[:ConfLimit].strip(), ConfLimit))
+ Chats[inst].more = body[ConfLimit:].strip()
+ body = AnsBase[18] % (body[:ConfLimit].strip(), ConfLimit)
else:
- ltype = Types[0]
+ stype = Types[0]
if not disp:
- if isinstance(instance, xmpp.JID):
- chat = instance.getStripped()
+ if isinstance(inst, xmpp.JID):
+ chat = inst.getStripped()
else:
- chat = (instance.split(chr(47)))[0].lower()
+ chat = (inst.split(chr(47)))[0].lower()
if Chats.has_key(chat):
disp = Chats[chat].disp
else:
- disp = Gen_disp
+ disp = GenDisp
if len(body) > PrivLimit:
- col, all = itypes.Number(), str((len(body) / PrivLimit) + 1)
+ Number, all = itypes.Number(), str(len(body) / PrivLimit + 1)
while len(body) > PrivLimit:
- text = "[%d/%s] %s[...]" % (col.plus(), all, body[:PrivLimit].strip())
Info["omsg"].plus()
- Sender(disp, xmpp.Message(instance, text, ltype))
+ Sender(disp, xmpp.Message(inst, "[%d/%s] %s[...]" % (Number.plus(), all, body[:PrivLimit].strip()), stype))
body = body[PrivLimit:].strip()
sleep(2)
- body = "[%d/%s] %s" % (col.plus(), all, body)
+ body = "[%d/%s] %s" % (Number.plus(), all, body)
Info["omsg"].plus()
- Sender(disp, xmpp.Message(instance, body.strip(), ltype))
+ Sender(disp, xmpp.Message(inst, body.strip(), stype))
-def Answer(body, ltyp, source, disp = None):
+def Answer(body, stype, source, disp = None):
body = object_encode(body)
- if ltyp == Types[1]:
- body = "%s: %s" % (source[2], body)
- Message(source[1], body, disp)
- elif ltyp == Types[0]:
- Message(source[0], body, disp)
+ if stype == Types[1]:
+ instance, body = source[1], "%s: %s" % (source[2], body)
+ else:
+ instance = source[0]
+ Message(instance, body, disp)
def CheckFlood(disp):
disp = get_disp(disp)
@@ -886,8 +873,8 @@ def IdleClient():
for disp in Clients.keys():
if online(disp):
cls[disp] = 0
- for conf in Chats.keys():
- disp = Chats[conf].disp
+ for conf in Chats.itervalues():
+ disp = conf.disp
if cls.has_key(disp):
cls[disp] += 1
if cls:
@@ -895,7 +882,7 @@ def IdleClient():
for disp, chats in cls.items():
if chats == idle:
return disp
- return Gen_disp
+ return GenDisp
def ejoinTimer(conf):
if Chats.has_key(conf):
@@ -903,13 +890,10 @@ def ejoinTimer(conf):
ejoinTimerName = lambda conf: "%s-%s" % (ejoinTimer.func_name, conf.decode("utf-8"))
-def get_self_nick(conf):
- if Chats.has_key(conf):
- return getattr(Chats[conf], Types[20], DefNick)
- return DefNick
-
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)
+
def online(disp):
if isinstance(disp, InstanceType):
disp = get_disp(disp)
@@ -1007,9 +991,9 @@ def get_file(filename):
with open(cefile(filename), "r") as fp:
return fp.read()
-def cat_file(filename, data, otp = "wb"):
+def cat_file(filename, data, otype = "wb"):
with Sequence:
- with open(cefile(filename), otp) as fp:
+ with open(cefile(filename), otype) as fp:
fp.write(data)
# Crashlogs
@@ -1022,7 +1006,7 @@ def collectDFail():
def collectExc(instance, command = None):
Number, instance, error_body = (len(VarCache["errors"]) + 1), instance.func_name, get_exc()
VarCache["errors"].append(error_body)
- if GetExc and online(Gen_disp):
+ if GetExc and online(GenDisp):
if command:
exception = AnsBase[13] % (command, instance)
else:
@@ -1030,7 +1014,7 @@ def collectExc(instance, command = None):
delivery(AnsBase[15] % exception)
else:
Print("\n\nError: can't execute '%s'!" % (instance), color2)
- filename = "%s/error[%d]%s.crash" % (FailDir, (Info["cfw"]._int() + 1), strTime("[%H.%M.%S][%d.%m.%Y]"))
+ filename = "%s/error[%d]%s.crash" % (FailDir, (Info["cfw"]._int() + 1), strfTime("[%H.%M.%S][%d.%m.%Y]"))
try:
if not os.path.exists(FailDir):
os.mkdir(FailDir, 0755)
@@ -1038,7 +1022,7 @@ def collectExc(instance, command = None):
Info["cfw"].plus()
exc_info_(crashfile)
crashfile.close()
- if GetExc and online(Gen_disp):
+ if GetExc and online(GenDisp):
if oSlist[0]:
delivery(AnsBase[16] % (Number, filename))
else:
@@ -1047,7 +1031,7 @@ def collectExc(instance, command = None):
Print("\n\nCrash file --> %s\nError's number --> %d" % (filename, Number), color2)
except:
exc_info_()
- if GetExc and online(Gen_disp):
+ if GetExc and online(GenDisp):
delivery(error_body)
else:
Print(*try_body(error_body, color2))
@@ -1057,21 +1041,24 @@ def collectExc(instance, command = None):
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)):
+ if (".svn" == ExpDir) or not os.path.isdir(os.path.join(ExpsDir, ExpDir)):
continue
- expansions[ExpDir] = exp = expansion(ExpDir)
+ exp = expansion(ExpDir)
if exp.isExp:
- rslt = exp.load()
- if rslt[1]:
- exp = expansion_temp(ExpDir)
- exp.initialize_exp()
- Print("%s - successfully loaded!" % (rslt[0]), color3)
+ exp, exc = exp.load()
+ if exp:
+ try:
+ exp.initialize_exp()
+ except:
+ exc = exc_info()
+ exp.dels(True)
+ Print("Can't init - %s!%s" % (ExpDir, "\n\t* %s: %s" % exc), color2)
+ else:
+ Print("%s - successfully loaded!" % (ExpDir), color3)
else:
- exp.dels(True)
- Print("Can't load - %s!%s" % (rslt[0], "\n\t* %s: %s") % (rslt[2]), color2)
+ Print("Can't load - %s!%s" % (ExpDir, "\n\t* %s: %s" % exc), color2)
else:
- exp.dels(True)
- Print("%s - isn't an expansion!" % (exp.name), color2)
+ Print("%s - isn't an expansion!" % (ExpDir), color2)
def get_pipe(command):
try:
@@ -1178,7 +1165,7 @@ def sub_desc(body, ls, sub = None):
body = body.replace(x, (sub if sub else ""))
return body
-strTime = lambda data = "%d.%m.%Y (%H:%M:%S)", local = True: time.strftime(data, time.localtime() if local else time.gmtime())
+strfTime = lambda data = "%d.%m.%Y (%H:%M:%S)", local = True: time.strftime(data, time.localtime() if local else time.gmtime())
def Time2Text(Time):
ext, ls = [], [("Year", None), ("Day", 365.25), ("Hour", 24), ("Minute", 60), ("Second", 60)]
@@ -1210,7 +1197,7 @@ enumerated_list = lambda ls: str.join(chr(10), ["%d) %s" % (numb, line) for numb
isNumber = lambda obj: (not exec_(int, (obj,)) is None)
-isSource = lambda jid: IsJID.match(jid)
+isSource = lambda jid: isJID.match(jid)
def calculate(Numb = int()):
if oSlist[0]:
@@ -1236,7 +1223,7 @@ def check_copies():
else:
try:
if BsPid == Cache["PID"]:
- Cache["alls"].append(strTime())
+ Cache["alls"].append(strfTime())
elif oSlist[0]:
get_pipe(sys_cmds[4] % (Cache["PID"])); raise SelfExc()
else:
@@ -1273,34 +1260,35 @@ def join_chats():
# Presence Handler
-def Xmpp_Presence_Cb(disp, stanza):
+def XmppPresenceCB(disp, stanza):
Info["prs"].plus()
(source, conf, stype, nick) = sAttrs(stanza)
if not enough_access(conf, nick):
xmpp_raise()
if stype == Types[5]:
- disp = get_disp(disp)
- if Clients[disp].Roster:
+ disp = disp._owner
+ if disp.Roster:
if enough_access(conf, nick, 7):
- Clients[disp].Roster.Authorize(conf)
- Clients[disp].Roster.setItem(conf, conf, ["Admins"])
- Clients[disp].Roster.Subscribe(conf)
+ disp.Roster.Authorize(conf)
+ disp.Roster.setItem(conf, conf, ["Admins"])
+ disp.Roster.Subscribe(conf)
elif Roster["on"]:
- Clients[disp].Roster.Authorize(conf)
- Clients[disp].Roster.setItem(conf, conf, ["Users"])
- Clients[disp].Roster.Subscribe(conf)
+ disp.Roster.Authorize(conf)
+ disp.Roster.setItem(conf, conf, ["Users"])
+ disp.Roster.Subscribe(conf)
else:
Sender(disp, xmpp.Presence(conf, Types[7]))
xmpp_raise()
elif Chats.has_key(conf):
+ Chat = Chats[conf]
if stype == Types[7]:
ecode = stanza.getErrorCode()
if ecode:
if ecode == eCodes[9]:
- Chats[conf].nick = "%s." % (nick)
- Chats[conf].join()
+ Chat.nick = "%s." % (nick)
+ Chat.join()
elif ecode in (eCodes[5], eCodes[12]):
- Chats[conf].IamHere = False
+ Chat.IamHere = False
TimerName = ejoinTimerName(conf)
if TimerName not in iThr.ThrNames():
try:
@@ -1308,74 +1296,74 @@ def Xmpp_Presence_Cb(disp, stanza):
except:
delivery(AnsBase[20] % (ecode, eCodesDesc[ecode], conf))
elif ecode == eCodes[4]:
- Chats[conf].full_leave(eCodesDesc[ecode])
+ Chat.full_leave(eCodesDesc[ecode])
delivery(AnsBase[21] % (ecode, eCodesDesc[ecode], conf))
elif ecode in (eCodes[2], eCodes[6]):
- Chats[conf].leave(eCodesDesc[ecode])
+ Chat.leave(eCodesDesc[ecode])
delivery(AnsBase[22] % (ecode, eCodesDesc[ecode], conf))
elif stype in (Types[3], None):
- if Chats[conf].nick == nick:
- Chats[conf].IamHere = True
+ if Chat.nick == nick:
+ Chat.IamHere = True
Role = GetRole(stanza)
- instance = stanza.getJid()
- if not instance:
- if Chats[conf].isModer:
- Chats[conf].isModer = False
+ inst = stanza.getJid()
+ if not inst:
+ if Chat.isModer:
+ Chat.isModer = False
if not Mserve:
- Chats[conf].change_status(AnsBase[23], sList[2])
+ Chat.change_status(AnsBase[23], sList[2])
Message(conf, AnsBase[24], disp)
xmpp_raise()
elif not Mserve:
xmpp_raise()
- elif Chats[conf].isModer is False:
- if Chats[conf].nick == nick and aDesc.get(Role[0], 0) >= 2:
- Chats[conf].isModer = True
- Chats[conf].leave(AnsBase[25])
+ elif not Chat.isModer:
+ if Chat.nick == nick and aDesc.get(Role[0], 0) >= 2:
+ Chat.isModer = True
+ Chat.leave(AnsBase[25])
sleep(0.4)
- Chats[conf].join()
+ Chat.join()
xmpp_raise()
else:
- instance = (instance.split(chr(47)))[0].lower()
- if Chats[conf].isHereTS(nick) and Chats[conf].isHe(nick, instance):
- Chats[conf].aroles_change(nick, Role, stanza)
+ inst = (inst.split(chr(47)))[0].lower()
+ if Chat.isHereTS(nick) and Chat.isHe(nick, inst):
+ Chat.aroles_change(nick, Role, stanza)
else:
- Chats[conf].sjoined(nick, Role, instance, stanza)
+ Chat.sjoined(nick, Role, inst, stanza)
elif stype == Types[4]:
scode = stanza.getStatusCode()
- if Chats[conf].nick == nick and scode in (sCodes[0], sCodes[2]):
- Chats[conf].full_leave(sCodesDesc[scode])
+ if Chat.nick == nick and scode in (sCodes[0], sCodes[2]):
+ Chat.full_leave(sCodesDesc[scode])
delivery(AnsBase[26] % (scode, conf, sCodesDesc[scode]))
xmpp_raise()
elif not Mserve and not stanza.getJid():
xmpp_raise()
elif scode == sCodes[1]:
Nick = stanza.getNick()
- if Chats[conf].isHere(nick):
- Chats[conf].set_nick(nick, Nick)
+ if Chat.isHere(nick):
+ Chat.set_nick(nick, Nick)
else:
- instance = stanza.getJid()
- if instance:
- instance = (instance.split(chr(47)))[0].lower()
+ inst = stanza.getJid()
+ if inst:
+ inst = (inst.split(chr(47)))[0].lower()
Role = GetRole(stanza)
- if Chats[conf].isHereTS(Nick) and Chats[conf].isHe(Nick, instance):
- Chats[conf].aroles_change(Nick, Role, stanza)
+ if Chat.isHereTS(Nick) and Chat.isHe(Nick, inst):
+ Chat.aroles_change(Nick, Role, stanza)
else:
- Chats[conf].sjoined(Nick, Role, instance)
+ Chat.sjoined(Nick, Role, inst)
else:
status = (stanza.getReason() or stanza.getStatus())
- if Chats[conf].isHereTS(nick):
- Chats[conf].sleaved(nick)
+ if Chat.isHereTS(nick):
+ Chat.sleaved(nick)
call_efunctions("05eh", (conf, nick, status, scode, disp,))
if Chats.has_key(conf):
call_efunctions("02eh", (stanza, disp,))
# Iq Handler
-def Xmpp_Iq_Cb(disp, stanza):
+def XmppIqCB(disp, stanza):
Info["iq"].plus()
ResponseChecker(disp, stanza)
- (source, instance, stype, nick) = sAttrs(stanza)
- if not enough_access(instance, nick):
+ (source, inst, stype, nick) = sAttrs(stanza)
+ if not enough_access(inst, nick):
xmpp_raise()
if stype == Types[10]:
Name = stanza.getQueryNS()
@@ -1383,23 +1371,23 @@ def Xmpp_Iq_Cb(disp, stanza):
Name = (stanza.getTag(Types[16]) or stanza.getTag(Types[17]))
if Name:
Name = Name.getNamespace()
- if Name in Features:
+ if Name in IqXEPs:
answer = stanza.buildReply(Types[8])
- if Name == Features[5]:
- query = answer.getTag(Types[18])
- query.addChild("identity", {"category": "client",
+ if Name == xmpp.NS_DISCO_INFO:
+ anode = answer.getTag(Types[18])
+ anode.addChild("identity", {"category": "client",
"type": "bot",
"name": ProdName[:10]})
- for Feature in aFeatures:
- query.addChild("feature", {"var": Feature})
- elif Name == Features[4]:
- query = answer.getTag(Types[18])
- query.setAttr("seconds", int(time.time() - VarCache["idle"]))
- query.setData(VarCache["action"])
- elif Name == Features[0]:
- query = answer.getTag(Types[18])
- query.setTagData("name", ProdName)
- query.setTagData("version", ProdVer)
+ for feature in XEPs:
+ anode.addChild("feature", {"var": feature})
+ elif Name == xmpp.NS_LAST:
+ anode = answer.getTag(Types[18])
+ anode.setAttr("seconds", int(time.time() - VarCache["idle"]))
+ anode.setData(VarCache["action"])
+ elif Name == xmpp.NS_VERSION:
+ anode = answer.getTag(Types[18])
+ anode.setTagData("name", ProdName)
+ anode.setTagData("version", ProdVer)
PyVer = str(sys.version).split()[0]
if oSlist[0]:
os_name = get_pipe(sys_cmds[5]).strip()
@@ -1407,20 +1395,20 @@ def Xmpp_Iq_Cb(disp, stanza):
os_name = "{0} {2:.16} [{4}]".format(*os.uname())
else:
os_name = "Os[%s]" % (BotOs)
- query.setTagData("os", "%s / PyVer[%s]" % (os_name, PyVer))
- elif Name == Features[2]:
- query = answer.getTag(Types[18])
- query.setTagData("utc", strTime("%Y%m%dT%H:%M:%S", False))
- tz = strTime("%Z")
+ anode.setTagData("os", "%s / PyVer[%s]" % (os_name, PyVer))
+ elif Name == xmpp.NS_TIME:
+ anode = answer.getTag(Types[18])
+ anode.setTagData("utc", strfTime("%Y%m%dT%H:%M:%S", False))
+ tz = strfTime("%Z")
if oSlist[0]:
tz = tz.decode("cp1251")
- query.setTagData("tz", tz)
- query.setTagData("display", time.asctime())
- elif Name == Features[3]:
- query = answer.addChild(Types[17], {}, [], Features[3])
- query.setTagData("utc", strTime("%Y-%m-%dT%H:%M:%SZ", False))
+ anode.setTagData("tz", tz)
+ anode.setTagData("display", time.asctime())
+ elif Name == xmpp.NS_URN_TIME:
+ anode = answer.addChild(Types[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)
- query.setTagData("tzo", "%s%02d:%02d" % (((TimeZone < 0) and "+" or "-"),
+ anode.setTagData("tzo", "%s%02d:%02d" % (((TimeZone < 0) and "+" or "-"),
abs(TimeZone) / 3600,
abs(TimeZone) / 60 % 60))
Sender(disp, answer)
@@ -1429,21 +1417,21 @@ def Xmpp_Iq_Cb(disp, stanza):
# Message Handler
-def Xmpp_Message_Cb(disp, stanza):
+def XmppMessageCB(disp, stanza):
Info["msg"].plus()
- (source, instance, stype, nick) = sAttrs(stanza)
- if not enough_access(instance, nick):
+ (source, inst, stype, nick) = sAttrs(stanza)
+ if not enough_access(inst, nick):
xmpp_raise()
if stanza.getTimestamp():
xmpp_raise()
- isConf = Chats.has_key(instance)
- if not isConf and not enough_access(instance, nick, 7):
+ isConf = Chats.has_key(inst)
+ if not isConf and not enough_access(inst, nick, 7):
if not Roster["on"]:
xmpp_raise()
CheckFlood(disp)
- if not Mserve and isConf and Chats[instance].isModer is False:
+ if isConf and not Mserve and not Chats[inst].isModer:
xmpp_raise()
- BotNick = (DefNick if not isConf else Chats[instance].nick)
+ BotNick = (DefNick if not isConf else Chats[inst].nick)
if nick == BotNick:
xmpp_raise()
Subject = stanza.getSubject()
@@ -1462,18 +1450,18 @@ def Xmpp_Message_Cb(disp, stanza):
if code == eCodes[7]:
if not isConf:
xmpp_raise()
- Chats[instance].join()
+ Chats[inst].join()
sleep(0.6)
Message(source, body)
xmpp_raise()
if Subject:
- call_efunctions("09eh", (instance, nick, Subject, body, disp,))
+ call_efunctions("09eh", (inst, nick, Subject, body, disp,))
else:
Copy, isToBs = body, (stype == Types[0])
if stype != Types[1]:
- if (stanza.getTag(Types[22])):
+ if (stanza.getTag(Types[14])):
answer = xmpp.Message(source)
- answer.setTag(Types[11], namespace = xmpp.NS_RECEIPTS)
+ answer.setTag(Types[15], namespace = xmpp.NS_RECEIPTS)
answer.setID(stanza.getID())
Sender(disp, answer)
stype = Types[0]
@@ -1485,21 +1473,21 @@ def Xmpp_Message_Cb(disp, stanza):
xmpp_raise()
Copy = Copy.split(None, 1)
command = (Copy.pop(0)).lower()
- if not isToBs and isConf and Chats[instance].cPref and command not in sCmds:
- if Chats[instance].cPref == command[:1]:
+ if not isToBs and isConf and Chats[inst].cPref and command not in sCmds:
+ if Chats[inst].cPref == command[:1]:
command = command[1:]
else:
command = False
elif isToBs and not Cmds.has_key(command) and command.startswith(cPrefs):
command = command[1:]
- if isConf and command in Chats[instance].oCmds:
+ if isConf and command in Chats[inst].oCmds:
xmpp_raise()
if Cmds.has_key(command):
VarCache["idle"] = time.time()
VarCache["action"] = AnsBase[27] % command.upper()
- Cmds[command].execute(stype, (source, instance, nick), (Copy[0] if Copy else ""), disp)
+ Cmds[command].execute(stype, (source, inst, nick), (Copy[0] if Copy else ""), disp)
else:
- call_efunctions("01eh", (stanza, isConf, stype, (source, instance, nick), body, isToBs, disp,))
+ call_efunctions("01eh", (stanza, isConf, stype, (source, inst, nick), body, isToBs, disp,))
# Connecting & Dispatching
@@ -1557,20 +1545,20 @@ def connect_client(source, InstanceAttrs):
except:
disp.Roster = None
disp.RespExp = {}
- disp.RegisterHandler(xmpp.NS_PRESENCE, Xmpp_Presence_Cb)
- disp.RegisterHandler(xmpp.NS_IQ, Xmpp_Iq_Cb)
- disp.RegisterHandler(xmpp.NS_MESSAGE, Xmpp_Message_Cb)
+ disp.RegisterHandler(xmpp.NS_PRESENCE, XmppPresenceCB)
+ disp.RegisterHandler(xmpp.NS_IQ, XmppIqCB)
+ disp.RegisterHandler(xmpp.NS_MESSAGE, XmppMessageCB)
Clients[source] = disp
Sender(disp, caps_add(xmpp.Presence(show = sList[0], status = DefStatus)))
return (True, source)
def connectAndDispatch(disp):
- if Reverse_disp(disp, False):
+ if ReverseDisp(disp, False):
sleep(60)
- for conf in Chats.keys():
- if disp == Chats[conf].disp:
- Chats[conf].join()
- Dispatch_handler(disp)
+ for conf in Chats.itervalues():
+ if disp == conf.disp:
+ conf.join()
+ DispatchHandler(disp)
else:
delivery(AnsBase[28] % (disp))
@@ -1580,21 +1568,21 @@ def connect_clients():
if not conn[0]:
if conn[1] and conn[1] == eCodes[2]:
continue
- composeTimer(60, connectAndDispatch, (Types[13] + Inctance), (Inctance,)).start()
+ composeTimer(60, connectAndDispatch, "%s-%s" % (Types[13], Inctance), (Inctance,)).start()
-def Reverse_disp(disp, chats_ = True):
+def ReverseDisp(disp, rejoin = True):
Iters = itypes.Number()
while 1440 > Iters.plus():
if connect_client(disp, InstansesDesc[disp])[0]:
- if chats_:
- for conf in Chats.keys():
- if disp == Chats[conf].disp:
- Chats[conf].join()
+ if rejoin:
+ for conf in Chats.itervalues():
+ if disp == conf.disp:
+ conf.join()
return True
else:
sleep(60)
-def Dispatch_handler(disp):
+def DispatchHandler(disp):
ZeroCycles = itypes.Number()
while VarCache["alive"]:
try:
@@ -1608,7 +1596,7 @@ def Dispatch_handler(disp):
except iThr.ThrKill:
break
except IOError:
- if not Reverse_disp(disp):
+ if not ReverseDisp(disp):
delivery(AnsBase[28] % (disp))
break
ZeroCycles = itypes.Number()
@@ -1616,7 +1604,7 @@ def Dispatch_handler(disp):
delivery(AnsBase[29] % (disp))
break
except xmpp.SystemShutdown:
- if not Reverse_disp(disp):
+ if not ReverseDisp(disp):
delivery(AnsBase[28] % (disp))
break
ZeroCycles = itypes.Number()
@@ -1642,9 +1630,9 @@ def load_mark2():
Print("\n\n%s is ready to serve!\n\n" % (ProdName), color3)
call_sfunctions("02si")
for disp in Clients.keys():
- ThrName = (Types[13] + disp)
+ ThrName = "%s-%s" % (Types[13], disp)
if ThrName not in iThr.ThrNames():
- composeThr(Dispatch_handler, ThrName, (disp,)).start()
+ composeThr(DispatchHandler, ThrName, (disp,)).start()
while VarCache["alive"]:
sleep(180)
Cls = itypes.Number()
diff --git a/expansions/access/code.py b/expansions/access/code.py
index 53cec36..c24c622 100644
--- a/expansions/access/code.py
+++ b/expansions/access/code.py
@@ -1,12 +1,10 @@
# coding: utf-8
# BlackSmith mark.2
-exp_name = "access" # /code.py v.x2
-# Id: 20~2b
+# exp_name = "access" # /code.py v.x2
+# Id: 20~2c
# Code © (2011) by WitcherGeralt [alkorgun@gmail.com]
-expansion_register(exp_name)
-
class expansion_temp(expansion):
def __init__(self, name):
@@ -15,7 +13,7 @@ class expansion_temp(expansion):
AccessFile = dynamic % ("access.db")
ChatAccessFile = "access.db"
- def command_get_access(self, ltype, source, body, disp):
+ def command_get_access(self, stype, source, body, disp):
def get_acc(access):
if access > 8:
@@ -43,25 +41,25 @@ class expansion_temp(expansion):
answer = self.AnsBase[1] % (body, get_acc(Galist.get(body, 0)))
else:
answer = self.AnsBase[2] % (body)
- Answer(answer, ltype, source, disp)
+ Answer(answer, stype, source, disp)
- def command_get_galist(self, ltype, source, body, disp):
+ def command_get_galist(self, stype, source, body, disp):
if Galist:
list = []
for x, y in Galist.items():
list.append([y, x])
list.sort()
list.reverse()
- if ltype == Types[1]:
- Answer(AnsBase[11], ltype, source, disp)
+ if stype == Types[1]:
+ Answer(AnsBase[11], stype, source, disp)
answer, Numb = self.AnsBase[5], itypes.Number()
for x in list:
answer += "%d) %s - %d\n" % (Numb.plus(), x[1], x[0])
Message(source[0], answer, disp)
else:
- Answer(self.AnsBase[3], ltype, source, disp)
+ Answer(self.AnsBase[3], stype, source, disp)
- def command_get_lalist(self, ltype, source, body, disp):
+ def command_get_lalist(self, stype, source, body, disp):
if Chats.has_key(source[1]):
if Chats[source[1]].alist:
list = []
@@ -69,8 +67,8 @@ class expansion_temp(expansion):
list.append([y, x])
list.sort()
list.reverse()
- if ltype == Types[1]:
- Answer(AnsBase[11], ltype, source, disp)
+ if stype == Types[1]:
+ Answer(AnsBase[11], stype, source, disp)
answer, Numb = self.AnsBase[5], itypes.Number()
for x in list:
answer += "%d) %s - %d\n" % (Numb.plus(), x[1], x[0])
@@ -79,10 +77,10 @@ class expansion_temp(expansion):
answer = self.AnsBase[4]
else:
answer = AnsBase[0]
- if locals().has_key(Types[12]):
- Answer(answer, ltype, source, disp)
+ if locals().has_key(Types[6]):
+ Answer(answer, stype, source, disp)
- def command_set_access(self, ltype, source, body, disp):
+ def command_set_access(self, stype, source, body, disp):
def set_access(instance, access = None):
if access != None:
@@ -134,9 +132,9 @@ class expansion_temp(expansion):
answer = AnsBase[2]
else:
answer = AnsBase[1]
- Answer(answer, ltype, source, disp)
+ Answer(answer, stype, source, disp)
- def command_set_local_access(self, ltype, source, body, disp):
+ def command_set_local_access(self, stype, source, body, disp):
def set_access(conf, instance, access = None):
if access != None:
@@ -192,7 +190,7 @@ class expansion_temp(expansion):
answer = AnsBase[1]
else:
answer = AnsBase[0]
- Answer(answer, ltype, source, disp)
+ Answer(answer, stype, source, disp)
def load_acclist(self):
if initialize_file(self.AccessFile):
diff --git a/expansions/access/globaccess.en b/expansions/access/globaccess.en
deleted file mode 100644
index af582ea..0000000
--- a/expansions/access/globaccess.en
+++ /dev/null
@@ -1,6 +0,0 @@
-bot sets global access
-globaccess [!/access] [jid/nick]
-*/globaccess 6 Obi-Wan Kenobi
-bot would set access level 6 for Obi-Wan Kenobi
-*/globaccess ! obi-wan_kenobi@jab.net
-bot would remove obi-wan_kenobi@jab.net from global access list \ No newline at end of file
diff --git a/expansions/access/globaccess.ru b/expansions/access/globaccess.ru
deleted file mode 100644
index 85111dd..0000000
--- a/expansions/access/globaccess.ru
+++ /dev/null
@@ -1,6 +0,0 @@
-бот устанавливает глобальный доступ для указанного пользователя
-глобдоступ [!/доступ] [jid/nick]
-*/глобдоступ 6 Оби-Ван Кеноби
-бот установит доступ 6 для Оби-Ван Кеноби
-*/глобдоступ ! obi-wan_kenobi@jab.net
-бот снимет доступ с obi-wan_kenobi@jab.net \ No newline at end of file
diff --git a/expansions/access/locaccess.en b/expansions/access/locaccess.en
deleted file mode 100644
index fb7b5bd..0000000
--- a/expansions/access/locaccess.en
+++ /dev/null
@@ -1,6 +0,0 @@
-bot sets local access
-globaccess [!/access] [jid/nick]
-*/globaccess 6 Obi-Wan Kenobi
-bot would set local access with level 6 for Obi-Wan Kenobi
-*/globaccess ! obi-wan_kenobi@jab.net
-bot would remove obi-wan_kenobi@jab.net from local access list \ No newline at end of file
diff --git a/expansions/access/locaccess.ru b/expansions/access/locaccess.ru
deleted file mode 100644
index c4469d5..0000000
--- a/expansions/access/locaccess.ru
+++ /dev/null
@@ -1,6 +0,0 @@
-бот устанавливает локальный доступ для указанного пользователя
-локдоступ [!/доступ] [jid/nick]
-*/локдоступ 6 Оби-Ван Кеноби
-бот установит локальный доступ 6 для Оби-Ван Кеноби
-*/локдоступ ! obi-wan_kenobi@jab.net
-бот снимет доступ с obi-wan_kenobi@jab.net \ No newline at end of file
diff --git a/expansions/alive_keeper/code.py b/expansions/alive_keeper/code.py
index e39ad8c..a614a13 100644
--- a/expansions/alive_keeper/code.py
+++ b/expansions/alive_keeper/code.py
@@ -1,12 +1,10 @@
# coding: utf-8
# BlackSmith mark.2
-exp_name = "alive_keeper" # /code.py v.x4
-# Id: 16~4b
+# exp_name = "alive_keeper" # /code.py v.x5
+# Id: 16~5c
# Code © (2011) by WitcherGeralt [alkorgun@gmail.com]
-expansion_register(exp_name)
-
class expansion_temp(expansion):
def __init__(self, name):
@@ -21,26 +19,26 @@ class expansion_temp(expansion):
while VarCache["alive"]:
sleep(360)
ThrIds = iThr.ThrNames()
- for disp in Clients.keys():
- if not hasattr(Clients[disp], "aKeeper"):
- Clients[disp].aKeeper = itypes.Number()
- if Clients[disp].aKeeper._int() >= 3:
- Clients[disp].aKeeper = itypes.Number()
- ThrName = (Types[13] + disp)
+ for disp_str, disp in Clients.iteritems():
+ if not hasattr(disp, "aKeeper"):
+ disp.aKeeper = itypes.Number()
+ if disp.aKeeper._int() >= 3:
+ disp.aKeeper = itypes.Number()
+ ThrName = "%s-%s" % (Types[13], disp_str)
if ThrName in ThrIds:
for Thr in iThr.enumerate():
if Thr._Thread__name == ThrName:
Thr.kill()
try:
- composeThr(connectAndDispatch, ThrName, (disp,)).start()
+ composeThr(connectAndDispatch, ThrName, (disp_str,)).start()
except:
- delivery(AnsBase[28] % (disp))
+ delivery(AnsBase[28] % (disp_str))
elif expansions.has_key(self.name):
- Clients[disp].aKeeper.plus()
- iq = xmpp.Iq(to = "%s/%s" % (disp, GenResource), typ = Types[10])
- iq.addChild(Types[16], {}, [], xmpp.NS_PING)
+ disp.aKeeper.plus()
+ iq = xmpp.Iq(to = "%s/%s" % (disp_str, GenResource), typ = Types[10])
+ iq.addChild(Types[16], namespace = xmpp.NS_PING)
iq.setID("Bs-i%d" % Info["outiq"].plus())
- CallForResponse(disp, iq, alive_keeper_answer)
+ CallForResponse(disp_str, iq, alive_keeper_answer)
del iq
else:
raise iThr.ThrKill("exit")
@@ -59,25 +57,25 @@ class expansion_temp(expansion):
while VarCache["alive"]:
sleep(360)
ThrIds = iThr.ThrNames()
- for conf in Chats.keys():
- if not (online(Chats[conf].disp) and Chats[conf].IamHere):
+ for conf in Chats.itervalues():
+ if not (online(conf.disp) and conf.IamHere):
continue
- if not hasattr(Chats[conf], "aKeeper"):
- Chats[conf].aKeeper = itypes.Number()
- if Chats[conf].aKeeper._int() >= 3:
- Chats[conf].aKeeper = itypes.Number()
- TimerName = ejoinTimerName(conf)
+ if not hasattr(conf, "aKeeper"):
+ conf.aKeeper = itypes.Number()
+ if conf.aKeeper._int() >= 3:
+ conf.aKeeper = itypes.Number()
+ TimerName = ejoinTimerName(conf.name)
if TimerName not in ThrIds:
try:
- composeTimer(180, ejoinTimer, TimerName, (conf,)).start()
+ composeTimer(180, ejoinTimer, TimerName, (conf.name,)).start()
except:
pass
elif expansions.has_key(self.name):
- Chats[conf].aKeeper.plus()
- iq = xmpp.Iq(to = "%s/%s" % (conf, get_self_nick(conf)), typ = Types[10])
- iq.addChild(Types[18], {}, [], xmpp.NS_PING)
+ conf.aKeeper.plus()
+ iq = xmpp.Iq(to = "%s/%s" % (conf.name, conf.nick), typ = Types[10])
+ iq.addChild(Types[18], namespace = xmpp.NS_PING)
iq.setID("Bs-i%d" % Info["outiq"].plus())
- CallForResponse(Chats[conf].disp, iq, conf_alive_keeper_answer, {"conf": conf})
+ CallForResponse(conf.disp, iq, conf_alive_keeper_answer, {"conf": conf.name})
del iq
else:
raise iThr.ThrKill("exit")
diff --git a/expansions/allweb/code.py b/expansions/allweb/code.py
index ee8b3ed..e0ee80f 100644
--- a/expansions/allweb/code.py
+++ b/expansions/allweb/code.py
@@ -1,12 +1,10 @@
# coding: utf-8
# BlackSmith mark.2
-exp_name = "allweb" # /code.py v.x20
-# Id: 25~20b
+# exp_name = "allweb" # /code.py v.x21
+# Id: 25~21c
# Code © (2011-2012) by WitcherGeralt [alkorgun@gmail.com]
-expansion_register(exp_name)
-
class expansion_temp(expansion):
def __init__(self, name):
@@ -74,7 +72,7 @@ class expansion_temp(expansion):
data = self.sub_ehtmls(data)
return data.strip()
- def command_jc(self, ltype, source, body, disp):
+ def command_jc(self, stype, source, body, disp):
if Chats.has_key(source[1]):
if body:
cName = body.lower()
@@ -82,9 +80,9 @@ class expansion_temp(expansion):
cName = (cName.split("@conf"))[0]
else:
cName = (source[1].split("@conf"))[0]
- Req = Web("http://jc.jabber.ru/search.html?", [("search", cName.encode("utf-8"))])
+ Opener = Web("http://jc.jabber.ru/search.html?", [("search", cName.encode("utf-8"))])
try:
- data = Req.get_page(self.UserAgent)
+ data = Opener.get_page(self.UserAgent)
except Web.Two.HTTPError, exc:
answer = str(exc)
except:
@@ -94,29 +92,28 @@ class expansion_temp(expansion):
comp = compile__("<li>((?:.|\s)+?)</li>", 16)
list = comp.findall(data)
if list:
- Number = itypes.Number()
ls = []
- for line in list:
+ for numb, line in enumerate(list, 1):
line = line.strip()
- ls.append("%d) %s" % (Number.plus(), line))
- answer = (chr(10) + self.decodeHTML(str.join(chr(10)*2, ls)))
+ ls.append("%d) %s" % (numb, line))
+ answer = chr(10) + self.decodeHTML(str.join(chr(10)*2, ls))
else:
answer = self.AnsBase[5]
else:
answer = AnsBase[0]
- Answer(answer, ltype, source, disp)
+ Answer(answer, stype, source, disp)
gCache = []
sMark = 1
tMark = 2
- def command_google(self, ltype, source, body, disp):
+ def command_google(self, stype, source, body, disp):
if body:
if (chr(42) != body):
- Req = Web("http://ajax.googleapis.com/ajax/services/search/web?", [("v", "1.0"), ("q", body.encode("utf-8"))])
+ Opener = Web("http://ajax.googleapis.com/ajax/services/search/web?", [("v", "1.0"), ("q", body.encode("utf-8"))])
try:
- data = Req.get_page(self.UserAgent)
+ data = Opener.get_page(self.UserAgent)
except Web.Two.HTTPError, exc:
answer = str(exc)
except:
@@ -174,22 +171,24 @@ class expansion_temp(expansion):
answer = self.AnsBase[3]
else:
answer = AnsBase[1]
- Answer(answer, ltype, source, disp)
+ Answer(answer, stype, source, disp)
+
+ LangMap = LangMap
- def command_google_translate(self, ltype, source, body, disp):
+ def command_google_translate(self, stype, source, body, disp):
if body:
if (chr(42) != body):
body = body.split(None, 2)
if len(body) == 3:
lang0, langX, body = body
- if langX in LangMap and (lang0 in LangMap or lang0 == "auto"):
+ if langX in self.LangMap and (lang0 in self.LangMap or lang0 == "auto"):
desc = (("client", "bs-2"),
("sl", lang0),
("tl", langX),
("text", body.encode("utf-8")))
- Req = Web("http://translate.google.com/translate_a/t?", desc, {"Accept-Charset": "utf-8"})
+ Opener = Web("http://translate.google.com/translate_a/t?", desc, {"Accept-Charset": "utf-8"})
try:
- data = Req.get_page(self.UserAgent_Moz)
+ data = Opener.get_page(self.UserAgent_Moz)
except Web.Two.HTTPError, exc:
answer = str(exc)
except:
@@ -252,8 +251,11 @@ class expansion_temp(expansion):
else:
answer = self.AnsBase[3]
else:
- answer = self.AnsBase[8] + str.join(chr(10), ["%s - %s" % (k, l) for k, l in sorted(LangMap.items())])
- Answer(answer, ltype, source, disp)
+ answer = self.AnsBase[8] + str.join(chr(10), ["%s - %s" % (k, l) for k, l in sorted(self.LangMap.items())])
+ if stype == Types[1]:
+ Message(source[0], answer, disp)
+ answer = AnsBase[11]
+ Answer(answer, stype, source, disp)
kinoHeaders = {
"Host": "m.kinopoisk.ru",
@@ -264,7 +266,7 @@ class expansion_temp(expansion):
C3oP = "СЗоР"
- def command_kino(self, ltype, source, body, disp):
+ def command_kino(self, stype, source, body, disp):
if body:
ls = body.split()
c1st = (ls.pop(0)).lower()
@@ -277,9 +279,9 @@ class expansion_temp(expansion):
limit = None
kinoHeaders = self.kinoHeaders.copy()
kinoHeaders["Host"] = "www.kinopoisk.ru"
- Req = Web("http://www.kinopoisk.ru/level/20/", headers = kinoHeaders)
+ Opener = Web("http://www.kinopoisk.ru/level/20/", headers = kinoHeaders)
try:
- data = Req.get_page(self.UserAgent_Moz)
+ data = Opener.get_page(self.UserAgent_Moz)
except Web.Two.HTTPError, exc:
answer = str(exc)
except:
@@ -299,8 +301,8 @@ class expansion_temp(expansion):
if limit and limit <= Number._int():
break
if not limit or limit > 25:
- if ltype == Types[1]:
- Answer(AnsBase[11], ltype, source, disp)
+ if stype == Types[1]:
+ Answer(AnsBase[11], stype, source, disp)
Top250 = str.join(chr(10), ls)
Message(source[0], Top250, disp)
else:
@@ -310,9 +312,9 @@ class expansion_temp(expansion):
else:
answer = self.AnsBase[1]
elif isNumber(body):
- Req = Web("http://m.kinopoisk.ru/movie/%s" % (body), headers = self.kinoHeaders.copy())
+ Opener = Web("http://m.kinopoisk.ru/movie/%s" % (body), headers = self.kinoHeaders.copy())
try:
- data = Req.get_page(self.UserAgent_Moz)
+ data = Opener.get_page(self.UserAgent_Moz)
except Web.Two.HTTPError, exc:
answer = str(exc)
except:
@@ -335,12 +337,12 @@ class expansion_temp(expansion):
else:
answer = self.AnsBase[5]
else:
- Req = (body if chr(42) != c1st else body[2:].strip())
- if Req:
- Req = Req.encode("cp1251")
- Req = Web("http://m.kinopoisk.ru/search/%s" % Web.One.quote_plus(Req), headers = self.kinoHeaders.copy())
+ body = (body if chr(42) != c1st else body[2:].strip())
+ if body:
+ body = body.encode("cp1251")
+ Opener = Web("http://m.kinopoisk.ru/search/%s" % Web.One.quote_plus(body), headers = self.kinoHeaders.copy())
try:
- data = Req.get_page(self.UserAgent_Moz)
+ data = Opener.get_page(self.UserAgent_Moz)
except Web.Two.HTTPError, exc:
answer = str(exc)
except:
@@ -363,12 +365,12 @@ class expansion_temp(expansion):
answer = AnsBase[2]
else:
answer = AnsBase[1]
- if locals().has_key(Types[12]):
- Answer(answer, ltype, source, disp)
+ if locals().has_key(Types[6]):
+ Answer(answer, stype, source, disp)
IMDbHeaders = {"Accept-Language": "%s,en" % UserAgents.get(DefLANG, "en-US")}
- def command_imdb(self, ltype, source, body, disp):
+ def command_imdb(self, stype, source, body, disp):
if body:
ls = body.split()
c1st = (ls.pop(0)).lower()
@@ -379,9 +381,9 @@ class expansion_temp(expansion):
limit = 5
else:
limit = None
- Req = Web("http://www.imdb.com/chart/top", headers = self.IMDbHeaders)
+ Opener = Web("http://www.imdb.com/chart/top", headers = self.IMDbHeaders)
try:
- data = Req.get_page(self.UserAgent_Moz)
+ data = Opener.get_page(self.UserAgent_Moz)
except Web.Two.HTTPError, exc:
answer = str(exc)
except:
@@ -402,8 +404,8 @@ class expansion_temp(expansion):
if limit and limit <= Number._int():
break
if not limit or limit > 25:
- if ltype == Types[1]:
- Answer(AnsBase[11], ltype, source, disp)
+ if stype == Types[1]:
+ Answer(AnsBase[11], stype, source, disp)
Top250 = str.join(chr(10), ls)
Message(source[0], Top250, disp)
else:
@@ -411,9 +413,9 @@ class expansion_temp(expansion):
else:
answer = self.AnsBase[1]
elif isNumber(body):
- Req = Web("http://www.imdb.com/title/tt%s/" % (body), headers = self.IMDbHeaders)
+ Opener = Web("http://www.imdb.com/title/tt%s/" % (body), headers = self.IMDbHeaders)
try:
- data = Req.get_page(self.UserAgent_Moz)
+ data = Opener.get_page(self.UserAgent_Moz)
except Web.Two.HTTPError, exc:
answer = str(exc)
except:
@@ -451,12 +453,12 @@ class expansion_temp(expansion):
else:
answer = self.AnsBase[1]
else:
- Req = (body if chr(42) != c1st else body[2:].strip())
- if Req:
- Req = Req.encode("utf-8")
- Req = Web("http://www.imdb.com/find?", [("s", "tt"), ("q", Req)], self.IMDbHeaders)
+ body = (body if chr(42) != c1st else body[2:].strip())
+ if body:
+ body = body.encode("utf-8")
+ Opener = Web("http://www.imdb.com/find?", [("s", "tt"), ("q", body)], self.IMDbHeaders)
try:
- data = Req.get_page(self.UserAgent_Moz)
+ data = Opener.get_page(self.UserAgent_Moz)
except Web.Two.HTTPError, exc:
answer = str(exc)
except:
@@ -479,13 +481,13 @@ class expansion_temp(expansion):
answer = AnsBase[2]
else:
answer = AnsBase[1]
- if locals().has_key(Types[12]):
- Answer(answer, ltype, source, disp)
+ if locals().has_key(Types[6]):
+ Answer(answer, stype, source, disp)
- def command_python(self, ltype, source, body, disp):
- Req = Web("http://python.org/")
+ def command_python(self, stype, source, body, disp):
+ Opener = Web("http://python.org/")
try:
- data = Req.get_page(self.UserAgent)
+ data = Opener.get_page(self.UserAgent)
except Web.Two.HTTPError, exc:
answer = str(exc)
except:
@@ -502,13 +504,13 @@ class expansion_temp(expansion):
answer = str.join(chr(10), ls)
else:
answer = self.AnsBase[1]
- Answer(answer, ltype, source, disp)
+ Answer(answer, stype, source, disp)
- def command_url_shorten(self, ltype, source, body, disp):
+ def command_url_shorten(self, stype, source, body, disp):
if body:
- Req = Web("http://is.gd/create.php?", [("format", "json"), ("url", body.encode("utf-8"))])
+ Opener = Web("http://is.gd/create.php?", [("format", "json"), ("url", body.encode("utf-8"))])
try:
- data = Req.get_page(self.UserAgent)
+ data = Opener.get_page(self.UserAgent)
except Web.Two.HTTPError, exc:
answer = str(exc)
except:
@@ -528,7 +530,7 @@ class expansion_temp(expansion):
answer = self.AnsBase[1]
else:
answer = AnsBase[1]
- Answer(answer, ltype, source, disp)
+ Answer(answer, stype, source, disp)
downloadLock = iThr.allocate_lock()
@@ -562,7 +564,7 @@ class expansion_temp(expansion):
fb[1] = Time
Message(fb[0], self.AnsBase[9].format(Pcts), fb[2])
- def command_download(self, ltype, source, body, disp):
+ def command_download(self, stype, source, body, disp):
if body:
if not self.downloadLock.locked():
with self.downloadLock:
@@ -594,9 +596,9 @@ class expansion_temp(expansion):
folder = folder.decode("utf-8")
if link:
Message(source[0], self.AnsBase[10], disp)
- Req = Web(link)
+ Opener = Web(link)
try:
- data = Req.download(filename, folder, self.download_process, [source[0], time.time(), disp, 0, 0], self.UserAgent)
+ data = Opener.download(filename, folder, self.download_process, [source[0], time.time(), disp, 0, 0], self.UserAgent)
except Web.Two.HTTPError, exc:
answer = str(exc)
except SelfExc:
@@ -611,17 +613,17 @@ class expansion_temp(expansion):
answer = self.AnsBase[11]
else:
answer = AnsBase[1]
- Answer(answer, ltype, source, disp)
+ Answer(answer, stype, source, disp)
if DefLANG in ("RU", "UA"):
- def command_chuck(self, ltype, source, body, disp):
+ def command_chuck(self, stype, source, body, disp):
if body and isNumber(body):
- Req = Web("http://chucknorrisfacts.ru/quote/%d" % int(body))
+ Opener = Web("http://chucknorrisfacts.ru/quote/%d" % int(body))
else:
- Req = Web("http://chucknorrisfacts.ru/random")
+ Opener = Web("http://chucknorrisfacts.ru/random")
try:
- data = Req.get_page(self.UserAgent)
+ data = Opener.get_page(self.UserAgent)
except Web.Two.HTTPError, exc:
answer = str(exc)
except:
@@ -634,15 +636,15 @@ class expansion_temp(expansion):
answer = self.decodeHTML("#%s\n%s" % data.groups())
else:
answer = self.AnsBase[1]
- Answer(answer, ltype, source, disp)
+ Answer(answer, stype, source, disp)
- def command_bash(self, ltype, source, body, disp):
+ def command_bash(self, stype, source, body, disp):
if body and isNumber(body):
- Req = Web("http://bash.im/quote/%d" % int(body))
+ Opener = Web("http://bash.im/quote/%d" % int(body))
else:
- Req = Web("http://bash.im/random")
+ Opener = Web("http://bash.im/random")
try:
- data = Req.get_page(self.UserAgent)
+ data = Opener.get_page(self.UserAgent)
except Web.Two.HTTPError, exc:
answer = str(exc)
except:
@@ -655,14 +657,14 @@ class expansion_temp(expansion):
answer = self.decodeHTML("#{1} +[{0}]-\n{2}".format(*data.groups()))
else:
answer = self.AnsBase[1]
- Answer(answer, ltype, source, disp)
+ Answer(answer, stype, source, disp)
else:
- def command_chuck(self, ltype, source, body, disp):
- Req = Web("http://www.chucknorrisfacts.com/all-chuck-norris-facts?page=%d" % randrange(974)) # 04:12 09.11.2012 by UTC number of pages was 974
+ def command_chuck(self, stype, source, body, disp):
+ 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 = Req.get_page(self.UserAgent)
+ data = Opener.get_page(self.UserAgent)
except Web.Two.HTTPError, exc:
answer = str(exc)
except:
@@ -675,15 +677,15 @@ class expansion_temp(expansion):
answer = self.decodeHTML(choice(list))
else:
answer = self.AnsBase[1]
- Answer(answer, ltype, source, disp)
+ Answer(answer, stype, source, disp)
- def command_bash(self, ltype, source, body, disp):
+ def command_bash(self, stype, source, body, disp):
if body and isNumber(body):
- Req = Web("http://bash.org/?%d" % int(body))
+ Opener = Web("http://bash.org/?%d" % int(body))
else:
- Req = Web("http://bash.org/?random")
+ Opener = Web("http://bash.org/?random")
try:
- data = Req.get_page(self.UserAgent)
+ data = Opener.get_page(self.UserAgent)
except Web.Two.HTTPError, exc:
answer = str(exc)
except:
@@ -696,25 +698,25 @@ class expansion_temp(expansion):
answer = self.decodeHTML("#%s +[%s]-\n%s" % data.groups())
else:
answer = self.AnsBase[1]
- Answer(answer, ltype, source, disp)
+ Answer(answer, stype, source, disp)
- def command_currency(self, ltype, source, body, disp):
+ def command_currency(self, stype, source, body, disp):
if body:
ls = body.split()
Code = (ls.pop(0)).lower()
if Code in ("code", "аббревиатура".decode("utf-8")):
if ls:
Code = (ls.pop(0)).upper()
- if self.Currency_desc.has_key(Code):
- answer = self.Currency_desc[Code].decode("utf-8")
+ if Code in self.CurrencyDesc:
+ answer = self.CurrencyDesc[Code].decode("utf-8")
else:
answer = self.AnsBase[1]
else:
answer = AnsBase[2]
elif Code in ("list", "список".decode("utf-8")):
- if ltype == Types[1]:
- Answer(AnsBase[11], ltype, source, disp)
- Curls = ["\->"] + ["%s: %s" % desc for desc in sorted(self.Currency_desc.items())]
+ if stype == Types[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)
elif Code in ("calc", "перевести".decode("utf-8")):
if len(ls) >= 2:
@@ -724,10 +726,10 @@ class expansion_temp(expansion):
Code = (ls.pop(0)).upper()
if (Code == "RUB"):
answer = "%d %s" % (Number, Code)
- elif self.Currency_desc.has_key(Code):
- Req = Web("http://www.cbr.ru/scripts/XML_daily.asp")
+ elif Code in self.CurrencyDesc:
+ Opener = Web("http://www.cbr.ru/scripts/XML_daily.asp")
try:
- data = Req.get_page(self.UserAgent)
+ data = Opener.get_page(self.UserAgent)
except Web.Two.HTTPError, exc:
answer = str(exc)
except:
@@ -756,10 +758,10 @@ class expansion_temp(expansion):
answer = AnsBase[2]
elif (Code != "rub") and Code.isalpha():
Code = Code.upper()
- if self.Currency_desc.has_key(Code):
- Req = Web("http://www.cbr.ru/scripts/XML_daily.asp")
+ if Code in self.CurrencyDesc:
+ Opener = Web("http://www.cbr.ru/scripts/XML_daily.asp")
try:
- data = Req.get_page(self.UserAgent)
+ data = Opener.get_page(self.UserAgent)
except Web.Two.HTTPError, exc:
answer = str(exc)
except:
@@ -778,9 +780,9 @@ class expansion_temp(expansion):
else:
answer = AnsBase[2]
else:
- Req = Web("http://www.cbr.ru/scripts/XML_daily.asp")
+ Opener = Web("http://www.cbr.ru/scripts/XML_daily.asp")
try:
- data = Req.get_page(self.UserAgent)
+ data = Opener.get_page(self.UserAgent)
except Web.Two.HTTPError, exc:
answer = str(exc)
except:
@@ -793,22 +795,22 @@ 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 ltype == Types[1]:
- Answer(AnsBase[11], ltype, source, disp)
+ if stype == Types[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[12]):
- Answer(answer, ltype, source, disp)
+ if locals().has_key(Types[6]):
+ Answer(answer, stype, source, disp)
- def command_jquote(self, ltype, source, body, disp):
+ def command_jquote(self, stype, source, body, disp):
if body and isNumber(body):
- Req = Web("http://jabber-quotes.ru/api/read/?id=%d" % int(body))
+ Opener = Web("http://jabber-quotes.ru/api/read/?id=%d" % int(body))
else:
- Req = Web("http://jabber-quotes.ru/api/read/?id=random")
+ Opener = Web("http://jabber-quotes.ru/api/read/?id=random")
try:
- data = Req.get_page(self.UserAgent)
+ data = Opener.get_page(self.UserAgent)
except Web.Two.HTTPError, exc:
answer = str(exc)
except:
@@ -825,15 +827,15 @@ class expansion_temp(expansion):
answer = answer.replace(lt, lt[:2])
else:
answer = self.AnsBase[1]
- Answer(answer, ltype, source, disp)
+ Answer(answer, stype, source, disp)
- def command_ithappens(self, ltype, source, body, disp):
+ def command_ithappens(self, stype, source, body, disp):
if body and isNumber(body):
- Req = Web("http://ithappens.ru/story/%d" % int(body))
+ Opener = Web("http://ithappens.ru/story/%d" % int(body))
else:
- Req = Web("http://ithappens.ru/random")
+ Opener = Web("http://ithappens.ru/random")
try:
- data = Req.get_page(self.UserAgent)
+ data = Opener.get_page(self.UserAgent)
except Web.Two.HTTPError, exc:
answer = str(exc)
except:
@@ -845,9 +847,9 @@ class expansion_temp(expansion):
answer = self.decodeHTML(sub_desc(data, {"<p class=\"date\">": chr(32)}))
else:
answer = self.AnsBase[1]
- Answer(answer, ltype, source, disp)
+ Answer(answer, stype, source, disp)
- def command_gismeteo(self, ltype, source, body, disp):
+ def command_gismeteo(self, stype, source, body, disp):
if body:
ls = body.split()
Numb = ls.pop(0)
@@ -858,9 +860,9 @@ class expansion_temp(expansion):
City = body
Numb = None
if -1 < Numb < 13 or not Numb:
- Req = Web("http://m.gismeteo.ru/citysearch/by_name/?", [("gis_search", City.encode("utf-8"))])
+ Opener = Web("http://m.gismeteo.ru/citysearch/by_name/?", [("gis_search", City.encode("utf-8"))])
try:
- data = Req.get_page(self.UserAgent)
+ data = Opener.get_page(self.UserAgent)
except Web.Two.HTTPError, exc:
answer = str(exc)
except:
@@ -871,9 +873,9 @@ class expansion_temp(expansion):
if data:
if Numb != None:
data = str.join(chr(47), [data, str(Numb) if Numb != 0 else "weekly"])
- Req = Web("http://m.gismeteo.ru/weather/%s/" % data)
+ Opener = Web("http://m.gismeteo.ru/weather/%s/" % data)
try:
- data = Req.get_page(self.UserAgent)
+ data = Opener.get_page(self.UserAgent)
except Web.Two.HTTPError, exc:
answer = str(exc)
except:
@@ -909,9 +911,9 @@ class expansion_temp(expansion):
answer = AnsBase[2]
else:
answer = AnsBase[1]
- Answer(answer, ltype, source, disp)
+ Answer(answer, stype, source, disp)
- def command_yandex_market(self, ltype, source, body, disp):
+ def command_yandex_market(self, stype, source, body, disp):
if body:
ls = body.split()
c1st = (ls.pop(0)).lower()
@@ -919,9 +921,9 @@ class expansion_temp(expansion):
if ls:
c2nd = ls.pop(0)
if isNumber(c2nd):
- Req = Web("http://m.market.yandex.ru/spec.xml?hid=%d&modelid=%d" % (int(c1st), int(c2nd)))
+ Opener = Web("http://m.market.yandex.ru/spec.xml?hid=%d&modelid=%d" % (int(c1st), int(c2nd)))
try:
- data = Req.get_page(self.UserAgent_Moz)
+ data = Opener.get_page(self.UserAgent_Moz)
except Web.Two.HTTPError, exc:
answer = str(exc)
except:
@@ -938,12 +940,12 @@ class expansion_temp(expansion):
else:
answer = AnsBase[2]
else:
- Req = (body if chr(42) != c1st else body[2:].strip())
- if Req:
- Req = Req.encode("utf-8")
- Req = Web("http://m.market.yandex.ru/search.xml?", [("nopreciser", "1"), ("text", Req)])
+ body = (body if chr(42) != c1st else body[2:].strip())
+ if body:
+ body = body.encode("utf-8")
+ Opener = Web("http://m.market.yandex.ru/search.xml?", [("nopreciser", "1"), ("text", body)])
try:
- data = Req.get_page(self.UserAgent_Moz)
+ data = Opener.get_page(self.UserAgent_Moz)
except Web.Two.HTTPError, exc:
answer = str(exc)
except:
@@ -965,7 +967,7 @@ class expansion_temp(expansion):
answer = AnsBase[2]
else:
answer = AnsBase[1]
- Answer(answer, ltype, source, disp)
+ Answer(answer, stype, source, disp)
commands = (
(command_jc, "jc", 2,),
@@ -988,10 +990,10 @@ class expansion_temp(expansion):
(command_gismeteo, "gismeteo", 2,),
(command_yandex_market, "market", 2,)
))
- Currency_desc = Currency_desc
+ CurrencyDesc = CurrencyDesc
else:
del kinoHeaders, C3oP, command_kino, command_currency, command_jquote, command_ithappens, command_gismeteo
if DefLANG in ("RU", "UA"):
- del Currency_desc
-del UserAgents
+ del CurrencyDesc
+del UserAgents, LangMap
diff --git a/expansions/allweb/insc.py b/expansions/allweb/insc.py
index 15e45ca..dedfd2f 100644
--- a/expansions/allweb/insc.py
+++ b/expansions/allweb/insc.py
@@ -44,7 +44,7 @@ if DefLANG in ("RU", "UA"):
"vi": "Вьетнамский", "yi": "Идиш", "zh-CN": "Китайский"
}
- Currency_desc = {
+ CurrencyDesc = {
"AMD": "Армянский драм",
"AUD": "Австралийский доллар ($)",
"AZN": "Азербайджанский манат",
diff --git a/expansions/apocalypse/code.py b/expansions/apocalypse/code.py
index be946fe..c69f737 100644
--- a/expansions/apocalypse/code.py
+++ b/expansions/apocalypse/code.py
@@ -1,18 +1,16 @@
# coding: utf-8
# BlackSmith mark.2
-exp_name = "apocalypse" # /code.py v.x2
-# Id: 0~2b
+# exp_name = "apocalypse" # /code.py v.x2
+# Id: 0~2c
# Code © (2012) by WitcherGeralt [alkorgun@gmail.com]
-expansion_register(exp_name)
-
class expansion_temp(expansion):
def __init__(self, name):
expansion.__init__(self, name)
- def command_apocalypse(self, ltype, source, body, disp):
+ def command_apocalypse(self, stype, source, body, disp):
Time = time.gmtime()
t1 = (356 - Time.tm_yday)
if not t1:
@@ -23,6 +21,6 @@ class expansion_temp(expansion):
answer = "We must be already dead..."
else:
answer = "There are %d days left to the Apocalypse." % (t1)
- Answer(answer, ltype, source, disp)
+ Answer(answer, stype, source, disp)
commands = ((command_apocalypse, "apocalypse", 1,),)
diff --git a/expansions/basic_control/code.py b/expansions/basic_control/code.py
index 8bffa46..1bea6df 100644
--- a/expansions/basic_control/code.py
+++ b/expansions/basic_control/code.py
@@ -1,18 +1,16 @@
# coding: utf-8
# BlackSmith mark.2
-exp_name = "basic_control" # /code.py v.x10
-# Id: 06~4b
-# Code © (2009-2011) by WitcherGeralt [alkorgun@gmail.com]
-
-expansion_register(exp_name)
+# exp_name = "basic_control" # /code.py v.x11
+# Id: 06~5c
+# Code © (2009-2012) by WitcherGeralt [alkorgun@gmail.com]
class expansion_temp(expansion):
def __init__(self, name):
expansion.__init__(self, name)
- def Chat_check(self, conf):
+ def Check(self, conf):
Numb = itypes.Number()
while Chats.has_key(conf):
if Chats[conf].IamHere != None:
@@ -21,7 +19,7 @@ class expansion_temp(expansion):
if Numb.plus() >= 50:
break
- def command_join(self, ltype, source, body, disp):
+ def command_join(self, stype, source, body, disp):
if body:
ls = body.split()
conf = (ls.pop(0)).lower()
@@ -67,7 +65,7 @@ class expansion_temp(expansion):
Chats[conf] = sConf(conf, disp_, codename, cPref, nick)
Chats[conf].load_all()
Chats[conf].join()
- self.Chat_check(conf)
+ self.Check(conf)
if Chats.has_key(conf) and Chats[conf].IamHere:
Message(conf, self.AnsBase[7] % (ProdName, source[2]), disp_)
answer = self.AnsBase[2] % (conf)
@@ -84,9 +82,9 @@ class expansion_temp(expansion):
answer = self.AnsBase[6] % (conf)
else:
answer = AnsBase[1]
- Answer(answer, ltype, source, disp)
+ Answer(answer, stype, source, disp)
- def command_rejoin(self, ltype, source, body, disp):
+ def command_rejoin(self, stype, source, body, disp):
if body:
conf = body.split()[0].lower()
else:
@@ -105,9 +103,9 @@ class expansion_temp(expansion):
answer = self.AnsBase[14]
else:
answer = AnsBase[8]
- Answer(answer, ltype, source, disp)
+ Answer(answer, stype, source, disp)
- def command_leave(self, ltype, source, body, disp):
+ def command_leave(self, stype, source, body, disp):
if body:
conf = body.split()[0].lower()
else:
@@ -127,16 +125,16 @@ class expansion_temp(expansion):
answer = AnsBase[8]
else:
answer = AnsBase[10]
- if locals().has_key(Types[12]):
- Answer(answer, ltype, source, disp)
+ if locals().has_key(Types[6]):
+ Answer(answer, stype, source, disp)
- def command_reconnect(self, ltype, source, body, disp):
+ def command_reconnect(self, stype, source, body, disp):
if body:
Name = body.split()[0].lower()
else:
Name = get_disp(disp)
if InstansesDesc.has_key(Name):
- ThrName = "%s%s" % (Types[13], Name)
+ ThrName = "%s-%s" % (Types[13], Name)
if Clients.has_key(Name):
ThrIds = iThr.ThrNames()
if ThrName in ThrIds:
@@ -150,27 +148,27 @@ class expansion_temp(expansion):
pass
if connect_client(Name, InstansesDesc[Name])[0]:
try:
- Try_Thr(composeThr(Dispatch_handler, ThrName, (Name,)), -1)
+ Try_Thr(composeThr(DispatchHandler, ThrName, (Name,)), -1)
except RuntimeError:
answer = self.AnsBase[16]
else:
- for conf in Chats.keys():
- if Name == Chats[conf].disp:
- Chats[conf].join()
+ for conf in Chats.itervalues():
+ if Name == conf.disp:
+ conf.join()
answer = AnsBase[4]
else:
answer = AnsBase[7]
else:
answer = self.AnsBase[17] % (Name)
- Answer(answer, ltype, source, disp)
+ Answer(answer, stype, source, disp)
- def command_reload(self, ltype, source, body, disp):
+ def command_reload(self, stype, source, body, disp):
exit_desclr = self.AnsBase[11] % (source[2])
if body not in ("silent", "тихо".decode("utf-8")):
if body:
exit_desclr += self.AnsBase[1] % (body)
- for conf in Chats.keys():
- Message(conf, exit_desclr, Chats[conf].disp)
+ for conf in Chats.itervalues():
+ Message(conf.name, exit_desclr, conf.disp)
sleep(6)
VarCache["alive"] = False
iThr.Threads_kill()
@@ -180,13 +178,13 @@ class expansion_temp(expansion):
call_sfunctions("03si")
Exit("\n\nRestart command...", 0, 15)
- def command_exit(self, ltype, source, body, disp):
+ def command_exit(self, stype, source, body, disp):
exit_desclr = self.AnsBase[11] % (source[2])
if body not in ("silent", "тихо".decode("utf-8")):
if body:
exit_desclr += self.AnsBase[1] % (body)
- for conf in Chats.keys():
- Message(conf, exit_desclr, Chats[conf].disp)
+ for conf in Chats.itervalues():
+ Message(conf.name, exit_desclr, conf.disp)
sleep(6)
VarCache["alive"] = False
iThr.Threads_kill()
diff --git a/expansions/books/code.py b/expansions/books/code.py
index eb778ef..6fdcf09 100644
--- a/expansions/books/code.py
+++ b/expansions/books/code.py
@@ -1,12 +1,10 @@
# coding: utf-8
# BlackSmith mark.2
-exp_name = "books" # /code.py v.x7 beta
-# Id: 29~7b
+# exp_name = "books" # /code.py v.x7 beta
+# Id: 29~7c
# Code © (2011-2012) by WitcherGeralt [alkorgun@gmail.com]
-expansion_register(exp_name)
-
class expansion_temp(expansion):
def __init__(self, name):
@@ -82,7 +80,7 @@ class expansion_temp(expansion):
Name = sub_desc(Name, (chr(32), chr(10), chr(13), chr(9)), chr(95))
return (Name if Name != "books" else None)
- def command_get_books(self, ltype, source, body, disp):
+ def command_get_books(self, stype, source, body, disp):
if body:
list = body.split()
a1 = (list.pop(0)).lower()
@@ -224,7 +222,7 @@ class expansion_temp(expansion):
db("select data from %s where page=?" % (book), (page,))
data = db.fetchone()
if data:
- if ltype == Types[1]:
+ if stype == Types[1]:
answer = AnsBase[11]
Message(source[0], data[0], disp)
if jid:
@@ -254,10 +252,10 @@ class expansion_temp(expansion):
answer = self.AnsBase[8] % len(db_desc)
else:
answer = self.AnsBase[0]
- if locals().has_key(Types[12]):
- Answer(answer, ltype, source, disp)
+ if locals().has_key(Types[6]):
+ Answer(answer, stype, source, disp)
- def command_set_books(self, ltype, source, body, disp):
+ def command_set_books(self, stype, source, body, disp):
if body:
list = body.split()
if len(list) >= 2:
@@ -457,7 +455,7 @@ class expansion_temp(expansion):
answer = AnsBase[2]
else:
answer = AnsBase[1]
- Answer(answer, ltype, source, disp)
+ Answer(answer, stype, source, disp)
def init_books_base(self):
if not os.path.isfile(self.BooksFile):
diff --git a/expansions/bot_sends/code.py b/expansions/bot_sends/code.py
index f691bf9..5936ed8 100644
--- a/expansions/bot_sends/code.py
+++ b/expansions/bot_sends/code.py
@@ -1,22 +1,20 @@
# coding: utf-8
# BlackSmith mark.2
-exp_name = "bot_sends" # /code.py v.x6
-# Id: 18~5b
+# exp_name = "bot_sends" # /code.py v.x6
+# Id: 18~5c
# Code © (2010-2011) by WitcherGeralt [alkorgun@gmail.com]
-expansion_register(exp_name)
-
class expansion_temp(expansion):
def __init__(self, name):
expansion.__init__(self, name)
- def command_clear(self, ltype, source, body, disp):
+ def command_clear(self, stype, source, body, disp):
if Chats.has_key(source[1]):
if ChatsAttrs[source[1]]["dirt"]:
ChatsAttrs[source[1]]["dirt"] = None
- if ltype == Types[1]:
+ if stype == Types[1]:
s1_backup = Chats[source[1]].state
s2_backup = Chats[source[1]].status
Chats[source[1]].change_status(sList[2], self.AnsBase[0])
@@ -27,45 +25,45 @@ class expansion_temp(expansion):
Sender(disp, zero); Info["omsg"].plus()
if (Numb != 23):
sleep(1.4)
- if ltype == Types[1]:
+ if stype == Types[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[12]):
- Answer(answer, ltype, source, disp)
+ if locals().has_key(Types[6]):
+ Answer(answer, stype, source, disp)
- def command_test(self, ltype, source, body, disp):
+ def command_test(self, stype, source, body, disp):
errors = len(VarCache["errors"])
if not errors:
answer = self.AnsBase[1]
elif errors < (len(Clients.keys())*3):
- answer = self.AnsBase[2] % (get_self_nick(source[1]), errors)
+ answer = self.AnsBase[2] % (get_nick(source[1]), errors)
else:
answer = self.AnsBase[3] % (errors)
- Answer(answer, ltype, source, disp)
+ Answer(answer, stype, source, disp)
- def command_sendall(self, ltype, source, body, disp):
+ def command_sendall(self, stype, source, body, disp):
if body:
for conf in Chats.keys():
Message(conf, self.AnsBase[5] % (source[2], body))
answer = AnsBase[4]
else:
answer = AnsBase[1]
- Answer(answer, ltype, source, disp)
+ Answer(answer, stype, source, disp)
- def command_more(self, ltype, source, body, disp):
+ def command_more(self, stype, source, body, disp):
if Chats.has_key(source[1]):
if Chats[source[1]].more:
body = "[&&] %s" % (Chats[source[1]].more)
Chats[source[1]].more = ""
Message(source[1], body, disp)
else:
- Answer(AnsBase[0], ltype, source, disp)
+ Answer(AnsBase[0], stype, source, disp)
- def command_send(self, ltype, source, body, disp):
+ def command_send(self, stype, source, body, disp):
if body:
list = body.split()
if len(list) >= 2:
@@ -83,9 +81,9 @@ class expansion_temp(expansion):
answer = AnsBase[2]
else:
answer = AnsBase[1]
- Answer(answer, ltype, source, disp)
+ Answer(answer, stype, source, disp)
- def command_adelivery(self, ltype, source, body, disp):
+ def command_adelivery(self, stype, source, body, disp):
if body:
if PrivLimit >= len(body):
instance = get_source(source[1], source[2])
@@ -95,38 +93,38 @@ class expansion_temp(expansion):
answer = AnsBase[5]
else:
answer = AnsBase[1]
- Answer(answer, ltype, source, disp)
+ Answer(answer, stype, source, disp)
- def command_say(self, ltype, source, body, disp):
+ def command_say(self, stype, source, body, disp):
if body:
if ConfLimit >= len(body):
Message(source[1], body, disp)
else:
Message(source[1], body[:ConfLimit], disp)
else:
- Answer(AnsBase[1], ltype, source, disp)
+ Answer(AnsBase[1], stype, source, disp)
- def command_invite(self, ltype, source, body, disp):
+ def command_invite(self, stype, source, body, disp):
if Chats.has_key(source[1]):
if body:
timer = (726 if enough_access(source[1], source[2], 7) else (time.time() - ChatsAttrs[source[1]]["intr"]))
if timer >= 720:
- source_, jid_ = None, (body.split()[0])
+ source_, ar = None, body.split()[0]
if Chats[source[1]].isHere(body):
if Chats[source[1]].isHereTS(body):
- Answer(self.AnsBase[6] % (body), ltype, source, disp)
+ Answer(self.AnsBase[6] % (body), stype, source, disp)
raise iThr.ThrKill("exit")
source_ = get_source(source[1], body)
- elif isSource(jid_):
- source_ = jid_.lower()
+ elif isSource(ar):
+ source_ = ar.lower()
if source_:
ChatsAttrs[source[1]]["intr"] = time.time()
invite = xmpp.Message(to = source[1])
- x = xmpp.Node("x")
- x.setNamespace(xmpp.NS_MUC_USER)
- x_child = x.addChild("invite", {"to": source_})
+ node = xmpp.Node("x")
+ node.setNamespace(xmpp.NS_MUC_USER)
+ x_child = node.addChild("invite", {"to": source_})
x_child.setTagData("reason", source[2])
- invite.addChild(node = x)
+ invite.addChild(node = node)
Info["omsg"].plus()
Sender(disp, invite)
answer = AnsBase[4]
@@ -138,7 +136,7 @@ class expansion_temp(expansion):
answer = AnsBase[1]
else:
answer = AnsBase[0]
- Answer(answer, ltype, source, disp)
+ Answer(answer, stype, source, disp)
def init_bot_sender(self, conf):
if not ChatsAttrs.has_key(conf):
diff --git a/expansions/calendar/code.py b/expansions/calendar/code.py
index 75435bb..c47a243 100644
--- a/expansions/calendar/code.py
+++ b/expansions/calendar/code.py
@@ -1,12 +1,10 @@
# coding: utf-8
# BlackSmith mark.2
-exp_name = "calendar" # /code.py v.x3
-# Id: 24~3b
+# exp_name = "calendar" # /code.py v.x3
+# Id: 24~3c
# Code © (2011) by WitcherGeralt [alkorgun@gmail.com]
-expansion_register(exp_name)
-
class expansion_temp(expansion):
def __init__(self, name):
@@ -14,7 +12,7 @@ class expansion_temp(expansion):
import calendar
- def command_calendar(self, ltype, source, body, disp):
+ def command_calendar(self, stype, source, body, disp):
date = time.gmtime()
y, z = 0, 0
if body:
@@ -33,6 +31,6 @@ class expansion_temp(expansion):
clndr = ((self.calendar.month(y, z)).strip()).splitlines()
Ans_2 = clndr.pop(0)
Ans_3 = "\n*\t".join(clndr)
- Answer(Ans_1 % (Ans_2, Ans_3, time.asctime(date)), ltype, source, disp)
+ Answer(Ans_1 % (Ans_2, Ans_3, time.asctime(date)), stype, source, disp)
commands = ((command_calendar, "calendar", 1,),)
diff --git a/expansions/clear_stats/code.py b/expansions/clear_stats/code.py
index cda164a..5d332b2 100644
--- a/expansions/clear_stats/code.py
+++ b/expansions/clear_stats/code.py
@@ -1,12 +1,10 @@
# coding: utf-8
# BlackSmith mark.2
-exp_name = "clear_stats" # /code.py v.x4
-# Id: 12~4b
+# exp_name = "clear_stats" # /code.py v.x4
+# Id: 12~4c
# Code © (2011) by WitcherGeralt [alkorgun@gmail.com]
-expansion_register(exp_name)
-
class expansion_temp(expansion):
def __init__(self, name):
diff --git a/expansions/cmd_control/code.py b/expansions/cmd_control/code.py
index 834a593..a90503f 100644
--- a/expansions/cmd_control/code.py
+++ b/expansions/cmd_control/code.py
@@ -1,12 +1,10 @@
# coding: utf-8
# BlackSmith mark.2
-exp_name = "cmd_control" # /code.py v.x1
-# Id: 32~1b
+# exp_name = "cmd_control" # /code.py v.x1
+# Id: 32~1c
# Code © (2012) by WitcherGeralt [alkorgun@gmail.com]
-expansion_register(exp_name)
-
class expansion_temp(expansion):
def __init__(self, name):
@@ -14,7 +12,7 @@ class expansion_temp(expansion):
TabooFile = "taboo.db"
- def command_taboo(self, ltype, source, body, disp):
+ def command_taboo(self, stype, source, body, disp):
if Chats.has_key(source[1]):
oCmds = Chats[source[1]].oCmds
if body:
@@ -45,7 +43,7 @@ class expansion_temp(expansion):
answer = self.AnsBase[3]
else:
answer = AnsBase[0]
- Answer(answer, ltype, source, disp)
+ Answer(answer, stype, source, disp)
def init_taboo(self, conf):
filename = chat_file(conf, self.TabooFile)
diff --git a/expansions/config/client.en b/expansions/config/client.en
index d87727f..97d4358 100644
--- a/expansions/config/client.en
+++ b/expansions/config/client.en
@@ -1,5 +1,5 @@
clients control system
-client ([del] [jid])/([add] [host] [accout] [password] (port) (server))/([password] [jid] [text])
+client ([del] [jid])/([add] [host] [accout] [password] (port) (server))/([password] [jid] (text))
*/client
bot would show current config
*/client del bs@xmpp.ru
@@ -7,4 +7,4 @@ bot would disable client with jid bs@xmpp.ru, and when will rejoin rooms behind
*/client add xmpp.ru bs xxx 5222 jabber.ru
bot would start client with jid bs@xmpp.ru (if host=server, server specify is optional, such as a port if it=5222)
*/client password bs@xmpp.ru xxx
-bot would change jid's password (password specify is optional, bot can generate it. with parameter "set" after password, bot will set it, even if it cann't be changed) \ No newline at end of file
+bot would change jid's password (password specify is optional, bot can generate it. with parameter "set" after password, bot will just write it) \ No newline at end of file
diff --git a/expansions/config/client.ru b/expansions/config/client.ru
index 05dbdad..c0c32da 100644
--- a/expansions/config/client.ru
+++ b/expansions/config/client.ru
@@ -1,5 +1,5 @@
система управления клиентами
-клиент ([удалить] [jid])/([добавить] [host] [аккаунт] [пароль] (порт) (сервер))/([пароль] [jid] [текст])
+клиент ([удалить] [jid])/([добавить] [host] [аккаунт] [пароль] (порт) (сервер))/([пароль] [jid] (текст))
*/клиент
бот покажет текущие настройки
*/клиент удалить bs@xmpp.ru
@@ -7,4 +7,4 @@
*/клиент добавить xmpp.ru bs xxx 5222 jabber.ru
запустит клиент с jid'ом bs@xmpp.ru (если хост равен серверу, его указывать необязательно, как и порт, если он равен 5222)
*/клиент пароль bs@xmpp.ru xxx
-бот сменит пароль к jid'у (если не указать пароль бот сгеренирует его автоматически. при параметре "записать" после пароля, бот его запишет, даже если его не удастся сменить) \ No newline at end of file
+бот сменит пароль к jid'у (если не указать пароль бот сгеренирует его автоматически. при параметре "записать" после пароля, бот просто его запишет) \ No newline at end of file
diff --git a/expansions/config/code.py b/expansions/config/code.py
index 822042e..55f6445 100644
--- a/expansions/config/code.py
+++ b/expansions/config/code.py
@@ -1,25 +1,28 @@
# coding: utf-8
# BlackSmith mark.2
-exp_name = "config" # /code.py v.x4
-# Id: 19~3b
-# Code © (2011) by WitcherGeralt [alkorgun@gmail.com]
-
-expansion_register(exp_name)
+# exp_name = "config" # /code.py v.x5
+# Id: 19~4c
+# Code © (2011-2012) by WitcherGeralt [alkorgun@gmail.com]
class expansion_temp(expansion):
def __init__(self, name):
expansion.__init__(self, name)
- def get_config(self, config, ecfg = str()):
+ def get_config(self, config):
+ cfg = []
for s in config.sections():
- ecfg += "[%s]\n" % (s.upper())
+ cfg.append("[%s]" % (s.upper()))
for (op, i) in config.items(s):
- ecfg += "%s = %s\n" % (op.upper(), str(i))
- return ecfg.strip()
+ cfg.append("%s = %s" % (op.upper(), str(i)))
+ return "\r\n".join(cfg)
+
+ ops = ("memory", "incoming", "chat", "private", "tls", "mserve", "getexc", "status", "resource")
- def command_config(self, ltype, source, body, disp):
+ opsGeq = ("MaxMemory", "IncLimit", "ConfLimit", "PrivLimit", "ConTls", "Mserve", "GetExc", "DefStatus", "GenResource")
+
+ def command_config(self, stype, source, body, disp):
if body:
ConfigDesc = {}
for x in body.split():
@@ -31,39 +34,42 @@ class expansion_temp(expansion):
Name = Name.lower()
for Title in GenCon.sections():
if Name in GenCon.options(Title):
- if Name in ("chat", "incoming", "memory", "private", "port"):
- if isNumber(data):
- data = str(int(data))
- else:
+ if Name in self.ops[:4]:
+ if not isNumber(data):
continue
- elif Name in ("tls", "getexc", "mserve"):
- if data not in (str(True), str(False)):
+ elif Name in self.ops[4:-2]:
+ if data not in ("True", "False"):
continue
- elif Name in ("status", "resource"):
+ elif Name in self.ops[-2:]:
data = sub_desc(data, {chr(95): chr(32)})
if not ConfigDesc.has_key(Title):
- ConfigDesc[Title] = dict()
+ ConfigDesc[Title] = {}
ConfigDesc[Title][Name] = data
if ConfigDesc:
for Title in ConfigDesc.keys():
for (Name, data) in ConfigDesc[Title].items():
GenCon.set(Title, Name, data)
+ if Name not in self.ops[-2:]:
+ data = eval(data)
+ if Name == self.ops[0]:
+ data *= 1024
+ data = (32768 if (data and data <= 32768) else data)
+ globals()[self.opsGeq[self.ops.index(Name)]] = data
cat_file(GenConFile, self.get_config(GenCon))
- list = []
+ ls = []
for Name in ConfigDesc.values():
- list.extend(Name.keys())
- list = [Name.upper() for Name in list]
- answer = self.AnsBase[0] % (", ".join(list))
+ ls.extend(Name.keys())
+ answer = self.AnsBase[0] % (", ".join([Name.upper() for Name in ls]))
else:
answer = self.AnsBase[1]
else:
- if ltype == Types[1]:
- Answer(AnsBase[11], ltype, source, disp)
- Message(source[0], self.get_config(GenCon, self.AnsBase[2]), disp)
- if locals().has_key(Types[12]):
- Answer(answer, ltype, source, disp)
+ Message(source[0], self.AnsBase[2] + self.get_config(GenCon), disp)
+ if stype == Types[1]:
+ answer = AnsBase[11]
+ if locals().has_key(Types[6]):
+ Answer(answer, stype, source, disp)
- def command_cls_config(self, ltype, source, body, disp):
+ def command_cls_config(self, stype, source, body, disp):
if body:
list = body.split()
if len(list) >= 2:
@@ -73,11 +79,11 @@ class expansion_temp(expansion):
if InstansesDesc.has_key(Name):
clients = Clients.keys()
if not Clients.has_key(Name) or len(clients) >= 2:
- if Name == Gen_disp:
- clients.remove(Gen_disp)
+ if Name == GenDisp:
+ clients.remove(GenDisp)
Gen = choice(clients)
delivery(self.AnsBase[6] % Gen)
- globals()["Gen_disp"], Con = Gen, client_config(GenCon, "CLIENT")[1]
+ globals()["GenDisp"], Con = Gen, client_config(GenCon, "CLIENT")[1]
for x in ConDisp.sections():
z = client_config(ConDisp, x)
if Gen == z[0]:
@@ -94,21 +100,21 @@ class expansion_temp(expansion):
ConDisp.remove_section(x)
if Clients.has_key(Name):
ThrIds = iThr.ThrNames()
- ThrName = "%s%s" % (Types[13], Name)
+ ThrName = "%s-%s" % (Types[13], Name)
if ThrName in ThrIds:
for Thr in iThr.enumerate():
if Thr._Thread__name == ThrName:
Thr.kill()
- for conf in Chats.keys():
- if Chats[conf].disp == Name:
+ for conf in Chats.itervalues():
+ if conf.disp == Name:
if online(Name):
- Message(conf, self.AnsBase[4], Name)
+ Message(conf.name, self.AnsBase[4], Name)
sleep(0.2)
- Chats[conf].leave(self.AnsBase[5])
- Chats[conf].disp = IdleClient()
- Chats[conf].save()
+ conf.leave(self.AnsBase[5])
+ conf.disp = IdleClient()
+ conf.save()
sleep(0.6)
- Chats[conf].join()
+ conf.join()
if online(Name):
try:
Clients[Name].disconnect()
@@ -160,13 +166,13 @@ class expansion_temp(expansion):
InstansesDesc[Instance] = desc
cat_file(ConDispFile, self.get_config(ConDisp))
try:
- Try_Thr(composeThr(Dispatch_handler, "%s%s" % (Types[13], Instance), (Instance,)), -1)
+ Try_Thr(composeThr(DispatchHandler, "%s-%s" % (Types[13], Instance), (Instance,)), -1)
except RuntimeError:
answer = self.AnsBase[8]
else:
- for conf in Chats.keys():
- if Instance == Chats[conf].disp:
- Chats[conf].join()
+ for conf in Chats.itervalues():
+ if Instance == conf.disp:
+ conf.join()
answer = AnsBase[4]
else:
answer = self.AnsBase[9]
@@ -185,35 +191,18 @@ class expansion_temp(expansion):
if (list.pop(0)).lower() in ("set", "записать".decode("utf-8")):
changed = True
else:
- code, symbols = "", "%s%s%s._+(!}{#)" % (CharCase[0], CharCase[1], CharCase[2])
+ code, symbols = "", "%s.%s_%s+(!}{#)" % (CharCase[0], CharCase[1], CharCase[2])
for x in xrange(24):
code += choice(symbols)
- if not locals().has_key("changed"):
- if Clients.has_key(Name):
- try:
- changed = xmpp.features.changePasswordTo(Clients[Name], code)
- except:
- changed = False
- else:
- changed = False
- if changed:
- if Name == Gen_disp:
- GenCon.set("CLIENT", "pass", code)
- cat_file(GenConFile, self.get_config(GenCon))
- else:
- for x in ConDisp.sections():
- if Name == client_config(ConDisp, x)[0]:
- ConDisp.set(x, "pass", code)
- cat_file(ConDispFile, self.get_config(ConDisp))
- break
- serv = InstansesDesc[Name][0]
- port = InstansesDesc[Name][1]
- host = InstansesDesc[Name][2]
- user = InstansesDesc[Name][3]
- InstansesDesc[Name] = (serv, port, host, user, code)
- answer = AnsBase[4]
+ if locals().has_key("changed"):
+ self.answer_register(self, disp, xmpp.Iq(typ = Types[8]), stype, source, code)
+ elif online(Name):
+ Disp = Clients[Name]
+ iq = xmpp.Iq(Types[9] , xmpp.NS_REGISTER, to = Disp.Server, payload = [xmpp.Node("username", payload = [Disp.User]), xmpp.Node("password", payload = [code])])
+ Info["outiq"].plus()
+ CallForResponse(Disp, iq, self.answer_register, {"stype": stype, "source": source, "code": code})
else:
- answer = AnsBase[7]
+ answer = self.AnsBase[12]
else:
answer = self.AnsBase[11]
else:
@@ -223,11 +212,33 @@ class expansion_temp(expansion):
elif not len(ConDisp.sections()):
answer = self.AnsBase[3]
else:
- if ltype == Types[1]:
- Answer(AnsBase[11], ltype, source, disp)
- Message(source[0], self.get_config(ConDisp, self.AnsBase[2]), disp)
- if locals().has_key(Types[12]):
- Answer(answer, ltype, source)
+ Message(source[0], self.AnsBase[2] + self.get_config(ConDisp), disp)
+ if stype == Types[1]:
+ answer = AnsBase[11]
+ if locals().has_key(Types[6]):
+ Answer(answer, stype, source)
+
+ def answer_register(self, disp, stanza, stype, source, code):
+ if xmpp.isResultNode(stanza):
+ Name = get_disp(disp)
+ if Name == GenDisp:
+ GenCon.set("CLIENT", "pass", code)
+ cat_file(GenConFile, self.get_config(GenCon))
+ else:
+ for x in ConDisp.sections():
+ if Name == client_config(ConDisp, x)[0]:
+ ConDisp.set(x, "pass", code)
+ cat_file(ConDispFile, self.get_config(ConDisp))
+ break
+ serv = InstansesDesc[Name][0]
+ port = InstansesDesc[Name][1]
+ host = InstansesDesc[Name][2]
+ user = InstansesDesc[Name][3]
+ InstansesDesc[Name] = (serv, port, host, user, code)
+ answer = AnsBase[4]
+ else:
+ answer = AnsBase[7]
+ Answer(answer, stype, source, disp)
commands = (
(command_config, "config", 8,),
diff --git a/expansions/config/insc.py b/expansions/config/insc.py
index 6cd2a38..3b79a7a 100644
--- a/expansions/config/insc.py
+++ b/expansions/config/insc.py
@@ -13,7 +13,8 @@ if DefLANG in ("RU", "UA"):
"Система не может выделить ресурсы на ещё один клиент.", # 8
"Не коннектится.", # 9
"Этот jid уже есть в списках.", # 10
- "«%s» нет в списке клиентов." # 11
+ "«%s» нет в списке клиентов.", # 11
+ "«%s» сейчас оффлайн." # 12
)])
else:
AnsBase_temp = (
@@ -28,5 +29,6 @@ else:
"The system can not allocate resources to another client.", # 8
"No connection.", # 9
"This jid is already in list.", # 10
- "'%s' not in clients-list." # 11
+ "'%s' not in clients-list.", # 11
+ "'%s' is offline." # 12
) \ No newline at end of file
diff --git a/expansions/converter/code.py b/expansions/converter/code.py
index d542d3b..e3355cc 100644
--- a/expansions/converter/code.py
+++ b/expansions/converter/code.py
@@ -1,12 +1,10 @@
# coding: utf-8
# BlackSmith mark.2
-exp_name = "converter" # /code.py v.x4
-# Id: 31~3b
+# exp_name = "converter" # /code.py v.x4
+# Id: 31~3c
# Code © (2012) by WitcherGeralt [alkorgun@gmail.com]
-expansion_register(exp_name)
-
class expansion_temp(expansion):
def __init__(self, name):
@@ -193,7 +191,7 @@ class expansion_temp(expansion):
Convert = lambda self, Desc, Numb, Type, ToType: (self.CrDesc[Desc][ToType]*(Numb / self.CrDesc[Desc][Type]))
- def command_convert(self, ltype, source, body, disp):
+ def command_convert(self, stype, source, body, disp):
if body:
ls = body.split()
Desc = (ls.pop(0)).lower()
@@ -237,6 +235,6 @@ class expansion_temp(expansion):
answer = self.AnsBase[2]
else:
answer = ", ".join(sorted(self.CrDesc.keys()))
- Answer(answer, ltype, source, disp)
+ Answer(answer, stype, source, disp)
commands = ((command_convert, "convert", 2,),)
diff --git a/expansions/cron/code.py b/expansions/cron/code.py
index e9e618e..a33ddf0 100644
--- a/expansions/cron/code.py
+++ b/expansions/cron/code.py
@@ -1,12 +1,10 @@
# coding: utf-8
# BlackSmith mark.2
-exp_name = "cron" # /code.py v.x4
-# Id: 27~3a
+# exp_name = "cron" # /code.py v.x4
+# Id: 27~3c
# Code © (2010-2011) by WitcherGeralt [alkorgun@gmail.com]
-expansion_register(exp_name)
-
class expansion_temp(expansion):
def __init__(self, name):
@@ -62,7 +60,7 @@ class expansion_temp(expansion):
ls[0] += 1
return time.strftime(sftime, time.struct_time(ls))
- def add_cron(self, disp, ls, body, Te, source, ltype, gt, answer, repeat, **etc):
+ def add_cron(self, disp, ls, body, Te, source, stype, gt, answer, repeat, **etc):
cmd = (ls.pop(0)).lower()
if Cmds.has_key(cmd):
if enough_access(source[1], source[2], Cmds[cmd].access):
@@ -73,7 +71,7 @@ class expansion_temp(expansion):
if 1024 >= len(body):
Time = time.mktime(gt)
instance = get_source(source[1], source[2])
- self.CronDesc[self.CronCounter.plus()] = ((Te + Time), (cmd, instance, (ltype, source, body, get_disp(disp)), repeat))
+ self.CronDesc[self.CronCounter.plus()] = ((Te + Time), (cmd, instance, (stype, source, body, get_disp(disp)), repeat))
self.cdesc_save()
else:
answer = AnsBase[5]
@@ -83,7 +81,7 @@ class expansion_temp(expansion):
answer = AnsBase[6]
return answer
- def command_cron(self, ltype, source, body, disp):
+ def command_cron(self, stype, source, body, disp):
gt = time.gmtime()
if body:
ls = body.split()
@@ -166,7 +164,7 @@ class expansion_temp(expansion):
date[0] = int(Date.pop(0))
except:
answer = AnsBase[2]
- if not locals().has_key(Types[12]):
+ if not locals().has_key(Types[6]):
try:
date = time.struct_time(date)
except:
@@ -215,7 +213,7 @@ class expansion_temp(expansion):
line = "%d (%s) [%s]" % (id, desc[0], self.getDate(list(gt), int(date - Te)))
ls.append(line)
answer = self.AnsBase[8] % enumerated_list(sorted(ls))
- Answer(answer, ltype, source, disp)
+ Answer(answer, stype, source, disp)
def start_cron(self):
Name = self.def_cron.func_name
@@ -246,10 +244,10 @@ class expansion_temp(expansion):
if len(repeat) == 2:
seconds, repeats = repeat
repeat = (seconds, int(repeats))
- ltype, source, body, disp = ls__
+ stype, source, body, disp = ls__
one, two, three = source
source = (str(one), two, three)
- ls__ = (ltype, source, body, disp)
+ ls__ = (stype, source, body, disp)
ls = (command, instance, ls__, repeat)
cdesc[id] = (date, ls)
cat_file(self.CronFile, str((cdesc, int(self.CronCounter))))
diff --git a/expansions/exp_control/code.py b/expansions/exp_control/code.py
index 7c24c05..d1870c4 100644
--- a/expansions/exp_control/code.py
+++ b/expansions/exp_control/code.py
@@ -1,19 +1,17 @@
# coding: utf-8
# BlackSmith mark.2
-exp_name = "exp_control" # /code.py v.x8
-# Id: 09~8b
+# exp_name = "exp_control" # /code.py v.x9
+# Id: 09~9c
# Code © (2011-2012) by WitcherGeralt [alkorgun@gmail.com]
-expansion_register(exp_name)
-
class expansion_temp(expansion):
def __init__(self, name):
expansion.__init__(self, name)
- def command_expinfo(self, ltype, source, body, disp):
- get_state = lambda filename: (self.AnsBase[1] if os.path.isfile(filename) else self.AnsBase[2])
+ def command_expinfo(self, stype, source, body, disp):
+ get_state = lambda filename: (self.AnsBase[1] if filename and os.path.isfile(filename) else self.AnsBase[2])
if body:
exp_name = body.lower()
if check_nosimbols(exp_name):
@@ -45,7 +43,7 @@ class expansion_temp(expansion):
answer += "\n%d) %s - %s - %s" % (Number.plus(), exp_name, code_file, insc_file)
elexps = []
for exp_name in sorted(os.listdir(ExpsDir)):
- if (".svn") == (exp_name) or expansions.has_key(exp_name):
+ if (".svn" == exp_name) or expansions.has_key(exp_name):
continue
if os.path.isdir(os.path.join(ExpsDir, exp_name)):
exp = expansion(exp_name)
@@ -55,54 +53,48 @@ class expansion_temp(expansion):
elexps_len = len(elexps)
if elexps_len:
answer += self.AnsBase[9] % (elexps_len, chr(10).join(elexps))
- Answer(answer, ltype, source, disp)
+ Answer(answer, stype, source, disp)
ReloadSemaphore = iThr.Semaphore()
- def command_expload(self, ltype, source, body, disp):
+ def command_expload(self, stype, source, body, disp):
if body:
exp_name = body.strip("\\/").lower()
if check_nosimbols(exp_name):
- if expansions.has_key(exp_name):
- if os.path.isfile(expansions[exp_name].file):
- with self.ReloadSemaphore:
- rslt = expansions[exp_name].load()
- if rslt[1]:
- exp = expansion_temp(exp_name)
+ exp = expansion(exp_name)
+ if exp.isExp:
+ backup = expansions.get(exp_name)
+ with self.ReloadSemaphore:
+ exp, exc = exp.load()
+ if exp:
+ try:
exp.initialize_exp()
- exp.initialize_all()
- answer = self.AnsBase[10] % (rslt[0])
+ except:
+ exc = exc_info()
+ exp.dels(True)
+ answer = self.AnsBase[11] % (exp_name, "\n\t* %s: %s" % exc)
+ if backup:
+ backup.initialize_exp()
+ backup.initialize_all()
+ answer += self.AnsBase[13]
else:
- expansions[exp_name].dels(True)
- answer = self.AnsBase[11] % (rslt[0], "\n\t* %s: %s") % (rslt[2])
- else:
- answer = self.AnsBase[12]
- else:
- expansions[exp_name] = exp = expansion(exp_name)
- if exp.isExp:
- with self.ReloadSemaphore:
- rslt = exp.load()
- if rslt[1] and expansions.has_key(exp_name):
- exp = expansion_temp(exp_name)
- exp.initialize_exp()
exp.initialize_all()
- answer = self.AnsBase[10] % (rslt[0])
- else:
- exp.dels(True)
- if rslt[2]:
- answer = self.AnsBase[11] % (rslt[0], "\n\t* %s: %s") % (rslt[2])
- else:
- answer = self.AnsBase[13] % (rslt[0])
- else:
- exp.dels(True)
- answer = self.AnsBase[7]
+ answer = self.AnsBase[10] % (exp_name)
+ else:
+ answer = self.AnsBase[11] % (exp_name, "\n\t* %s: %s" % exc)
+ if backup:
+ backup.initialize_exp()
+ backup.initialize_all()
+ answer += self.AnsBase[13]
+ else:
+ answer = self.AnsBase[7]
else:
answer = self.AnsBase[7]
else:
answer = AnsBase[1]
- Answer(answer, ltype, source, disp)
+ Answer(answer, stype, source, disp)
- def command_expunload(self, ltype, source, body, disp):
+ def command_expunload(self, stype, source, body, disp):
if body:
body = body.split()
exp_name = (body.pop(0)).lower()
@@ -133,29 +125,29 @@ class expansion_temp(expansion):
answer = self.AnsBase[7]
else:
answer = AnsBase[1]
- Answer(answer, ltype, source, disp)
+ Answer(answer, stype, source, disp)
- def command_tumbler(self, ltype, source, body, disp):
+ def command_tumbler(self, stype, source, body, disp):
if body:
ls = body.split()
command = (ls.pop(0)).lower()
if Cmds.has_key(command):
- obj = Cmds.get(command)
+ cmd = Cmds.get(command)
if ls:
body = (ls.pop(0)).lower()
if body in ("on", "вкл".decode("utf-8")):
- if not obj.isAvalable:
- if obj.handler:
- obj.isAvalable = True
+ if not cmd.isAvalable:
+ if cmd.handler:
+ cmd.isAvalable = True
answer = AnsBase[4]
else:
answer = AnsBase[19] % (command)
else:
answer = self.AnsBase[16] % (command)
elif body in ("off", "выкл".decode("utf-8")):
- if obj.isAvalable:
- if obj.handler:
- obj.isAvalable = False
+ if cmd.isAvalable:
+ if cmd.handler:
+ cmd.isAvalable = False
answer = AnsBase[4]
else:
answer = AnsBase[19] % (command)
@@ -164,16 +156,16 @@ class expansion_temp(expansion):
else:
answer = AnsBase[2]
else:
- answer = self.AnsBase[16 if obj.isAvalable else 17] % (command)
+ answer = self.AnsBase[16 if cmd.isAvalable else 17] % (command)
else:
answer = AnsBase[6]
else:
- oCmds = [cmd for cmd, obj in Cmds.iteritems() if not obj.isAvalable]
+ oCmds = [cmd_str for cmd_str, cmd in Cmds.iteritems() if not cmd.isAvalable]
if oCmds:
answer = ", ".join(oCmds)
else:
answer = self.AnsBase[18]
- Answer(answer, ltype, source, disp)
+ Answer(answer, stype, source, disp)
commands = (
(command_expinfo, "expinfo", 7,),
diff --git a/expansions/exp_control/insc.py b/expansions/exp_control/insc.py
index b5eac4e..4ded8a2 100644
--- a/expansions/exp_control/insc.py
+++ b/expansions/exp_control/insc.py
@@ -15,7 +15,7 @@ if DefLANG in ("RU", "UA"):
"%s - успешно загружен!", # 10
"Не могу загрузить - %s!%s", # 11
"Какой-то гад удалил файл с кодом!", # 12
- "%s написан некорректно. Загрузка отменена.", # 13
+ "\n\n** Загрузил последнюю рабочую версию плагина.", # 13
"Этой функции нет в списке зарегистрированных.\n## Список зареганных: %s", # 14
"В %s нет зарегистрированных функций.", # 15
"Команда «%s» включена.", # 16
@@ -32,13 +32,13 @@ else:
"\nHandlers: %s", # 5
"not loaded", # 6
"Also, this expansion isn't exist.", # 7
- "\n[#][Name][codefile][langfile]", # 8
+ "\n[#][Name][code-file][lang-file]", # 8
"\n\n## Not loaded (%d) ->\n\n%s", # 9
"%s - successfully loaded!", # 10
"Can't load - %s!%s", # 11
"Somebody deleted code-file!", # 12
- "%s was coded incorrectly. Loading aborted.", # 13
- "This func. isn't registered.\n## Function list: %s", # 14
+ "\n\n** The last valid version of the expansion was loaded.", # 13
+ "This function isn't registered.\n## Functions-list: %s", # 14
"There is no registered functions in %s", # 15
"Command '%s' is on.", # 16
"Command '%s' is off.", # 17
diff --git a/expansions/exp_control/unload.en b/expansions/exp_control/unload.en
deleted file mode 100644
index 8c3a7b4..0000000
--- a/expansions/exp_control/unload.en
+++ /dev/null
@@ -1,6 +0,0 @@
-expansions and functions unloader
-unload [expansion] (function)
-*/unload talkers
-bot would unload expansion "talkers"
-*/unload talkers calculate_talkers
-bot would unload talkers calculator (unloader should use only uers with experience) \ No newline at end of file
diff --git a/expansions/exp_control/unload.ru b/expansions/exp_control/unload.ru
deleted file mode 100644
index 5d22bfb..0000000
--- a/expansions/exp_control/unload.ru
+++ /dev/null
@@ -1,6 +0,0 @@
-выгрузка плагинов и функций
-выгрузи [плагин] (функция)
-*/выгрузи talkers
-бот выгрузит плагин "talkers"
-*/выгрузи talkers calculate_talkers
-бот выгрузит функцию подсчёта болтунов (выгрузку функций следует использовать только профи) \ No newline at end of file
diff --git a/expansions/extra_control/code.py b/expansions/extra_control/code.py
index 7df496b..fa281e1 100644
--- a/expansions/extra_control/code.py
+++ b/expansions/extra_control/code.py
@@ -1,12 +1,10 @@
# coding: utf-8
# BlackSmith mark.2
-exp_name = "extra_control" # /code.py v.x8
-# Id: 01~6b
+# exp_name = "extra_control" # /code.py v.x9
+# Id: 01~7c
# Code © (2009-2012) by WitcherGeralt [alkorgun@gmail.com]
-expansion_register(exp_name)
-
class expansion_temp(expansion):
def __init__(self, name):
@@ -14,13 +12,14 @@ class expansion_temp(expansion):
sep = chr(38)*2
- def command_turbo(self, ltype, source, body, disp):
+ def command_turbo(self, stype, source, body, disp):
if body:
if self.sep in body:
ls = body.split(self.sep)
lslen = len(ls) - 1
if lslen < 4 or enough_access(source[1], source[2], 7):
for numb, body in enumerate(ls):
+ body = body.strip()
body = body.split(None, 1)
cmd = (body.pop(0)).lower()
if Cmds.has_key(cmd):
@@ -28,7 +27,7 @@ class expansion_temp(expansion):
body = body[0]
else:
body = ""
- Cmds[cmd].execute(ltype, source, body, disp)
+ Cmds[cmd].execute(stype, source, body, disp)
if numb not in (0, lslen):
sleep(2)
else:
@@ -39,10 +38,10 @@ class expansion_temp(expansion):
answer = AnsBase[2]
else:
answer = AnsBase[1]
- if locals().has_key(Types[12]):
- Answer(answer, ltype, source, disp)
+ if locals().has_key(Types[6]):
+ Answer(answer, stype, source, disp)
- def command_remote(self, ltype, source, body, disp):
+ def command_remote(self, stype, source, body, disp):
confs = sorted(Chats.keys())
if body:
body = body.split(None, 3)
@@ -60,9 +59,9 @@ class expansion_temp(expansion):
conf = False
if conf:
itype = (body.pop(0)).lower()
- if itype in (Types[14], Types[0]):
+ if itype in ("chat", "чат".decode("utf-8")):
type2 = Types[1]
- elif itype in (Types[15], Types[6]):
+ elif itype in ("private", "приват".decode("utf-8")):
type2 = Types[0]
else:
type2 = False
@@ -100,10 +99,10 @@ class expansion_temp(expansion):
answer = AnsBase[2]
else:
answer = enumerated_list(confs)
- if locals().has_key(Types[12]):
- Answer(answer, ltype, source, disp)
+ if locals().has_key(Types[6]):
+ Answer(answer, stype, source, disp)
- def command_private(self, ltype, source, body, disp):
+ def command_private(self, stype, source, body, disp):
if Chats.has_key(source[1]):
if body:
body = body.split(None, 1)
@@ -120,8 +119,8 @@ class expansion_temp(expansion):
answer = AnsBase[1]
else:
answer = AnsBase[0]
- if locals().has_key(Types[12]):
- Answer(answer, ltype, source, disp)
+ if locals().has_key(Types[6]):
+ Answer(answer, stype, source, disp)
commands = (
(command_turbo, "turbo", 1,),
diff --git a/expansions/game/code.py b/expansions/game/code.py
index fc769d4..4949ec3 100644
--- a/expansions/game/code.py
+++ b/expansions/game/code.py
@@ -1,12 +1,10 @@
# coding: utf-8
# BlackSmith mark.2
-exp_name = "game" # /code.py v.x2
-# Id: 26~2b
+# exp_name = "game" # /code.py v.x2
+# Id: 26~2c
# Code © (2011) by WitcherGeralt [alkorgun@gmail.com]
-expansion_register(exp_name)
-
class expansion_temp(expansion):
def __init__(self, name):
@@ -37,12 +35,12 @@ class expansion_temp(expansion):
GameRules = GameRules
- def command_game(self, ltype, source, Char, disp):
+ def command_game(self, stype, source, Char, disp):
if Char:
Char = Char.lower()
- if self.GameDesc.has_key(Char):
+ if Char in self.GameDesc:
Char_2 = choice(self.GameDesc.keys())
- Answer(Char_2, ltype, source, disp)
+ Answer(Char_2, stype, source, disp)
sleep(3.2)
if Char == Char_2:
answer = self.AnsBase[0]
@@ -54,7 +52,7 @@ class expansion_temp(expansion):
answer = AnsBase[2]
else:
answer = str.join(chr(10), self.GameRules)
- Answer(answer, ltype, source, disp)
+ Answer(answer, stype, source, disp)
commands = ((command_game, "game", 2,),)
diff --git a/expansions/get_iq/code.py b/expansions/get_iq/code.py
index 87e0d2f..f154533 100644
--- a/expansions/get_iq/code.py
+++ b/expansions/get_iq/code.py
@@ -1,18 +1,16 @@
# coding: utf-8
# BlackSmith mark.2
-exp_name = "get_iq" # /code.py v.x6
-# Id: 13~5b
-# Code © (2010-2011) by WitcherGeralt [alkorgun@gmail.com]
-
-expansion_register(exp_name)
+# exp_name = "get_iq" # /code.py v.x6
+# Id: 13~5c
+# Code © (2010-2012) by WitcherGeralt [alkorgun@gmail.com]
class expansion_temp(expansion):
def __init__(self, name):
expansion.__init__(self, name)
- def command_ping(self, ltype, source, instance, disp):
+ def command_ping(self, stype, source, instance, disp):
if instance:
source_ = instance
if Chats.has_key(source[1]) and Chats[source[1]].isHere(instance):
@@ -20,32 +18,32 @@ 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), ltype, source, disp)
+ Answer(self.AnsBase[5] % (instance), stype, source, disp)
raise iThr.ThrKill("exit")
else:
instance, source_ = source[0], get_source(source[1], source[2])
iq = xmpp.Iq(to = instance, typ = Types[10])
- iq.addChild(Types[16], {}, [], xmpp.NS_PING)
+ iq.addChild(Types[16], namespace = xmpp.NS_PING)
iq.setID("Bs-i%d" % Info["outiq"].plus())
- CallForResponse(disp, iq, self.answer_ping, {"ltype": ltype, "source": source, "instance": instance, "source_": source_, "start": time.time()})
+ CallForResponse(disp, iq, self.answer_ping, {"stype": stype, "source": source, "instance": instance, "source_": source_, "start": time.time()})
PingStats = {}
- def answer_ping(self, disp, stanza, ltype, source, instance, source_, start):
+ def answer_ping(self, disp, stanza, stype, source, instance, source_, start):
if xmpp.isResultNode(stanza):
answer = round(time.time() - start, 3)
if source_:
if not self.PingStats.has_key(source_):
self.PingStats[source_] = []
self.PingStats[source_].append(answer)
- Answer(self.AnsBase[0] % str(answer), ltype, source, disp)
+ Answer(self.AnsBase[0] % str(answer), stype, source, disp)
else:
iq = xmpp.Iq(to = instance, typ = Types[10])
- iq.addChild(Types[18], {}, [], xmpp.NS_VERSION)
+ iq.addChild(Types[18], namespace = xmpp.NS_VERSION)
iq.setID("Bs-i%d" % Info["outiq"].plus())
- CallForResponse(disp, iq, self.answer_ping_ver, {"ltype": ltype, "source": source, "instance": instance, "source_": source_, "start": time.time()})
+ CallForResponse(disp, iq, self.answer_ping_ver, {"stype": stype, "source": source, "instance": instance, "source_": source_, "start": time.time()})
- def answer_ping_ver(self, disp, stanza, ltype, source, instance, source_, start):
+ def answer_ping_ver(self, disp, stanza, stype, source, instance, source_, start):
if xmpp.isResultNode(stanza):
answer = round(time.time() - start, 3)
if source_:
@@ -61,9 +59,9 @@ class expansion_temp(expansion):
answer = self.AnsBase[1] % (Name, str(answer))
else:
answer = self.AnsBase[2]
- Answer(answer, ltype, source, disp)
+ Answer(answer, stype, source, disp)
- def command_ping_stats(self, ltype, source, source_, disp):
+ def command_ping_stats(self, stype, source, source_, disp):
if source_:
if Chats.has_key(source[1]) and Chats[source[1]].isHere(source_):
source_ = get_source(source[1], source_)
@@ -82,24 +80,24 @@ class expansion_temp(expansion):
answer = self.AnsBase[4]
else:
answer = self.AnsBase[4]
- Answer(answer, ltype, source, disp)
+ Answer(answer, stype, source, disp)
- def command_version(self, ltype, source, instance, disp):
+ def command_version(self, stype, source, instance, disp):
if instance:
if Chats.has_key(source[1]) and Chats[source[1]].isHere(instance):
if Chats[source[1]].isHereTS(instance):
instance = "%s/%s" % (source[1], instance)
else:
- Answer(self.AnsBase[5] % (instance), ltype, source, disp)
+ Answer(self.AnsBase[5] % (instance), stype, source, disp)
raise iThr.ThrKill("exit")
else:
instance = source[0]
iq = xmpp.Iq(to = instance, typ = Types[10])
- iq.addChild(Types[18], {}, [], xmpp.NS_VERSION)
+ iq.addChild(Types[18], namespace = xmpp.NS_VERSION)
iq.setID("Bs-i%d" % Info["outiq"].plus())
- CallForResponse(disp, iq, self.answer_version, {"ltype": ltype, "source": source})
+ CallForResponse(disp, iq, self.answer_version, {"stype": stype, "source": source})
- def answer_version(self, disp, stanza, ltype, source):
+ def answer_version(self, disp, stanza, stype, source):
if xmpp.isResultNode(stanza):
Name, Ver, Os = "[None]", "[None]", "[None]"
for node in stanza.getQueryChildren():
@@ -113,29 +111,31 @@ class expansion_temp(expansion):
answer = "\nName: %s\nVer.: %s\nOS: %s" % (Name, Ver, Os)
else:
answer = self.AnsBase[6]
- Answer(answer, ltype, source, disp)
+ Answer(answer, stype, source, disp)
+
+ XEPs.add(xmpp.NS_VCARD)
- def command_vcard(self, ltype, source, instance, disp):
+ def command_vcard(self, stype, source, instance, disp):
if instance:
if Chats.has_key(source[1]) and Chats[source[1]].isHere(instance):
if Chats[source[1]].isHereTS(instance):
instance = "%s/%s" % (source[1], instance)
else:
- Answer(self.AnsBase[5] % (instance), ltype, source, disp)
+ Answer(self.AnsBase[5] % (instance), stype, source, disp)
raise iThr.ThrKill("exit")
else:
instance = source[0]
iq = xmpp.Iq(to = instance, typ = Types[10])
- iq.addChild(Types[18], {}, [], xmpp.NS_VCARD)
+ iq.addChild(Types[18], namespace = xmpp.NS_VCARD)
iq.setID("Bs-i%d" % Info["outiq"].plus())
- CallForResponse(disp, iq, self.answer_vcard, {"ltype": ltype, "source": source})
+ CallForResponse(disp, iq, self.answer_vcard, {"stype": stype, "source": source})
VcardDesc = {
"NICKNAME": "Nick",
"GIVEN": "Name",
"FAMILY": "Surname",
- "BDAY": "Birthday",
"FN": "Full Name",
+ "BDAY": "Birthday",
"USERID": "e-Mail",
"URL": "Web Page",
"DESC": "Description",
@@ -144,8 +144,8 @@ class expansion_temp(expansion):
"PCODE": "Post Code",
"LOCALITY": "City",
"CTRY": "Country",
- "ORGNAME": "Organization Name",
- "ORGUNIT": "Organization Unit"
+ "ORGNAME": "Organization",
+ "ORGUNIT": "Department"
}
def parse_vcard(self, node, ls):
@@ -162,7 +162,7 @@ class expansion_temp(expansion):
name = self.VcardDesc.get(name, name.capitalize())
ls.append("%s: %s" % (name, data))
- def answer_vcard(self, disp, stanza, ltype, source):
+ def answer_vcard(self, disp, stanza, stype, source):
if xmpp.isResultNode(stanza):
ls = []
self.parse_vcard(stanza, ls)
@@ -173,17 +173,17 @@ class expansion_temp(expansion):
answer = self.AnsBase[10]
else:
answer = self.AnsBase[6]
- Answer(answer, ltype, source, disp)
+ Answer(answer, stype, source, disp)
- def command_uptime(self, ltype, source, server, disp):
+ def command_uptime(self, stype, source, server, disp):
if not server:
- server = InstansesDesc[Gen_disp][0]
+ server = disp._owner.Server
iq = xmpp.Iq(to = server, typ = Types[10])
- iq.addChild(Types[18], {}, [], xmpp.NS_LAST)
+ iq.addChild(Types[18], namespace = xmpp.NS_LAST)
iq.setID("Bs-i%d" % Info["outiq"].plus())
- CallForResponse(disp, iq, self.answer_idle, {"ltype": ltype, "source": source, "instance": server, "typ": None})
+ CallForResponse(disp, iq, self.answer_idle, {"stype": stype, "source": source, "instance": server, "typ": None})
- def command_idle(self, ltype, source, instance, disp):
+ def command_idle(self, stype, source, instance, disp):
if instance:
nick = instance
if Chats.has_key(source[1]) and Chats[source[1]].isHere(instance):
@@ -191,28 +191,28 @@ class expansion_temp(expansion):
instance = "%s/%s" % (source[1], instance)
else:
answer = self.AnsBase[5] % (instance)
- if not locals().has_key(Types[12]):
+ if not locals().has_key(Types[6]):
iq = xmpp.Iq(to = instance, typ = Types[10])
- iq.addChild(Types[18], {}, [], xmpp.NS_LAST)
+ iq.addChild(Types[18], namespace = xmpp.NS_LAST)
iq.setID("Bs-i%d" % Info["outiq"].plus())
- CallForResponse(disp, iq, self.answer_idle, {"ltype": ltype, "source": source, "instance": nick, "typ": True})
+ CallForResponse(disp, iq, self.answer_idle, {"stype": stype, "source": source, "instance": nick, "typ": True})
else:
answer = AnsBase[1]
- if locals().has_key(Types[12]):
- Answer(answer, ltype, source, disp)
+ if locals().has_key(Types[6]):
+ Answer(answer, stype, source, disp)
- def answer_idle(self, disp, stanza, ltype, source, instance, typ):
+ def answer_idle(self, disp, stanza, stype, source, instance, typ):
if xmpp.isResultNode(stanza):
seconds = stanza.getTagAttr(Types[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[12]):
+ if not locals().has_key(Types[6]):
answer = self.AnsBase[6]
- Answer(answer, ltype, source, disp)
+ Answer(answer, stype, source, disp)
affs = ("owner", "admin", "member", "outcast")
- def command_aflist(self, ltype, source, body, disp):
+ def command_aflist(self, stype, source, body, disp):
def get_req(body):
if DefLANG in ("RU", "UA"):
@@ -251,7 +251,7 @@ class expansion_temp(expansion):
ls.append("%d) %s" % (Number.plus(), jid))
if ls:
Message(source[0], str.join(chr(10), ls), disp)
- if ltype == Types[1]:
+ if stype == Types[1]:
answer = AnsBase[11]
else:
answer = self.AnsBase[9]
@@ -274,15 +274,15 @@ class expansion_temp(expansion):
query.addChild("item", {aRoles[0]: body})
iq.addChild(node = query)
iq.setID("Bs-i%d" % Info["outiq"].plus())
- CallForResponse(disp, iq, self.answer_aflist, {"ltype": ltype, "source": source, "Numb": Numb})
+ CallForResponse(disp, iq, self.answer_aflist, {"stype": stype, "source": source, "Numb": Numb})
else:
answer = AnsBase[2]
else:
answer = AnsBase[1]
else:
answer = AnsBase[0]
- if locals().has_key(Types[12]):
- Answer(answer, ltype, source, disp)
+ if locals().has_key(Types[6]):
+ Answer(answer, stype, source, disp)
def answer_aflist_search(self, disp, stanza, desc, name, data):
if xmpp.isResultNode(stanza):
@@ -297,7 +297,7 @@ class expansion_temp(expansion):
count.append(jid)
desc[name] = count
- def answer_aflist(self, disp, stanza, ltype, source, Numb):
+ def answer_aflist(self, disp, stanza, stype, source, Numb):
if xmpp.isResultNode(stanza):
ls, Number = [], itypes.Number()
for node in stanza.getQueryChildren():
@@ -315,33 +315,35 @@ class expansion_temp(expansion):
if Numb and Numb < Number._int():
ls.append("...\nTotal: %s items." % (Number._str()))
Message(source[0], str.join(chr(10), ls), disp)
- if ltype == Types[1]:
+ if stype == Types[1]:
answer = AnsBase[11]
else:
answer = self.AnsBase[6]
else:
answer = self.AnsBase[6]
- if locals().has_key(Types[12]):
- Answer(answer, ltype, source, disp)
+ if locals().has_key(Types[6]):
+ Answer(answer, stype, source, disp)
- def command_server_stats(self, ltype, source, instance, disp):
- if not instance:
- instance = disp._owner.Server
- iq = xmpp.Iq(to = instance, typ = Types[10])
- iq.addChild(Types[18], {}, [], xmpp.NS_STATS)
+ XEPs.add(xmpp.NS_STATS)
+
+ def command_server_stats(self, stype, source, server, disp):
+ if not server:
+ server = disp._owner.Server
+ iq = xmpp.Iq(to = server, typ = Types[10])
+ iq.addChild(Types[18], namespace = xmpp.NS_STATS)
iq.setID("Bs-i%d" % Info["outiq"].plus())
- CallForResponse(disp, iq, self.answer_server_stats, {"ltype": ltype, "source": source})
+ CallForResponse(disp, iq, self.answer_server_stats, {"stype": stype, "source": source})
- def answer_server_stats(self, disp, stanza, ltype, source):
+ def answer_server_stats(self, disp, stanza, stype, source):
if xmpp.isResultNode(stanza):
iq = xmpp.Iq(to = stanza.getFrom(), typ = Types[10])
iq.addChild(Types[18], {}, stanza.getQueryChildren(), xmpp.NS_STATS)
iq.setID("Bs-i%d" % Info["outiq"].plus())
- CallForResponse(disp, iq, self.answer_server_stats_get, {"ltype": ltype, "source": source})
+ CallForResponse(disp, iq, self.answer_server_stats_get, {"stype": stype, "source": source})
else:
- Answer(self.AnsBase[6], ltype, source, disp)
+ Answer(self.AnsBase[6], stype, source, disp)
- def answer_server_stats_get(self, disp, stanza, ltype, source):
+ def answer_server_stats_get(self, disp, stanza, stype, source):
if xmpp.isResultNode(stanza):
ls = []
for node in stanza.getQueryChildren():
@@ -356,13 +358,13 @@ class expansion_temp(expansion):
answer = self.AnsBase[4]
else:
answer = self.AnsBase[6]
- Answer(answer, ltype, source, disp)
+ Answer(answer, stype, source, disp)
commands = (
(command_ping, "ping", 1,),
(command_ping_stats, "pstat", 1,),
(command_version, "version", 1,),
- (command_vcard, "vcard", 1,),
+ (command_vcard, "vcard", 2,),
(command_uptime, "uptime", 1,),
(command_idle, "idle", 1,),
(command_aflist, "list", 4,),
diff --git a/expansions/get_iq/uptime.en b/expansions/get_iq/uptime.en
index d61a0be..05d42e8 100644
--- a/expansions/get_iq/uptime.en
+++ b/expansions/get_iq/uptime.en
@@ -1,4 +1,6 @@
servers's uptime
-uptime [domain]
+uptime (server)
+*/uptime
+bot would show uptime of it's current jid's server
*/uptime jabr.com
-bot would show the uptime of jabr.com \ No newline at end of file
+bot would show uptime of jabr.com \ No newline at end of file
diff --git a/expansions/get_iq/uptime.ru b/expansions/get_iq/uptime.ru
index 4eef790..e333f0d 100644
--- a/expansions/get_iq/uptime.ru
+++ b/expansions/get_iq/uptime.ru
@@ -1,4 +1,6 @@
время работы сервера
-аптайм [домен]
+аптайм (server)
+*/аптайм
+бот покажет время работы сервера своего текущего jid'а
*/аптайм jab.ru
бот покажет время работы jab.ru \ No newline at end of file
diff --git a/expansions/help/code.py b/expansions/help/code.py
index b371e6d..1acff2d 100644
--- a/expansions/help/code.py
+++ b/expansions/help/code.py
@@ -1,18 +1,16 @@
# coding: utf-8
# BlackSmith mark.2
-exp_name = "help" # /code.py v.x5
-# Id: 03~2a
+# exp_name = "help" # /code.py v.x5
+# Id: 03~2c
# Code © (2010-2011) by WitcherGeralt [alkorgun@gmail.com]
-expansion_register(exp_name)
-
class expansion_temp(expansion):
def __init__(self, name):
expansion.__init__(self, name)
- def command_location(self, ltype, source, body, disp):
+ def command_location(self, stype, source, body, disp):
if body:
command = body.lower()
if Cmds.has_key(command):
@@ -21,9 +19,9 @@ class expansion_temp(expansion):
answer = AnsBase[6]
else:
answer = AnsBase[1]
- Answer(answer, ltype, source, disp)
+ Answer(answer, stype, source, disp)
- def command_comacc(self, ltype, source, body, disp):
+ def command_comacc(self, stype, source, body, disp):
if body:
command = body.lower()
if Cmds.has_key(command):
@@ -32,9 +30,9 @@ class expansion_temp(expansion):
answer = AnsBase[6]
else:
answer = AnsBase[1]
- Answer(answer, ltype, source, disp)
+ Answer(answer, stype, source, disp)
- def command_help(self, ltype, source, body, disp):
+ def command_help(self, stype, source, body, disp):
if body:
command = body.lower()
if Cmds.has_key(command):
@@ -59,9 +57,9 @@ class expansion_temp(expansion):
answer = AnsBase[6]
else:
answer = self.AnsBase[5]
- Answer(answer, ltype, source, disp)
+ Answer(answer, stype, source, disp)
- def command_commands(self, ltype, source, body, disp):
+ def command_commands(self, stype, source, body, disp):
answer = self.AnsBase[6] % (self.AnsBase[7] % (Chats[source[1]].cPref) if (Chats.has_key(source[1]) and Chats[source[1]].cPref) else ":")
cmds, lcmds = {}, {}
for x in xrange(1, 9):
@@ -102,8 +100,8 @@ class expansion_temp(expansion):
else:
access = str(access)
answer += self.AnsBase[16] % (access)
- if ltype == Types[1]:
- Answer(AnsBase[11], ltype, source, disp)
+ if stype == Types[1]:
+ Answer(AnsBase[11], stype, source, disp)
Message(source[0], answer, disp)
commands = (
diff --git a/expansions/info/code.py b/expansions/info/code.py
index d4dc4ca..c008197 100644
--- a/expansions/info/code.py
+++ b/expansions/info/code.py
@@ -1,170 +1,168 @@
# coding: utf-8
# BlackSmith mark.2
-exp_name = "info" # /code.py v.x5
-# Id: 11~4a
-# Code © (2010-2011) by WitcherGeralt [alkorgun@gmail.com]
-
-expansion_register(exp_name)
+# exp_name = "info" # /code.py v.x6
+# Id: 11~5c
+# Code © (2010-2012) by WitcherGeralt [alkorgun@gmail.com]
class expansion_temp(expansion):
def __init__(self, name):
expansion.__init__(self, name)
- def command_online(self, ltype, source, body, disp):
- list, Numb, ThrIds = self.AnsBase[7], itypes.Number(), iThr.ThrNames()
- for disp_ in sorted(InstansesDesc.keys()):
- connect, alive = online(disp_), str("%s%s" % (Types[13], disp_) in ThrIds)
+ def command_online(self, stype, source, body, disp):
+ ls, ThrIds = self.AnsBase[7], iThr.ThrNames()
+ for numb, disp_ in enumerate(sorted(InstansesDesc.keys()), 1):
+ connect, alive = online(disp_), str("%s-%s" % (Types[13], disp_) in ThrIds)
if not connect:
- connect = False
- list += "\n%d) %s - %s - %s" % (Numb.plus(), disp_, str(connect), alive)
- if ltype == Types[1]:
- Answer(AnsBase[11], ltype, source, disp)
- Message(source[0], list, disp)
+ connect = None
+ ls += "\n%d) %s - %s - %s" % (numb, disp_, str(connect), alive)
+ if stype == Types[1]:
+ Answer(AnsBase[11], stype, source, disp)
+ Message(source[0], ls, disp)
- def command_inchat(self, ltype, source, body, disp):
+ def command_inchat(self, stype, source, body, disp):
if Chats.has_key(source[1]):
- list, Numb, acc = self.AnsBase[8], itypes.Number(), enough_access(source[1], source[2], 4)
+ ls, Numb, access = self.AnsBase[8], itypes.Number(), enough_access(source[1], source[2], 4)
owners, admins, members, none = [], [], [], []
for nick in Chats[source[1]].sorted_users():
if nick.ishere:
- text = nick.nick
- if acc and nick.source:
- text += " (%s)" % (nick.source)
+ data = nick.nick
+ if access and nick.source:
+ data += " (%s)" % (nick.source)
if nick.role[0] == aRoles[5]:
- owners.append(text)
+ owners.append(data)
elif nick.role[0] == aRoles[4]:
- admins.append(text)
+ admins.append(data)
elif nick.role[0] == aRoles[3]:
- members.append(text)
+ members.append(data)
else:
- none.append(text)
+ none.append(data)
if owners:
- list += "\n\nOwners:"
+ ls += "\n\nOwners:"
for x in owners:
- list += "\n%d) %s" % (Numb.plus(), x)
+ ls += "\n%d) %s" % (Numb.plus(), x)
if admins:
- list += "\n\nAdmins:"
+ ls += "\n\nAdmins:"
for x in admins:
- list += "\n%d) %s" % (Numb.plus(), x)
+ ls += "\n%d) %s" % (Numb.plus(), x)
if members:
- list += "\n\nMembers:"
+ ls += "\n\nMembers:"
for x in members:
- list += "\n%d) %s" % (Numb.plus(), x)
+ ls += "\n%d) %s" % (Numb.plus(), x)
if none:
- list += "\n\nOthers:"
+ ls += "\n\nOthers:"
for x in none:
- list += "\n%d) %s" % (Numb.plus(), x)
- if ltype == Types[1]:
- Answer(AnsBase[11], ltype, source, disp)
- Message(source[0], list, disp)
+ ls += "\n%d) %s" % (Numb.plus(), x)
+ if stype == Types[1]:
+ Answer(AnsBase[11], stype, source, disp)
+ Message(source[0], ls, disp)
else:
- Answer(AnsBase[0], ltype, source, disp)
+ Answer(AnsBase[0], stype, source, disp)
- def command_conflist(self, ltype, source, body, disp):
- answer, Numb, admin = self.AnsBase[5], itypes.Number(), enough_access(source[1], source[2], 7)
- for conf in sorted(Chats.keys()):
- BsNick = get_self_nick(conf)
- isModer = str(Chats[conf].isModer)
- ConfName = conf.split("@")[0]
- disp_ = (Chats[conf].disp if admin else "***")
- cPref = str(Chats[conf].cPref)
+ def command_conflist(self, stype, source, body, disp):
+ ls, Numb, access = [], itypes.Number(), enough_access(source[1], source[2], 7)
+ for conf_str, conf in sorted(Chats.items()):
+ isModer = str(conf.isModer)
+ cName = conf_str.split("@")[0]
+ disp_ = (conf.disp if access else "***")
+ cPref = str(conf.cPref)
online = itypes.Number()
- for nick in Chats[conf].get_users():
+ for nick in conf.get_users():
if nick.ishere:
online.plus()
- answer += '\n%d) %s/%s [%s] "%s" (%s) - %s' % (Numb.plus(), ConfName, BsNick, disp_, cPref, online._str(), isModer)
- if Numb._int():
- if ltype == Types[1]:
- Answer(AnsBase[11], ltype, source, disp)
- Message(source[0], answer, disp)
+ ls.append("%d) %s/%s [%s] \"%s\" (%s) - %s" % (Numb.plus(), cName, conf.nick, disp_, cPref, online._str(), isModer))
+ if ls:
+ if stype == Types[1]:
+ Answer(AnsBase[11], stype, source, disp)
+ ls.insert(0, self.AnsBase[5])
+ Message(source[0], str.join(chr(10), ls), disp)
else:
- Answer(self.AnsBase[6], ltype, source, disp)
+ Answer(self.AnsBase[6], stype, source, disp)
- def command_visitors(self, ltype, source, body, disp):
+ def command_visitors(self, stype, source, body, disp):
if Chats.has_key(source[1]):
if body:
- Var = body.lower()
+ body = body.lower()
else:
- Var = "default"
- if Var in ("today", "сегодня".decode("utf-8")):
- list = str()
- date = Yday()
+ body = "default"
+ if body in ("today", "сегодня".decode("utf-8")):
+ Number = itypes.Number()
Numb = itypes.Number()
- Numb2 = itypes.Number()
+ ls = []
+ date = Yday()
for nick in Chats[source[1]].sorted_users():
if not nick.ishere:
if nick.date[1] == date:
if nick.source:
- list += "\n%d. %s (%s)" % (Numb.plus(), nick.nick, nick.source)
+ ls.append("%d. %s (%s)" % (Number.plus(), nick.nick, nick.source))
else:
- list += "\n%d. %s" % (Numb.plus(), nick.nick)
+ ls.append("%d. %s" % (Number.plus(), nick.nick))
else:
- Numb2.plus()
- if Numb._int():
- if ltype == Types[1]:
- Answer(AnsBase[11], ltype, source, disp)
- Message(source[0], self.AnsBase[0] % (Numb._str(), list, Numb2._str()), disp)
+ Numb.plus()
+ if Number._int():
+ if stype == Types[1]:
+ Answer(AnsBase[11], stype, source, disp)
+ Message(source[0], self.AnsBase[0] % (Number._str(), str.join(chr(10), ls), Numb._str()), disp)
else:
- Answer(self.AnsBase[1], ltype, source, disp)
- elif Var in ("dates", "даты".decode("utf-8")):
- list = str()
- Numb = itypes.Number()
+ Answer(self.AnsBase[1], stype, source, disp)
+ elif body in ("dates", "даты".decode("utf-8")):
+ Number = itypes.Number()
+ ls = []
for nick in Chats[source[1]].sorted_users():
- list += "\n%d. %s\t\t%s" % (Numb.plus(), nick.nick, nick.date[2])
- if ltype == Types[1]:
- Answer(AnsBase[11], ltype, source, disp)
- Message(source[0], self.AnsBase[2] % (Numb._str(), list), disp)
- elif Var in ("list", "лист".decode("utf-8")):
+ ls.append("%d. %s\t\t%s" % (Number.plus(), nick.nick, nick.date[2]))
+ if stype == Types[1]:
+ Answer(AnsBase[11], stype, source, disp)
+ Message(source[0], self.AnsBase[2] % (Number._str(), str.join(chr(10))), disp)
+ elif body in ("list", "лист".decode("utf-8")):
ls = sorted(Chats[source[1]].get_nicks())
- if ltype == Types[1]:
- Answer(AnsBase[11], ltype, source, disp)
+ if stype == Types[1]:
+ Answer(AnsBase[11], stype, source, disp)
Message(source[0], self.AnsBase[2] % (str(len(ls)), ", ".join(ls)), disp)
else:
- list = str()
+ Number = itypes.Number()
Numb = itypes.Number()
- Numb2 = itypes.Number()
+ ls = []
for nick in Chats[source[1]].sorted_users():
if not nick.ishere:
if nick.source:
- list += "\n%d. %s (%s)" % (Numb.plus(), nick.nick, nick.source)
+ ls.append("%d. %s (%s)" % (Number.plus(), nick.nick, nick.source))
else:
- list += "\n%d. %s" % (Numb.plus(), nick.nick)
+ ls.append("%d. %s" % (Number.plus(), nick.nick))
else:
- Numb2.plus()
- if Numb._int():
- if ltype == Types[1]:
- Answer(AnsBase[11], ltype, source, disp)
- Message(source[0], self.AnsBase[3] % (Numb._str(), list, Numb2._str()), disp)
+ Numb.plus()
+ if Number._int():
+ if stype == Types[1]:
+ Answer(AnsBase[11], stype, source, disp)
+ Message(source[0], self.AnsBase[3] % (Number._str(), str.join(chr(10), ls), Numb._str()), disp)
else:
- Answer(self.AnsBase[4], ltype, source, disp)
+ Answer(self.AnsBase[4], stype, source, disp)
else:
- Answer(AnsBase[0], ltype, source, disp)
+ Answer(AnsBase[0], stype, source, disp)
- def command_search(self, ltype, source, body, disp):
+ def command_search(self, stype, source, body, disp):
if body:
- list, Numb, acc = str(), itypes.Number(), enough_access(source[1], source[2], 7)
- for conf in sorted(Chats.keys()):
- for nick in sorted(Chats[conf].get_nicks()):
- if Chats[conf].isHereTS(nick):
- jid = get_source(conf, nick)
+ ls, Numb, access = "", itypes.Number(), enough_access(source[1], source[2], 7)
+ for conf_str, conf in sorted(Chats.items()):
+ for nick in sorted(conf.get_nicks()):
+ if conf.isHereTS(nick):
+ jid = get_source(conf_str, nick)
if nick.count(body) or (jid and jid.count(body)):
- list += "\n%d) %s (%s)" % (Numb.plus(), nick, conf)
- if jid and acc:
- list += " [%s]" % (jid)
+ ls += "\n%d) %s (%s)" % (Numb.plus(), nick, conf_str)
+ if jid and access:
+ ls += " [%s]" % (jid)
if Numb._int() >= 20:
break
if Numb._int():
- if ltype == Types[1]:
- Answer(AnsBase[11], ltype, source, disp)
- Message(source[0], self.AnsBase[9] % (Numb._str(), list), disp)
+ if stype == Types[1]:
+ Answer(AnsBase[11], stype, source, disp)
+ Message(source[0], self.AnsBase[9] % (Numb._str(), ls), disp)
else:
answer = self.AnsBase[10]
else:
answer = AnsBase[1]
- if locals().has_key(Types[12]):
- Answer(answer, ltype, source, disp)
+ if locals().has_key(Types[6]):
+ Answer(answer, stype, source, disp)
commands = (
(command_online, "online", 7,),
diff --git a/expansions/info/insc.py b/expansions/info/insc.py
index 8a061f3..59207f3 100644
--- a/expansions/info/insc.py
+++ b/expansions/info/insc.py
@@ -2,8 +2,8 @@
if DefLANG in ("RU", "UA"):
AnsBase_temp = tuple([line.decode("utf-8") for line in (
- "Сегодня здесь было %s юзеров:%s\n+ ещё %s досихпор здесь.", # 0
- "Сегодня при мне ещё никто не выходил, все кто был досихпор здесь.", # 1
+ "Сегодня здесь было %s юзеров:%s\n+ ещё %s до сих пор здесь.", # 0
+ "Сегодня при мне ещё никто не выходил, все кто был до сих пор здесь.", # 1
"При мне заходило %s юзеров:\n%s", # 2
"Здесь было %s юзеров:%s\n+ ещё %s досихпор здесь.", # 3
"При мне ещё никто не выходил, все кто был досихпор здесь.", # 4
diff --git a/expansions/interpreter/code.py b/expansions/interpreter/code.py
index ee0df42..969e0a2 100644
--- a/expansions/interpreter/code.py
+++ b/expansions/interpreter/code.py
@@ -1,20 +1,18 @@
# coding: utf-8
# BlackSmith mark.2
-exp_name = "interpreter" # /code.py v.x8
-# Id: 04~6b
+# exp_name = "interpreter" # /code.py v.x8
+# Id: 04~6c
# Code © (2002-2005) by Mike Mintz [mikemintz@gmail.com]
# Code © (2007) by Als [Als@exploit.in]
# Code © (2009-2012) by WitcherGeralt [alkorgun@gmail.com]
-expansion_register(exp_name)
-
class expansion_temp(expansion):
def __init__(self, name):
expansion.__init__(self, name)
- def command_eval(self, ltype, source, body, disp):
+ def command_eval(self, stype, source, body, disp):
if body:
try:
answer = UnicodeType(eval(UnicodeType(body)))
@@ -24,9 +22,9 @@ class expansion_temp(expansion):
answer = "%s - %s" % exc_info()
else:
answer = AnsBase[1]
- Answer(answer, ltype, source, disp)
+ Answer(answer, stype, source, disp)
- def command_exec(self, ltype, source, body, disp):
+ def command_exec(self, stype, source, body, disp):
if body:
if not body.endswith(chr(10)):
body += chr(10)
@@ -38,9 +36,9 @@ class expansion_temp(expansion):
answer = AnsBase[4]
else:
answer = AnsBase[1]
- Answer(answer, ltype, source, disp)
+ Answer(answer, stype, source, disp)
- def command_sh(self, ltype, source, body, disp):
+ def command_sh(self, stype, source, body, disp):
if body:
if oSlist[1]:
command = sys_cmds[6] % (body.encode("utf-8"))
@@ -51,9 +49,9 @@ class expansion_temp(expansion):
answer = AnsBase[4]
else:
answer = AnsBase[1]
- Answer(answer, ltype, source, disp)
+ Answer(answer, stype, source, disp)
- def command_calc(self, ltype, source, body, disp):
+ def command_calc(self, stype, source, body, disp):
if body:
if not body.count(chr(42)*2) and 32 >= len(body):
comp = compile__("([0-9]|[\+\-\(\/\*\)\%\^\.])")
@@ -71,7 +69,7 @@ class expansion_temp(expansion):
answer = AnsBase[2]
else:
answer = AnsBase[1]
- Answer(answer, ltype, source, disp)
+ Answer(answer, stype, source, disp)
commands = (
(command_eval, "eval", 8,),
diff --git a/expansions/muc/code.py b/expansions/muc/code.py
index 78b6412..20feb2c 100644
--- a/expansions/muc/code.py
+++ b/expansions/muc/code.py
@@ -1,18 +1,16 @@
# coding: utf-8
# BlackSmith mark.2
-exp_name = "muc" # /code.py v.x7
-# Id: 05~3a
+# exp_name = "muc" # /code.py v.x7
+# Id: 05~3c
# Code © (2009-2011) by WitcherGeralt [alkorgun@gmail.com]
-expansion_register(exp_name)
-
class expansion_temp(expansion):
def __init__(self, name):
expansion.__init__(self, name)
- def command_subject(self, ltype, source, body, disp):
+ def command_subject(self, stype, source, body, disp):
if Chats.has_key(source[1]):
if body:
if Chats[source[1]].isModer:
@@ -24,14 +22,14 @@ class expansion_temp(expansion):
answer = AnsBase[1]
else:
answer = AnsBase[0]
- if locals().has_key(Types[12]):
- Answer(answer, ltype, source, disp)
+ if locals().has_key(Types[6]):
+ Answer(answer, stype, source, disp)
- def command_ban(self, ltype, source, body, disp):
+ def command_ban(self, stype, source, body, disp):
if Chats.has_key(source[1]):
if body:
if Chats[source[1]].isModer:
- Lock, BsNick = False, get_self_nick(source[1])
+ Lock, BsNick = False, get_nick(source[1])
if getattr(Chats[source[1]].get_user(BsNick), "role", (aRoles[5],))[0] == aRoles[5]:
if not enough_access(source[1], source[2], 6):
Lock = True
@@ -51,8 +49,8 @@ class expansion_temp(expansion):
if body and body[0]:
text = "%s: %s" % (source[2], (body.pop(0)).strip())
else:
- text = "%s/%s" % (get_self_nick(source[1]), source[2])
- Chats[source[1]].outcast(jid, text, (None, (ltype, source)))
+ text = "%s/%s" % (get_nick(source[1]), source[2])
+ Chats[source[1]].outcast(jid, text, (None, (stype, source)))
else:
answer = AnsBase[7]
else:
@@ -63,14 +61,14 @@ class expansion_temp(expansion):
answer = AnsBase[1]
else:
answer = AnsBase[0]
- if locals().has_key(Types[12]):
- Answer(answer, ltype, source, disp)
+ if locals().has_key(Types[6]):
+ Answer(answer, stype, source, disp)
- def command_none(self, ltype, source, body, disp):
+ def command_none(self, stype, source, body, disp):
if Chats.has_key(source[1]):
if body:
if Chats[source[1]].isModer:
- Lock, BsNick = False, get_self_nick(source[1])
+ Lock, BsNick = False, get_nick(source[1])
if getattr(Chats[source[1]].get_user(BsNick), "role", (aRoles[5],))[0] == aRoles[5]:
if not enough_access(source[1], source[2], 6):
Lock = True
@@ -90,8 +88,8 @@ class expansion_temp(expansion):
if body and body[0]:
text = "%s: %s" % (source[2], (body.pop(0)).strip())
else:
- text = "%s/%s" % (get_self_nick(source[1]), source[2])
- Chats[source[1]].none(jid, text, (None, (ltype, source)))
+ text = "%s/%s" % (get_nick(source[1]), source[2])
+ Chats[source[1]].none(jid, text, (None, (stype, source)))
else:
answer = AnsBase[7]
else:
@@ -102,14 +100,14 @@ class expansion_temp(expansion):
answer = AnsBase[1]
else:
answer = AnsBase[0]
- if locals().has_key(Types[12]):
- Answer(answer, ltype, source, disp)
+ if locals().has_key(Types[6]):
+ Answer(answer, stype, source, disp)
- def command_member(self, ltype, source, body, disp):
+ def command_member(self, stype, source, body, disp):
if Chats.has_key(source[1]):
if body:
if Chats[source[1]].isModer:
- Lock, BsNick = False, get_self_nick(source[1])
+ Lock, BsNick = False, get_nick(source[1])
if getattr(Chats[source[1]].get_user(BsNick), "role", (aRoles[5],))[0] == aRoles[5]:
if not enough_access(source[1], source[2], 6):
Lock = True
@@ -129,8 +127,8 @@ class expansion_temp(expansion):
if body and body[0]:
text = "%s: %s" % (source[2], (body.pop(0)).strip())
else:
- text = "%s/%s" % (get_self_nick(source[1]), source[2])
- Chats[source[1]].member(jid, text, (None, (ltype, source)))
+ text = "%s/%s" % (get_nick(source[1]), source[2])
+ Chats[source[1]].member(jid, text, (None, (stype, source)))
else:
answer = AnsBase[7]
else:
@@ -141,14 +139,14 @@ class expansion_temp(expansion):
answer = AnsBase[1]
else:
answer = AnsBase[0]
- if locals().has_key(Types[12]):
- Answer(answer, ltype, source, disp)
+ if locals().has_key(Types[6]):
+ Answer(answer, stype, source, disp)
- def command_admin(self, ltype, source, body, disp):
+ def command_admin(self, stype, source, body, disp):
if Chats.has_key(source[1]):
if body:
if Chats[source[1]].isModer:
- Lock, BsNick = False, get_self_nick(source[1])
+ Lock, BsNick = False, get_nick(source[1])
if getattr(Chats[source[1]].get_user(BsNick), "role", (aRoles[5],))[0] == aRoles[5]:
if not enough_access(source[1], source[2], 6):
Lock = True
@@ -168,8 +166,8 @@ class expansion_temp(expansion):
if body and body[0]:
text = "%s: %s" % (source[2], (body.pop(0)).strip())
else:
- text = "%s/%s" % (get_self_nick(source[1]), source[2])
- Chats[source[1]].admin(jid, text, (None, (ltype, source)))
+ text = "%s/%s" % (get_nick(source[1]), source[2])
+ Chats[source[1]].admin(jid, text, (None, (stype, source)))
else:
answer = AnsBase[7]
else:
@@ -180,14 +178,14 @@ class expansion_temp(expansion):
answer = AnsBase[1]
else:
answer = AnsBase[0]
- if locals().has_key(Types[12]):
- Answer(answer, ltype, source, disp)
+ if locals().has_key(Types[6]):
+ Answer(answer, stype, source, disp)
- def command_owner(self, ltype, source, body, disp):
+ def command_owner(self, stype, source, body, disp):
if Chats.has_key(source[1]):
if body:
if Chats[source[1]].isModer:
- Lock, BsNick = False, get_self_nick(source[1])
+ Lock, BsNick = False, get_nick(source[1])
if getattr(Chats[source[1]].get_user(BsNick), "role", (aRoles[5],))[0] == aRoles[5]:
if not enough_access(source[1], source[2], 6):
Lock = True
@@ -207,8 +205,8 @@ class expansion_temp(expansion):
if body and body[0]:
text = "%s: %s" % (source[2], (body.pop(0)).strip())
else:
- text = "%s/%s" % (get_self_nick(source[1]), source[2])
- Chats[source[1]].owner(jid, text, (None, (ltype, source)))
+ text = "%s/%s" % (get_nick(source[1]), source[2])
+ Chats[source[1]].owner(jid, text, (None, (stype, source)))
else:
answer = AnsBase[7]
else:
@@ -219,14 +217,14 @@ class expansion_temp(expansion):
answer = AnsBase[1]
else:
answer = AnsBase[0]
- if locals().has_key(Types[12]):
- Answer(answer, ltype, source, disp)
+ if locals().has_key(Types[6]):
+ Answer(answer, stype, source, disp)
- def command_kick(self, ltype, source, body, disp):
+ def command_kick(self, stype, source, body, disp):
if Chats.has_key(source[1]):
if body:
if Chats[source[1]].isModer:
- Lock, BsNick = False, get_self_nick(source[1])
+ Lock, BsNick = False, get_nick(source[1])
if getattr(Chats[source[1]].get_user(BsNick), "role", (aRoles[5],))[0] == aRoles[5]:
if not enough_access(source[1], source[2], 6):
Lock = True
@@ -245,8 +243,8 @@ class expansion_temp(expansion):
if body and body[0]:
text = "%s: %s" % (source[2], (body.pop(0)).strip())
else:
- text = "%s/%s" % (get_self_nick(source[1]), source[2])
- Chats[source[1]].kick(nick, text, (None, (ltype, source)))
+ text = "%s/%s" % (get_nick(source[1]), source[2])
+ Chats[source[1]].kick(nick, text, (None, (stype, source)))
else:
answer = AnsBase[7]
else:
@@ -257,14 +255,14 @@ class expansion_temp(expansion):
answer = AnsBase[1]
else:
answer = AnsBase[0]
- if locals().has_key(Types[12]):
- Answer(answer, ltype, source, disp)
+ if locals().has_key(Types[6]):
+ Answer(answer, stype, source, disp)
- def command_visitor(self, ltype, source, body, disp):
+ def command_visitor(self, stype, source, body, disp):
if Chats.has_key(source[1]):
if body:
if Chats[source[1]].isModer:
- Lock, BsNick = False, get_self_nick(source[1])
+ Lock, BsNick = False, get_nick(source[1])
if getattr(Chats[source[1]].get_user(BsNick), "role", (aRoles[5],))[0] == aRoles[5]:
if not enough_access(source[1], source[2], 6):
Lock = True
@@ -283,8 +281,8 @@ class expansion_temp(expansion):
if body and body[0]:
text = "%s: %s" % (source[2], (body.pop(0)).strip())
else:
- text = "%s/%s" % (get_self_nick(source[1]), source[2])
- Chats[source[1]].visitor(nick, text, (None, (ltype, source)))
+ text = "%s/%s" % (get_nick(source[1]), source[2])
+ Chats[source[1]].visitor(nick, text, (None, (stype, source)))
else:
answer = AnsBase[7]
else:
@@ -295,14 +293,14 @@ class expansion_temp(expansion):
answer = AnsBase[1]
else:
answer = AnsBase[0]
- if locals().has_key(Types[12]):
- Answer(answer, ltype, source, disp)
+ if locals().has_key(Types[6]):
+ Answer(answer, stype, source, disp)
- def command_participant(self, ltype, source, body, disp):
+ def command_participant(self, stype, source, body, disp):
if Chats.has_key(source[1]):
if body:
if Chats[source[1]].isModer:
- Lock, BsNick = False, get_self_nick(source[1])
+ Lock, BsNick = False, get_nick(source[1])
if getattr(Chats[source[1]].get_user(BsNick), "role", (aRoles[5],))[0] == aRoles[5]:
if not enough_access(source[1], source[2], 6):
Lock = True
@@ -320,8 +318,8 @@ class expansion_temp(expansion):
if body and body[0]:
text = "%s: %s" % (source[2], (body.pop(0)).strip())
else:
- text = "%s/%s" % (get_self_nick(source[1]), source[2])
- Chats[source[1]].participant(nick, text, (None, (ltype, source)))
+ text = "%s/%s" % (get_nick(source[1]), source[2])
+ Chats[source[1]].participant(nick, text, (None, (stype, source)))
else:
answer = AnsBase[7]
else:
@@ -332,14 +330,14 @@ class expansion_temp(expansion):
answer = AnsBase[1]
else:
answer = AnsBase[0]
- if locals().has_key(Types[12]):
- Answer(answer, ltype, source, disp)
+ if locals().has_key(Types[6]):
+ Answer(answer, stype, source, disp)
- def command_moder(self, ltype, source, body, disp):
+ def command_moder(self, stype, source, body, disp):
if Chats.has_key(source[1]):
if body:
if Chats[source[1]].isModer:
- Lock, BsNick = False, get_self_nick(source[1])
+ Lock, BsNick = False, get_nick(source[1])
if getattr(Chats[source[1]].get_user(BsNick), "role", (aRoles[5],))[0] == aRoles[5]:
if not enough_access(source[1], source[2], 6):
Lock = True
@@ -357,8 +355,8 @@ class expansion_temp(expansion):
if body and body[0]:
text = "%s: %s" % (source[2], (body.pop(0)).strip())
else:
- text = "%s/%s" % (get_self_nick(source[1]), source[2])
- Chats[source[1]].moder(nick, text, (None, (ltype, source)))
+ text = "%s/%s" % (get_nick(source[1]), source[2])
+ Chats[source[1]].moder(nick, text, (None, (stype, source)))
else:
answer = AnsBase[7]
else:
@@ -369,8 +367,8 @@ class expansion_temp(expansion):
answer = AnsBase[1]
else:
answer = AnsBase[0]
- if locals().has_key(Types[12]):
- Answer(answer, ltype, source, disp)
+ if locals().has_key(Types[6]):
+ Answer(answer, stype, source, disp)
PerfDesc = {"done": 0, "fail": 0}
@@ -396,7 +394,7 @@ class expansion_temp(expansion):
answer = self.AnsBase[4]
return answer
- def command_fullban(self, ltype, source, body, disp):
+ def command_fullban(self, stype, source, body, disp):
if Chats.has_key(source[1]):
if body:
body = body.split(chr(47), 1)
@@ -414,10 +412,10 @@ class expansion_temp(expansion):
if body and body[0]:
text = "%s: %s" % (source[2], (body.pop(0)).strip())
else:
- text = "%s/%s" % (get_self_nick(source[1]), source[2])
+ text = "%s/%s" % (get_nick(source[1]), source[2])
desc = self.PerfDesc.copy()
- for conf in Chats.keys():
- Chats[conf].outcast(jid, text, (self.HandleFB, {"desc": desc}))
+ for conf in Chats.itervalues():
+ conf.outcast(jid, text, (self.HandleFB, {"desc": desc}))
answer = self.calcPerformance(desc)
else:
answer = AnsBase[7]
@@ -425,9 +423,9 @@ class expansion_temp(expansion):
answer = AnsBase[1]
else:
answer = AnsBase[0]
- Answer(answer, ltype, source, disp)
+ Answer(answer, stype, source, disp)
- def command_fullunban(self, ltype, source, body, disp):
+ def command_fullunban(self, stype, source, body, disp):
if Chats.has_key(source[1]):
if body:
body = body.split(chr(47), 1)
@@ -443,8 +441,8 @@ class expansion_temp(expansion):
jid = None
if jid:
desc = self.PerfDesc.copy()
- for conf in Chats.keys():
- Chats[conf].none(jid, handler = (self.HandleFB, {"desc": desc}))
+ for conf in Chats.itervalues():
+ conf.none(jid, handler = (self.HandleFB, {"desc": desc}))
answer = self.calcPerformance(desc)
else:
answer = AnsBase[7]
@@ -452,7 +450,7 @@ class expansion_temp(expansion):
answer = AnsBase[1]
else:
answer = AnsBase[0]
- Answer(answer, ltype, source, disp)
+ Answer(answer, stype, source, disp)
commands = (
(command_subject, "subject", 3,),
diff --git a/expansions/new_year/code.py b/expansions/new_year/code.py
index 424c964..7cf1547 100644
--- a/expansions/new_year/code.py
+++ b/expansions/new_year/code.py
@@ -1,18 +1,16 @@
# coding: utf-8
# BlackSmith mark.2
-exp_name = "new_year" # /code.py v.x4
-# Id: 02~3b
+# exp_name = "new_year" # /code.py v.x4
+# Id: 02~3c
# Code © (2010-2011) by WitcherGeralt [alkorgun@gmail.com]
-expansion_register(exp_name)
-
class expansion_temp(expansion):
def __init__(self, name):
expansion.__init__(self, name)
- def command_new_year(self, ltype, source, body, disp):
+ def command_new_year(self, stype, source, body, disp):
list = ["Until the New Year (UTC) left:"]
Time = time.gmtime()
dr = lambda Numb: (Numb, ("s" if Numb >= 2 else ""))
@@ -31,6 +29,6 @@ class expansion_temp(expansion):
list.append("%d Second%s" % dr(t4))
if len(list) == 1:
list = ["Happy New Year!"]
- Answer(str.join(chr(32), list), ltype, source, disp)
+ Answer(str.join(chr(32), list), stype, source, disp)
commands = ((command_new_year, "new_year", 1,),)
diff --git a/expansions/note/code.py b/expansions/note/code.py
index 68d1594..af5a4a1 100644
--- a/expansions/note/code.py
+++ b/expansions/note/code.py
@@ -1,12 +1,10 @@
# coding: utf-8
# BlackSmith mark.2
-exp_name = "note" # /code.py v.x5
-# Id: 22~4b
+# exp_name = "note" # /code.py v.x5
+# Id: 22~4c
# Code © (2010-2011) by WitcherGeralt [alkorgun@gmail.com]
-expansion_register(exp_name)
-
class expansion_temp(expansion):
def __init__(self, name):
@@ -14,7 +12,7 @@ class expansion_temp(expansion):
NoteFile = dynamic % ("notepad.db")
- def command_note(self, ltype, source, body, disp):
+ def command_note(self, stype, source, body, disp):
source_ = get_source(source[1], source[2])
if source_:
if body:
@@ -34,7 +32,7 @@ class expansion_temp(expansion):
if mode == "+":
body = body[2:].lstrip()
if len(body) <= 512:
- date = strTime(local = False)
+ date = strfTime(local = False)
with database(self.NoteFile) as db:
db("select * from note where jid=?", (source_,))
db_desc = db.fetchone()
@@ -100,8 +98,8 @@ class expansion_temp(expansion):
Numb.plus()
if Notes:
Notes = (self.AnsBase[6] % (Notes))
- if ltype == Types[1]:
- Answer(AnsBase[11], ltype, source, disp)
+ if stype == Types[1]:
+ Answer(AnsBase[11], stype, source, disp)
Message(source[0], Notes, disp)
else:
db("delete from note where jid=?", (source_,))
@@ -111,8 +109,8 @@ class expansion_temp(expansion):
answer = self.AnsBase[0]
else:
answer = self.AnsBase[2]
- if locals().has_key(Types[12]):
- Answer(answer, ltype, source, disp)
+ if locals().has_key(Types[6]):
+ Answer(answer, stype, source, disp)
def init_note_file(self):
if not os.path.isfile(self.NoteFile):
diff --git a/expansions/roster_control/code.py b/expansions/roster_control/code.py
index f9255f4..626e79f 100644
--- a/expansions/roster_control/code.py
+++ b/expansions/roster_control/code.py
@@ -1,12 +1,10 @@
# coding: utf-8
# BlackSmith mark.2
-exp_name = "roster_control" # /code.py v.x3
-# Id: 23~3b
+# exp_name = "roster_control" # /code.py v.x3
+# Id: 23~3c
# Code © (2011-2012) by WitcherGeralt [alkorgun@gmail.com]
-expansion_register(exp_name)
-
class expansion_temp(expansion):
def __init__(self, name):
@@ -14,7 +12,7 @@ class expansion_temp(expansion):
RosterFile = dynamic % ("roster.db")
- def command_roster(self, ltype, source, body, disp):
+ def command_roster(self, stype, source, body, disp):
cls = sorted(Clients.keys())
if body:
ls = body.split()
@@ -99,9 +97,9 @@ class expansion_temp(expansion):
answer = self.AnsBase[2]
else:
answer = enumerated_list(cls)
- Answer(answer, ltype, source, disp)
+ Answer(answer, stype, source, disp)
- def command_roster_state(self, ltype, source, body, disp):
+ def command_roster_state(self, stype, source, body, disp):
if body:
body = (body.split())[0].lower()
if body in ("on", "1", "вкл".decode("utf-8")):
@@ -122,7 +120,7 @@ class expansion_temp(expansion):
answer = AnsBase[2]
else:
answer = (self.AnsBase[3] if Roster["on"] else self.AnsBase[4])
- Answer(answer, ltype, source, disp)
+ Answer(answer, stype, source, disp)
def init_roster_state(self):
if initialize_file(self.RosterFile, str(True)):
diff --git a/expansions/sconf_attrs/code.py b/expansions/sconf_attrs/code.py
index 163a2d0..b46e9c8 100644
--- a/expansions/sconf_attrs/code.py
+++ b/expansions/sconf_attrs/code.py
@@ -1,18 +1,16 @@
# coding: utf-8
# BlackSmith mark.2
-exp_name = "sconf_attrs" # /code.py v.x4
-# Id: 07~3b
+# exp_name = "sconf_attrs" # /code.py v.x4
+# Id: 07~3c
# Code © (2010-2011) by WitcherGeralt [alkorgun@gmail.com]
-expansion_register(exp_name)
-
class expansion_temp(expansion):
def __init__(self, name):
expansion.__init__(self, name)
- def command_redisp(self, ltype, source, body, disp):
+ def command_redisp(self, stype, source, body, disp):
body = body.split()
if len(body) >= 1:
disp_ = (body.pop(0)).lower()
@@ -42,9 +40,9 @@ class expansion_temp(expansion):
answer = self.AnsBase[2] % (disp_)
else:
answer = AnsBase[2]
- Answer(answer, ltype, source, disp)
+ Answer(answer, stype, source, disp)
- def command_botnick(self, ltype, source, body, disp):
+ def command_botnick(self, stype, source, body, disp):
if Chats.has_key(source[1]):
if body:
Nick = sub_desc(body, [(chr(32), chr(95)), chr(10), chr(13), chr(9)]).strip()
@@ -59,9 +57,9 @@ class expansion_temp(expansion):
answer = AnsBase[1]
else:
answer = AnsBase[0]
- Answer(answer, ltype, source, disp)
+ Answer(answer, stype, source, disp)
- def command_prefix(self, ltype, source, body, disp):
+ def command_prefix(self, stype, source, body, disp):
if Chats.has_key(source[1]):
if body:
if enough_access(source[1], source[2], 6):
@@ -90,13 +88,13 @@ class expansion_temp(expansion):
answer = self.AnsBase[12]
else:
answer = AnsBase[0]
- Answer(answer, ltype, source, disp)
+ Answer(answer, stype, source, disp)
StatusDesc = {"чат".decode("utf-8"): 0, "ушел".decode("utf-8"): 1, "нет".decode("utf-8"): 2, "занят".decode("utf-8"): 3}
ChatStatus = "status.db"
- def command_status(self, ltype, source, body, disp):
+ def command_status(self, stype, source, body, disp):
if body:
body = body.split(None, 2)
if len(body) == 3:
@@ -108,9 +106,9 @@ class expansion_temp(expansion):
body = "%s|%s" % (state, status)
chat = chat.lower()
if chat in ("everywhere", "везде".decode("utf-8")):
- for conf in Chats.keys():
- Chats[conf].change_status(state, status)
- cat_file(chat_file(conf, self.ChatStatus), body)
+ for conf in Chats.itervalues():
+ conf.change_status(state, status)
+ cat_file(chat_file(conf.name, self.ChatStatus), body)
answer = AnsBase[4]
elif chat in ("here", "здесь".decode("utf-8")):
if Chats.has_key(source[1]):
@@ -131,9 +129,9 @@ class expansion_temp(expansion):
answer = AnsBase[2]
else:
answer = AnsBase[1]
- Answer(answer, ltype, source, disp)
+ Answer(answer, stype, source, disp)
- def command_password(self, ltype, source, body, disp):
+ def command_password(self, stype, source, body, disp):
if Chats.has_key(source[1]):
if body:
if body in ("none", "нет".decode("utf-8")):
@@ -145,7 +143,7 @@ class expansion_temp(expansion):
answer = str(Chats[source[1]].code)
else:
answer = AnsBase[0]
- Answer(answer, ltype, source, disp)
+ Answer(answer, stype, source, disp)
def load_status(self, conf):
filename = chat_file(conf, self.ChatStatus)
diff --git a/expansions/session_stats/code.py b/expansions/session_stats/code.py
index c7d4c4d..d1d9a26 100644
--- a/expansions/session_stats/code.py
+++ b/expansions/session_stats/code.py
@@ -1,18 +1,16 @@
# coding: utf-8
# BlackSmith mark.2
-exp_name = "session_stats" # /code.py v.x6
-# Id: 10~4b
+# exp_name = "session_stats" # /code.py v.x6
+# Id: 10~4c
# Code © (2010-2012) by WitcherGeralt [alkorgun@gmail.com]
-expansion_register(exp_name)
-
class expansion_temp(expansion):
def __init__(self, name):
expansion.__init__(self, name)
- def command_exc_info(self, ltype, source, body, disp):
+ def command_exc_info(self, stype, source, body, disp):
if body:
if isNumber(body):
Number = (int(body) - 1)
@@ -22,8 +20,8 @@ class expansion_temp(expansion):
if oSlist[0]:
exc = exc.decode("cp1251")
exc = str(exc)
- if ltype == Types[1]:
- Answer(AnsBase[11], ltype, source, disp)
+ if stype == Types[1]:
+ Answer(AnsBase[11], stype, source, disp)
Message(source[0], exc, disp)
except:
answer = self.AnsBase[20]
@@ -33,19 +31,19 @@ class expansion_temp(expansion):
answer = AnsBase[30]
else:
answer = self.AnsBase[22] % len(VarCache["errors"])
- if locals().has_key(Types[12]):
- Answer(answer, ltype, source, disp)
+ if locals().has_key(Types[6]):
+ Answer(answer, stype, source, disp)
- def command_botup(self, ltype, source, body, disp):
+ def command_botup(self, stype, source, body, disp):
NowTime = time.time()
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]:
answer += self.AnsBase[17]
- Answer(answer, ltype, source, disp)
+ Answer(answer, stype, source, disp)
- def command_session(self, ltype, source, body, disp):
+ def command_session(self, stype, source, body, disp):
NowTime = time.time()
answer = self.AnsBase[0] % (BsPid)
answer += self.AnsBase[1] % (Time2Text(NowTime - Info["up"]))
@@ -57,8 +55,8 @@ class expansion_temp(expansion):
answer += self.AnsBase[5] % (Info["prs"]._str(), Info["iq"]._str())
answer += self.AnsBase[6] % (Info["omsg"]._str(), Info["outiq"]._str())
Number = itypes.Number()
- for conf in Chats.keys():
- Number.plus(len(Chats[conf].get_nicks()))
+ 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())
@@ -67,9 +65,9 @@ class expansion_temp(expansion):
Number = calculate()
if Number:
answer += self.AnsBase[14] % str(round(float(Number) / 1024, 3))
- Answer(answer, ltype, source, disp)
+ Answer(answer, stype, source, disp)
- def command_stats(self, ltype, source, body, disp):
+ def command_stats(self, stype, source, body, disp):
if body:
cmd = body.lower()
if Cmds.has_key(cmd):
@@ -83,7 +81,7 @@ class expansion_temp(expansion):
if used:
ls.append((used, len(cmd.desc), cmd.name))
answer = self.AnsBase[19] + str.join(chr(10), ["%s. %s - %d (%d)" % (numb, name, used, desc) for numb, (used, desc, name) in enumerate(sorted(ls, reverse = True), 1)])
- Answer(answer, ltype, source, disp)
+ Answer(answer, stype, source, disp)
commands = (
(command_exc_info, "excinfo", 8,),
diff --git a/expansions/sheriff/code.py b/expansions/sheriff/code.py
index 09cf355..3a84dce 100644
--- a/expansions/sheriff/code.py
+++ b/expansions/sheriff/code.py
@@ -1,12 +1,10 @@
# coding: utf-8
# BlackSmith mark.2
-exp_name = "sheriff" # /code.py v.x7
-# Id: 15~5a
+# exp_name = "sheriff" # /code.py v.x7
+# Id: 15~5c
# Code © (2011) by WitcherGeralt [alkorgun@gmail.com]
-expansion_register(exp_name)
-
class expansion_temp(expansion):
def __init__(self, name):
@@ -53,7 +51,7 @@ class expansion_temp(expansion):
def addMsTime(self):
self.msdates.append(time.time())
- def command_order(self, ltype, source, body, disp):
+ def command_order(self, stype, source, body, disp):
def change_cfg(conf, Name, mode):
if mode in ("on", "1", "вкл".decode("utf-8")):
@@ -180,10 +178,10 @@ class expansion_temp(expansion):
answer += self.AnsBase[26][:-1]
else:
answer = AnsBase[0]
- Answer(answer, ltype, source, disp)
+ Answer(answer, stype, source, disp)
def spesial_kick(self, conf, nick, text):
- Chats[conf].kick(nick, "%s: %s" % (get_self_nick(conf), text))
+ Chats[conf].kick(nick, "%s: %s" % (get_nick(conf), text))
raise iThr.ThrKill("exit")
def sheriffs_loyalty(self, conf):
@@ -248,16 +246,16 @@ class expansion_temp(expansion):
if self.obscene_checker(nick):
self.spesial_kick(conf, nick, self.AnsBase[3])
- def sheriff_set(self, ltype, source, source_, access, loyalty, body, disp):
+ def sheriff_set(self, stype, source, source_, access, loyalty, body, disp):
if access <= loyalty:
prisoner = self.Federal_Jail[source[1]].get(source_)
if prisoner:
prisoner.offenses += 1
if prisoner.offenses in (1, 2):
- Answer(body, ltype, source, disp)
+ Answer(body, stype, source, disp)
raise iThr.ThrKill("exit")
elif prisoner.offenses == 3:
- Chats[source[1]].visitor(source[2], "%s: %s" % (get_self_nick(source[1]), body))
+ 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")
@@ -267,10 +265,10 @@ class expansion_temp(expansion):
else:
self.spesial_kick(source[1], source[2], body)
else:
- Answer(body, ltype, source, disp)
+ Answer(body, stype, source, disp)
raise iThr.ThrKill("exit")
- def Security_01eh(self, stanza, isConf, ltype, source, body, isToBs, disp):
+ def Security_01eh(self, stanza, isConf, stype, source, body, isToBs, disp):
if isConf and source[2] and Chats[source[1]].isModer:
source_ = get_source(source[1], source[2])
if source_:
@@ -286,13 +284,13 @@ class expansion_temp(expansion):
prisoner.SetDevoice()
self.spesial_kick(source[1], source[2], self.AnsBase[4])
else:
- Answer(self.AnsBase[4], ltype, source, disp)
+ Answer(self.AnsBase[4], stype, source, disp)
raise iThr.ThrKill("exit")
if ChatsAttrs[source[1]]["laws"]["verif"]:
- if access < 2 and prisoner.vakey and ltype == Types[0]:
+ if access < 2 and prisoner.vakey and stype == Types[0]:
if prisoner.vakey == body.lower():
prisoner.Autenticated()
- Chats[source[1]].participant(source[2], self.AnsBase[20] % get_self_nick(source[1]))
+ Chats[source[1]].participant(source[2], self.AnsBase[20] % get_nick(source[1]))
Message(source[0], self.AnsBase[21], disp)
elif prisoner.vnumb.plus() >= 3:
prisoner.vnumb = itypes.Number()
@@ -309,16 +307,16 @@ class expansion_temp(expansion):
else:
prisoner.msdates.pop(0)
del list
- if ltype == Types[1]:
+ if stype == Types[1]:
if ChatsAttrs[source[1]]["laws"]["obscene"]:
if self.obscene_checker(body):
- self.sheriff_set(ltype, source, source_, access, loyalty[1], self.AnsBase[5], disp)
+ self.sheriff_set(stype, source, source_, access, loyalty[1], self.AnsBase[5], disp)
if ChatsAttrs[source[1]]["laws"]["len"]:
if len(body) > ChatsAttrs[source[1]]["laws"]["len"]:
- self.sheriff_set(ltype, source, source_, access, loyalty[1], self.AnsBase[6], disp)
+ self.sheriff_set(stype, source, source_, access, loyalty[1], self.AnsBase[6], disp)
if ChatsAttrs[source[1]]["laws"]["lower"]:
if self.lower_checker(source[1], body):
- self.sheriff_set(ltype, source, source_, access, loyalty[1], self.AnsBase[7], disp)
+ self.sheriff_set(stype, source, source_, access, loyalty[1], self.AnsBase[7], disp)
def AwipeClear(self, conf, list):
if Chats.has_key(conf):
@@ -345,7 +343,7 @@ class expansion_temp(expansion):
def check_wipe(self, conf, nick, role, inst):
if role == aRoles[2]:
- BsNick = get_self_nick(conf)
+ BsNick = get_nick(conf)
if ChatsAttrs[conf]["laws"]["sparta"]:
jid = self.get_server(inst)
if jid not in self.GoodServers__(conf):
@@ -398,7 +396,7 @@ class expansion_temp(expansion):
Questions = []
def Security_04eh(self, conf, nick, source_, role, stanza, disp):
- if source_ and nick != get_self_nick(conf):
+ if source_ and nick != get_nick(conf):
access = get_access(conf, nick)
if access <= self.sheriffs_loyalty(conf)[1]:
prisoner = self.Federal_Jail[conf].get(source_)
@@ -407,7 +405,7 @@ class expansion_temp(expansion):
if prisoner.devoice:
eTime = prisoner.GetDevoice()
if (eTime < ChatsAttrs[conf]["laws"]["dtime"]):
- Chats[conf].visitor(nick, self.AnsBase[11] % get_self_nick(conf))
+ 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)
else:
prisoner.devoice = 0
@@ -419,7 +417,7 @@ class expansion_temp(expansion):
self.check_nick(conf, nick)
if ChatsAttrs[conf]["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_self_nick(conf))
+ Chats[conf].visitor(nick, self.AnsBase[17] % get_nick(conf))
if not self.Questions:
for qu in self.AnsBase[19].splitlines():
qu, an = qu.split(chr(124), 1)
@@ -449,7 +447,7 @@ class expansion_temp(expansion):
self.spesial_kick(conf, nick, self.AnsBase[9])
def Security_05eh(self, conf, nick, sbody, scode, disp):
- if nick != get_self_nick(conf):
+ if nick != get_nick(conf):
source_ = get_source(conf, nick)
if source_:
prisoner = self.Federal_Jail[conf].get(source_)
@@ -461,10 +459,10 @@ class expansion_temp(expansion):
if scode == sCodes[2] and prisoner.kicks.plus() >= ChatsAttrs[conf]["laws"]["aban"]:
if ChatsAttrs[conf]["laws"]["aban"]:
del self.Federal_Jail[conf][source_]
- Chats[conf].outcast(source_, self.AnsBase[10] % (get_self_nick(conf), ChatsAttrs[conf]["laws"]["aban"]))
+ Chats[conf].outcast(source_, self.AnsBase[10] % (get_nick(conf), ChatsAttrs[conf]["laws"]["aban"]))
def Security_06eh(self, conf, old_nick, nick, disp):
- if nick != get_self_nick(conf) and Chats[conf].isModer:
+ if nick != get_nick(conf) and Chats[conf].isModer:
sUser = Chats[conf].get_user(nick)
if getattr(sUser, "source", 0):
prisoner = self.Federal_Jail[conf].get(sUser.source)
@@ -481,7 +479,7 @@ class expansion_temp(expansion):
prisoner.prdates.pop(0)
def Security_07eh(self, conf, nick, role, disp):
- if nick != get_self_nick(conf):
+ if nick != get_nick(conf):
sUser = Chats[conf].get_user(nick)
if getattr(sUser, "source", 0):
prisoner = ((sUser.access <= self.sheriffs_loyalty(conf)[1]) and Chats[conf].isModer)
@@ -492,7 +490,7 @@ class expansion_temp(expansion):
self.Federal_Jail[conf][sUser.source] = self.rUser()
def Security_08eh(self, conf, nick, stanza, disp):
- if nick != get_self_nick(conf) and Chats[conf].isModer:
+ if nick != get_nick(conf) and Chats[conf].isModer:
source_ = get_source(conf, nick)
if source_:
prisoner = self.Federal_Jail[conf].get(source_)
diff --git a/expansions/talkers/code.py b/expansions/talkers/code.py
index 0663575..110002a 100644
--- a/expansions/talkers/code.py
+++ b/expansions/talkers/code.py
@@ -1,12 +1,10 @@
# coding: utf-8
# BlackSmith mark.2
-exp_name = "talkers" # /code.py v.x5
-# Id: 14~4b
+# exp_name = "talkers" # /code.py v.x5
+# Id: 14~4c
# Code © (2010-2012) by WitcherGeralt [alkorgun@gmail.com]
-expansion_register(exp_name)
-
class expansion_temp(expansion):
def __init__(self, name):
@@ -16,7 +14,7 @@ class expansion_temp(expansion):
TalkersDesc = {}
- def command_talkers(self, ltype, source, body, disp):
+ def command_talkers(self, stype, source, body, disp):
if Chats.has_key(source[1]):
if body:
ls = body.split()
@@ -187,10 +185,10 @@ class expansion_temp(expansion):
answer = AnsBase[1]
else:
answer = AnsBase[0]
- Answer(answer, ltype, source, disp)
+ Answer(answer, stype, source, disp)
- def calculate_talkers(self, stanza, isConf, ltype, source, body, isToBs, disp):
- if isConf and ltype == Types[1] and source[2]:
+ def calculate_talkers(self, stanza, isConf, stype, source, body, isToBs, disp):
+ if isConf and stype == Types[1] and source[2]:
source_ = get_source(source[1], source[2])
if source_:
nick = source[2].strip()
diff --git a/expansions/turn/code.py b/expansions/turn/code.py
index a4ca0b0..8ed9742 100644
--- a/expansions/turn/code.py
+++ b/expansions/turn/code.py
@@ -1,12 +1,10 @@
# coding: utf-8
# BlackSmith mark.2
-exp_name = "turn" # /code.py v.x2
-# Id: 21~2b
+# exp_name = "turn" # /code.py v.x2
+# Id: 21~2c
# Code © (2011) by WitcherGeralt [alkorgun@gmail.com]
-expansion_register(exp_name)
-
class expansion_temp(expansion):
def __init__(self, name):
@@ -17,7 +15,7 @@ class expansion_temp(expansion):
TurnBase = {}
- def command_turn(self, ltype, source, body, disp):
+ def command_turn(self, stype, source, body, disp):
def Turn(conf, body):
desc = {}
@@ -51,14 +49,14 @@ class expansion_temp(expansion):
answer = AnsBase[7]
else:
answer = AnsBase[0]
- if locals().has_key(Types[12]):
- Answer(answer, ltype, source, disp)
+ if locals().has_key(Types[6]):
+ Answer(answer, stype, source, disp)
- def collect_turnable(self, stanza, isConf, ltype, source, body, isToBs, disp):
- if isConf and ltype == Types[1] and source[2]:
+ def collect_turnable(self, stanza, isConf, stype, source, body, isToBs, disp):
+ if isConf and stype == Types[1] and source[2]:
source_ = get_source(source[1], source[2])
if source_:
- self.TurnBase[source[1]][source_] = (strTime("%H:%M:%S", False), body)
+ self.TurnBase[source[1]][source_] = (strfTime("%H:%M:%S", False), body)
def init_Turn_Base(self, conf):
self.TurnBase[conf] = {}
diff --git a/expansions/user_stats/code.py b/expansions/user_stats/code.py
index bdd3364..9b395f0 100644
--- a/expansions/user_stats/code.py
+++ b/expansions/user_stats/code.py
@@ -1,12 +1,10 @@
# coding: utf-8
# BlackSmith mark.2
-exp_name = "user_stats" # /code.py v.x6
-# Id: 17~5b
+# exp_name = "user_stats" # /code.py v.x6
+# Id: 17~5c
# Code © (2010-2012) by WitcherGeralt [alkorgun@gmail.com]
-expansion_register(exp_name)
-
class expansion_temp(expansion):
def __init__(self, name):
@@ -16,7 +14,7 @@ class expansion_temp(expansion):
UstatsDesc = {}
- def command_user_stats(self, ltype, source, body, disp):
+ def command_user_stats(self, stype, source, body, disp):
if Chats.has_key(source[1]):
if not body:
body = get_source(source[1], source[2])
@@ -36,9 +34,9 @@ class expansion_temp(expansion):
answer = self.AnsBase[3]
else:
answer = AnsBase[0]
- Answer(answer, ltype, source, disp)
+ Answer(answer, stype, source, disp)
- def command_here(self, ltype, source, nick, disp):
+ def command_here(self, stype, source, nick, disp):
if Chats.has_key(source[1]):
if not nick:
nick = source[2]
@@ -52,11 +50,11 @@ class expansion_temp(expansion):
answer = self.AnsBase[6]
else:
answer = AnsBase[0]
- Answer(answer, ltype, source, disp)
+ Answer(answer, stype, source, disp)
def calc_stat_04eh(self, conf, nick, instance, role, stanza, disp):
- if instance and nick != get_self_nick(conf):
- date, filename = strTime(local = False), cefile(chat_file(conf, self.UstatsFile))
+ if instance and nick != get_nick(conf):
+ date, filename = strfTime(local = False), cefile(chat_file(conf, self.UstatsFile))
with self.UstatsDesc[conf]:
with database(filename) as db:
db("select * from stat where jid=?", (instance,))
@@ -74,7 +72,7 @@ class expansion_temp(expansion):
db.commit()
def calc_stat_05eh(self, conf, nick, sbody, scode, disp):
- if nick != get_self_nick(conf):
+ if nick != get_nick(conf):
source_ = get_source(conf, nick)
if source_:
sbody = UnicodeType(sbody)
@@ -82,7 +80,7 @@ class expansion_temp(expansion):
sbody = "banned:(%s)" % (sbody)
elif scode == sCodes[2]:
sbody = "kicked:(%s)" % (sbody)
- date, filename = strTime(local = False), cefile(chat_file(conf, self.UstatsFile))
+ date, filename = strfTime(local = False), cefile(chat_file(conf, self.UstatsFile))
with self.UstatsDesc[conf]:
with database(filename) as db:
db("select * from stat where jid=?", (source_,))
@@ -92,7 +90,7 @@ class expansion_temp(expansion):
db.commit()
def calc_stat_06eh(self, conf, old_nick, nick, disp):
- if nick != get_self_nick(conf):
+ if nick != get_nick(conf):
source_ = get_source(conf, nick)
if source_:
filename = cefile(chat_file(conf, self.UstatsFile))
@@ -105,7 +103,7 @@ class expansion_temp(expansion):
db.commit()
def calc_stat_07eh(self, conf, nick, role, disp):
- if nick != get_self_nick(conf):
+ if nick != get_nick(conf):
source_ = get_source(conf, nick)
if source_:
filename = cefile(chat_file(conf, self.UstatsFile))
diff --git a/expansions/wtf/code.py b/expansions/wtf/code.py
index da3cf1d..55a199a 100644
--- a/expansions/wtf/code.py
+++ b/expansions/wtf/code.py
@@ -1,12 +1,10 @@
# coding: utf-8
# BlackSmith mark.2
-exp_name = "wtf" # /code.py v.x2
-# Id: 28~2b
+# exp_name = "wtf" # /code.py v.x2
+# Id: 28~2c
# Code © (2012) by WitcherGeralt [alkorgun@gmail.com]
-expansion_register(exp_name)
-
class expansion_temp(expansion):
def __init__(self, name):
@@ -15,7 +13,7 @@ class expansion_temp(expansion):
Base = dynamic % ("wtf.db")
ChatBase = "wtf.db"
- def command_wtf(self, ltype, source, body, disp):
+ def command_wtf(self, stype, source, body, disp):
if body:
ls = body.split(None, 1)
ar = (ls.pop(0)).lower()
@@ -98,7 +96,7 @@ class expansion_temp(expansion):
answer = self.AnsBase[-1] + str.join(chr(10), ls)
else:
answer = self.AnsBase[2]
- Answer(answer, ltype, source, disp)
+ Answer(answer, stype, source, disp)
sep = chr(61)
@@ -121,7 +119,7 @@ class expansion_temp(expansion):
answer = self.AnsBase[6] % (name)
return answer
- def command_def(self, ltype, source, body, disp):
+ def command_def(self, stype, source, body, disp):
if body:
ls = body.split(None, 1)
ar = (ls.pop(0)).lower()
@@ -160,7 +158,7 @@ class expansion_temp(expansion):
answer = self.AnsBase[10]
else:
answer = AnsBase[1]
- Answer(answer, ltype, source, disp)
+ Answer(answer, stype, source, disp)
def init_wtf_base(self):
if not os.path.isfile(self.Base):
diff --git a/librarys.zip b/librarys.zip
index 9720864..6be2302 100644
--- a/librarys.zip
+++ b/librarys.zip
Binary files differ