Class: ChatgptAssistant::TelegramBot

Overview

This class is responsible for the telegram bot features

Instance Attribute Summary

Attributes inherited from ApplicationBot

#audio_url, #bot, #common_messages, #config, #database, #default_msg, #discord_client_id, #discord_prefix, #discord_token, #error_messages, #evnt, #help_messages, #mode, #openai_api_key, #success_messages, #telegram_token, #user

Instance Method Summary collapse

Methods included from Bots::Telegram::EventsController

#action_events, #auth_events, #text_events

Methods included from Bots::Telegram::Permissions

#audio_allowed?, #common_allowed?, #hist_allowed?, #list_allowed?, #register_allowed?, #select_allowed?

Methods included from Bots::Telegram::VoiceActions

#telegram_audio, #telegram_audio_info, #telegram_audio_url, #telegram_process_ai_voice, #telegram_send_voice_message

Methods included from Bots::Telegram::Validations

#auth_event?, #telegram_actions?, #telegram_message_has_audio?, #telegram_message_has_text?, #telegram_text_or_audio?, #telegram_visited?, #user_confirmed?, #valid_for_list_action?, #visitor_user?

Methods included from Bots::Telegram::ChatActions

#chat_if_exists, #chat_success, #send_message

Methods included from Bots::Telegram::Events

#audio_event, #confirm_account_event, #help_event, #hist_event, #list_event, #login_event, #new_chat_event, #register_event, #select_chat_event, #sign_out_event, #start_event, #telegram_chat_event

Methods included from Bots::Telegram::Actions

#chat_created_message, #telegram_create_chat, #telegram_send_start_message, #telegram_user_create

Methods included from Bots::Telegram::Auth

#authenticate_user, #telegram_user_access, #telegram_user_auth

Methods included from Bots::Telegram::Bot

#bot, #user

Methods inherited from ApplicationBot

#chatter, #initialize

Methods included from FileHelper

#delete_file

Methods included from SearchHelper

#find_user, #find_visitor, #where_user

Methods included from AudioHelper

#recognition, #synthesis, #transcribe_file

Methods included from MessengerHelper

#parse_message

Constructor Details

This class inherits a constructor from ChatgptAssistant::ApplicationBot

Instance Method Details

#startObject



16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/chatgpt_assistant/bots/telegram_bot.rb', line 16

def start
  bot.listen do |message|
    @msg = message
    @visitor = telegram_visited?(@msg.chat.id)
    next unless telegram_text_or_audio?

    text_events if telegram_message_has_text?
    audio_event if telegram_message_has_audio?
  end
rescue StandardError => e
  Error.create(message: e.message, backtrace: e.backtrace)
  retry
end