У меня есть две функции. Это сделано для того, чтобы бот распознал команду (например, «.say Hello World»)
Код: Выделить всё
@bot.command(pass_context=True, aliases=[])
@asyncio.coroutine
def say(context, *, msg):
yield from bot.say("```{0}```".format(rcon.rcon_say(msg)))
Код: Выделить всё
def rcon_say(_msg : str):
with RCON(SERVER_ADDRESS, PASSWORD) as rcon:
return rcon("say {0}".format(_msg))
Код: Выделить всё
say test
kick user1
Что я сделал, чтобы избежать злоупотреблений:
Я добавил следующую функцию:
Код: Выделить всё
def checkMsg(checkThis : str):
if ";" in checkThis:
raise errors.SemicolonError()
return
else:
return checkThis
Код: Выделить всё
_msg = checkMsg(_msg)
Я в безопасности или есть способ злоупотребить ею?
Подробнее здесь: https://stackoverflow.com/questions/391 ... tom-string
Мобильная версия