Class: OpenAIBot

Inherits:
Rubydium::Bot
  • Object
show all
Includes:
ConfigMenu, OpenAI::ChatGPT, OpenAI::Dalle, OpenAI::Utils, OpenAI::Whisper
Defined in:
lib/open_ai_bot.rb

Direct Known Subclasses

MyCustomBot

Instance Method Summary collapse

Methods included from ConfigMenu

#config_menu, #handle_config_query, #handle_model_query, included, #model_selection_menu

Methods included from OpenAI::Whisper

#ogg_to_mp3, #send_whisper_error, #send_whisper_request, #send_whisper_response, #transcribe

Methods included from OpenAI::Utils

#attempt, #download_file

Methods included from OpenAI::Dalle

#dalle

Methods included from OpenAI::ChatGPT

#current_thread, #get_tokens_info!, #handle_gpt_command, included, #init_session, #send_chat_gpt_error, #send_chat_gpt_response, #send_request!, #username

Instance Method Details

#allowed_chat?Boolean

Returns:

  • (Boolean)


53
54
55
56
57
58
59
60
# File 'lib/open_ai_bot.rb', line 53

def allowed_chat?
  return true if @user.username == config.owner_username
  return true if config.open_ai["whitelist"].include?(@chat.id)
  return true if config.open_ai["allow_all_private_chats"] && @chat.id.positive?
  return true if config.open_ai["allow_all_group_chats"] && @chat.id.negative?

  false
end

#chat_not_allowed_messageObject



62
63
64
65
# File 'lib/open_ai_bot.rb', line 62

def chat_not_allowed_message
  # Return false/nil (leave method empty) to ignore
  # "This chat (`#{@chat.id}`) is not whitelisted for ChatGPT usage. Ask @#{config.owner_username}."
end

#session_restart_messageObject



67
68
69
# File 'lib/open_ai_bot.rb', line 67

def session_restart_message
  "Bot's context reset."
end