You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
text: "🎉 Account linked successfully! Welcome to SplitMySub, #{user.first_name}!\n\nYou can now receive payment reminders and manage your subscriptions through this bot.\n\nType /help to see available commands."
161
-
)
129
+
# Check if this Telegram account is already linked to someone else
text: "⚠️ This Telegram account is already linked to another SplitMySub account.\n\nIf you want to link it to a different account, please first unlink it from your current account in the profile settings, then try again."
136
+
)
137
+
return
138
+
end
139
+
140
+
# Link the account (or update if already linked to same user)
141
+
begin
142
+
user.update!(
143
+
telegram_user_id: chat_id.to_s,
144
+
telegram_username: user_info["username"],
145
+
telegram_verification_token: nil,
146
+
telegram_verification_token_expires_at: nil
147
+
)
148
+
149
+
send_message(
150
+
chat_id: chat_id,
151
+
text: "🎉 Account linked successfully! Welcome to SplitMySub, #{user.first_name}!\n\nYou can now receive payment reminders and manage your subscriptions through this bot.\n\nType /help to see available commands."
152
+
)
153
+
rescueActiveRecord::RecordInvalid=>e
154
+
Rails.logger.error"Failed to link Telegram account: #{e.message}"
155
+
send_message(
156
+
chat_id: chat_id,
157
+
text: "❌ Unable to link account due to a validation error. Please try generating a new verification token from your profile settings."
Rails.logger.info"Payment confirmed via Telegram by user #{user.id} for project #{project.id}"
351
352
end
352
353
354
+
defhandle_unlink_command(user,chat_id)
355
+
# Store user name for goodbye message
356
+
user_name=user.first_name
357
+
358
+
# Unlink the account directly
359
+
user.unlink_telegram_account!
360
+
361
+
send_message(
362
+
chat_id: chat_id,
363
+
text: "🔓 <b>Account Unlinked</b>\n\nGoodbye #{user_name}! Your Telegram account has been successfully unlinked from SplitMySub.\n\n📱 To re-link in the future:\n1. Go to your SplitMySub profile settings\n2. Generate a new verification token\n3. Send /start [token] to this bot\n\nThank you for using SplitMySub! 👋",
364
+
parse_mode: "HTML"
365
+
)
366
+
367
+
Rails.logger.info"Telegram account unlinked via bot by user #{user.id}"
0 commit comments