My server is a multilingual, so I would like to add a new command in a different language rules.
I added them to the configuration and wprzeklei?em admin_plugin.xml wyedytowa?em command and rules in admin.py
when you type! rules and nothing happens
Rules in english - works fine comands !rules, !r
(( in admin_plugin.xml
<set name="rule1">^3Rule ^2#1: No racism of any kind</set>
<set name="rule2">^3Rule ^2#2:^3 No arguing with admins (listen and learn or ^1leave^3)</set>
etc ))
def cmd_rules(self, data, client=None, cmd=None):
"""\
- say the rules
"""
if not self.aquireCmdLock(cmd, client, 60, True):
client.message('^7Do not spam commands')
return
m = self.parseUserCmd(data)
if m:
if client.maxLevel >= self.config.getint('settings', 'admins_level'):
sclient = self.findClientPrompt(m[0], client)
if not sclient:
return
if sclient.maxLevel >= client.maxLevel:
client.message('%s ^7already knows the rules' % sclient.exactName)
return
else:
client.message('^7Sir, Yes Sir!, spamming rules to %s' % sclient.exactName)
else:
client.message('^7Stop trying to spam other players')
return
elif cmd.loud:
thread.start_new_thread(self._sendRules, (None,))
return
else:
sclient = client
thread.start_new_thread(self._sendRules, (sclient,))
def _sendRules(self, sclient):
rules = []
for i in range(1, 20):
try:
rule = self.config.getTextTemplate('spamages', 'rule%s' % i)
rules.append(rule)
except:
break
if sclient:
for rule in rules:
sclient.message(rule)
time.sleep(1)
else:
for rule in rules:
self.console.say(rule)
time.sleep(1)
Rules in Polish - commands !zasady !z
(( in admin_plugin.xml
<set name="zasada1"> TEXT1</set>
<set name="zasada2">TEXT2</set> ))
def cmd_zasady(self, data, client=None, cmd=None):
"""\
- say the zasady
"""
if not self.aquireCmdLock(cmd, client, 60, True):
client.message('^7Do not spam commands')
return
m = self.parseUserCmd(data)
if m:
if client.maxLevel >= self.config.getint('settings', 'admins_level'):
sclient = self.findClientPrompt(m[0], client)
if not sclient:
return
if sclient.maxLevel >= client.maxLevel:
client.message('%s ^7juz znasz wszystkie zasady' % sclient.exactName)
return
else:
client.message('^7Sir, Tak jest!, spamuje zasady %s' % sclient.exactName)
else:
client.message('^7Przestan spamowac zasady innym gracza')
return
elif cmd.loud:
thread.start_new_thread(self._sendZasady, (None,))
return
else:
sclient = client
thread.start_new_thread(self._sendZasady, (sclient,))
def _sendZasady(self, sclient):
zasady = []
for i in range(1, 10):
try:
zasada = self.config.getTextTemplate('spamages', 'zasada', 'zasady' % i)
zasady.append(zasada)
except:
break
if sclient:
for zasada in zasady:
sclient.message(zasada)
time.sleep(1)
else:
for zasada in zasady:
self.console.say(zasada)
time.sleep(1)
Could someone correct the possible error in the code?