def set_timeout(bot: Bot, update: Update, args):
"""
Handles /timeout command
:param bot:
:param update:
:param args:
:return:
"""
global data
chat_id = update.message.chat_id
if chat_id in data.conversations:
if len(args) != 1:
timeout = str(data.conversations[chat_id].timeout)
message = "Current timeout %s seconds." % timeout
send_custom_message(bot, chat_id, message=message)
else:
try:
timeout = int(args[0])
settings = data.conversations[chat_id].settings
if int(settings.get_setting("min_timeout")) <= timeout <= int(
settings.get_setting("max_timeout")):
data.conversations[chat_id].timeout = timeout
message = "Timeout updated to %d seconds." % data.conversations[chat_id].timeout
send_custom_message(bot, chat_id, message=message)
else:
send_custom_message(bot, chat_id, "Timeout out of range: "
+ str(settings.get_setting("min_timeout")) + "-"
+ str(settings.get_setting("max_timeout")))
except AttributeError:
message = "An error happened."
send_custom_message(bot, chat_id, message=message)
except BaseException:
message = "An error happened."
send_custom_message(bot, chat_id, message=message)
else:
send_error(bot=bot, chat_id=chat_id, name="account_not_setup")
评论列表
文章目录