def do_login(bot: Bot, chat_id: str, sender: str, token: str, job_queue: JobQueue):
from bot_app.model import Conversation
global data
try:
# Notify this is going to take some time
# In groups
if data.change_account_queries[sender] != sender:
bot.sendChatAction(chat_id=chat_id, action=ChatAction.TYPING)
# In private chat
bot.sendChatAction(chat_id=chat_id, action=ChatAction.TYPING)
# Create Tinder session
session = Session(token)
if session.do_connect():
message = "Switching to %s's account." % session.get_profile_name()
messages.send_custom_message(bot=bot, message=message, chat_id=data.change_account_queries[sender])
if sender != data.change_account_queries[sender]:
# group_name = bot.getChat(chat_id=data.change_account_queries[sender]).title
bot.sendMessage(chat_id=sender,
text=message,
reply_markup=keyboards.switch_group_keyboard())
# Create conversation
conversation = Conversation(data.change_account_queries[sender], session, sender)
data.conversations[data.change_account_queries[sender]] = conversation
del data.change_account_queries[sender]
# Launch get matches background job
cache_time = int(conversation.settings.get_setting("matches_cache_time"))
job = Job(job_refresh_matches, cache_time + 1, repeat=True, context=conversation)
job_queue.put(job, next_t=0.0)
else:
messages.send_error(bot=bot, chat_id=chat_id, name="auth_failed")
except BaseException:
messages.send_error(bot=bot, chat_id=chat_id, name="auth_failed")
评论列表
文章目录