1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-23 19:44:20 +00:00

Don't shadow help()

This commit is contained in:
Steffo 2017-03-14 14:02:10 +01:00
parent 1da79e6fc0
commit 5da6d7f778

View file

@ -84,16 +84,23 @@ Sintassi: `/markov [inizio]`"""
file.close() file.close()
if len(arguments) == 0: if len(arguments) == 0:
# Generate a sentence with a random start # Generate a sentence with a random start
# TODO: the generator sometimes returns None? text = generator.make_sentence(tries=50)
text = generator.make_sentence()
else: else:
# Generate a sentence with a specific start # Generate a sentence with a specific start
start = " ".join(arguments) start = " ".join(arguments)
text = generator.make_sentence_with_start(start) try:
await update.message.reply(bot, f"*Frase generata:*\n{text}", parse_mode="Markdown", tries=50) text = generator.make_sentence_with_start(start, tries=100)
# No entry can start in that word.
except KeyError:
await update.message.reply(bot, f"⚠ Non sono state trovate corrispondenze nel diario dell'inizio che hai specificato.", parse_mode="Markdown")
return
if text is not None:
await update.message.reply(bot, f"*Frase generata:*\n{text}", parse_mode="Markdown")
else:
await update.message.reply(bot, f"⚠ Il bot non è riuscito a generare una nuova frase.\nSe è la prima volta che vedi questo errore, riprova, altrimenti prova a cambiare configurazione.")
async def help(bot, update, arguments): async def help_cmd(bot, update, arguments):
"""Visualizza la descrizione di un comando. """Visualizza la descrizione di un comando.
Sintassi: `/help [comando]`""" Sintassi: `/help [comando]`"""
@ -194,7 +201,7 @@ if __name__ == "__main__":
b.commands["discord"] = discord b.commands["discord"] = discord
b.commands["sync"] = sync b.commands["sync"] = sync
b.commands["changepassword"] = changepassword b.commands["changepassword"] = changepassword
b.commands["help"] = help b.commands["help"] = help_cmd
b.commands["markov"] = markov b.commands["markov"] = markov
print("Bot started!") print("Bot started!")
b.run() b.run()