Module: ChatgptAssistant::Bots::Telegram::Validations
- Included in:
- TelegramBot
- Defined in:
- lib/chatgpt_assistant/bots/telegram/validations.rb
Instance Method Summary collapse
- #auth_event? ⇒ Boolean
- #telegram_actions? ⇒ Boolean
- #telegram_message_has_audio? ⇒ Boolean
- #telegram_message_has_text? ⇒ Boolean
- #telegram_text_or_audio? ⇒ Boolean
- #telegram_visited?(chat_id) ⇒ Boolean
- #user_confirmed? ⇒ Boolean
- #valid_for_list_action? ⇒ Boolean
- #visitor_user? ⇒ Boolean
Instance Method Details
#auth_event? ⇒ Boolean
45 46 47 |
# File 'lib/chatgpt_assistant/bots/telegram/validations.rb', line 45 def auth_event? msg.text.include?("login/") || msg.text.include?("register/") || msg.text.include?("sign_out/") || msg.text.include?("confirm/* ") end |
#telegram_actions? ⇒ Boolean
7 8 9 |
# File 'lib/chatgpt_assistant/bots/telegram/validations.rb', line 7 def telegram_actions? msg.text.include?("new_chat/") || msg.text.include?("sl_chat/") || msg.text.include?("login/") || msg.text.include?("register/") end |
#telegram_message_has_audio? ⇒ Boolean
19 20 21 |
# File 'lib/chatgpt_assistant/bots/telegram/validations.rb', line 19 def msg.audio.present? || msg.voice.present? end |
#telegram_message_has_text? ⇒ Boolean
15 16 17 |
# File 'lib/chatgpt_assistant/bots/telegram/validations.rb', line 15 def msg.text.present? end |
#telegram_text_or_audio? ⇒ Boolean
11 12 13 |
# File 'lib/chatgpt_assistant/bots/telegram/validations.rb', line 11 def telegram_text_or_audio? msg.respond_to?(:text) || msg.respond_to?(:audio) || msg.respond_to?(:voice) end |
#telegram_visited?(chat_id) ⇒ Boolean
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/chatgpt_assistant/bots/telegram/validations.rb', line 23 def telegram_visited?(chat_id) return unless msg visitor = Visitor.find_by(telegram_id: chat_id, name: msg.from.first_name) if visitor.nil? Visitor.create(telegram_id: chat_id, name: msg.from.first_name) else visitor end end |
#user_confirmed? ⇒ Boolean
49 50 51 |
# File 'lib/chatgpt_assistant/bots/telegram/validations.rb', line 49 def user_confirmed? user.name == name && user.confirm_account(token) end |
#valid_for_list_action? ⇒ Boolean
38 39 40 41 42 43 |
# File 'lib/chatgpt_assistant/bots/telegram/validations.rb', line 38 def valid_for_list_action? (chat_id: msg.chat.id, text: [:user_not_logged_in]) if user.nil? (chat_id: msg.chat.id, text: [:account_not_verified]) unless user.active? (chat_id: msg.chat.id, text: [:chat_not_found]) if user.chats.count.zero? && user.active? !user.nil? && user.active? && user.chats.count.positive? end |
#visitor_user? ⇒ Boolean
34 35 36 |
# File 'lib/chatgpt_assistant/bots/telegram/validations.rb', line 34 def visitor_user? visitor&.tel_user.nil? end |