def set_account(bot: Bot, update: Update):
"""
Handles /set_account command
:param bot:
:param update:
:return:
"""
global data
sender = update.message.from_user.id
data.change_account_queries[sender] = update.message.chat_id
msg = messages["ask_for_token"]
group_name = update.message.chat.title
if len(group_name) > 0:
msg += " for chat %s" % group_name
is_msg_sent = send_private_message(bot, user_id=sender, text=msg)
# Check if user already allowed bot to send private messages
if not is_msg_sent:
notify_start_private_chat(bot=bot,
chat_id=data.change_account_queries[sender],
incoming_message=update.message)
# If the bot is not used in a private chat, display a button allowing user to easily switch to the private chat
elif sender != data.change_account_queries[sender]:
keyboard = keyboards.switch_private_chat_keyboard(bot.username)
notify_send_token(bot=bot, is_group=True,
chat_id=data.change_account_queries[sender],
reply_to_message_id=update.message.message_id, group_name=group_name,
reply_markup=keyboard)
评论列表
文章目录