61 lines
1.1 KiB
Python
61 lines
1.1 KiB
Python
|
|
|
|
# Isengard commands
|
|
|
|
def cmdping(owners, nick, text, sbuf):
|
|
"""
|
|
Ping command.
|
|
"""
|
|
|
|
return "pong !"
|
|
|
|
|
|
def cmdmainteneur(owners, nick, text, sbuf):
|
|
"""
|
|
Change maintainer for an host
|
|
"""
|
|
|
|
if not nick in owners:
|
|
return "désolé mais vous n'êtes pas autorisé à utiliser cette commande."
|
|
|
|
try:
|
|
splittedtext = text.split(" ")
|
|
|
|
# print maintainer
|
|
if len(splittedtext) == 2:
|
|
host = splittedtext[1]
|
|
|
|
return "le responsable de cette machine est " \
|
|
+ sbuf.buf[host]["maintainer"]
|
|
|
|
if len(splittedtext) == 3:
|
|
host = splittedtext[1]
|
|
maintainer = splittedtext[2]
|
|
|
|
sbuf.buf[host]["maintainer"] = maintainer
|
|
|
|
return "le responsable est à présent " \
|
|
+ sbuf.buf[host]["maintainer"]
|
|
|
|
except Exception as e:
|
|
print(repr(e))
|
|
return "Erreur à l'exécution"
|
|
|
|
return "Syntaxe invalide"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Commands
|
|
|
|
commandtable = {
|
|
|
|
"ping" : cmdping,
|
|
"mainteneur" : cmdmainteneur,
|
|
|
|
}
|
|
|
|
|