Module: ChatgptAssistant::Bots::Telegram::ChatActions
- Included in:
- TelegramBot
- Defined in:
- lib/chatgpt_assistant/bots/telegram/chat_actions.rb
Instance Method Summary collapse
Instance Method Details
#chat_if_exists ⇒ Object
7 8 9 10 |
# File 'lib/chatgpt_assistant/bots/telegram/chat_actions.rb', line 7 def chat_if_exists chat = Chat.find_by(user_id: user.id, id: user.current_chat_id) chat ? chat_success(chat.id) : (chat_id: msg.chat.id, text: [:no_chat_selected]) end |
#chat_success(chat_id) ⇒ Object
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/chatgpt_assistant/bots/telegram/chat_actions.rb', line 12 def chat_success(chat_id) = Message.new(chat_id: chat_id, content: msg.text, role: "user") if &.save text = chatter.chat(msg.text, chat_id, [:something_went_wrong]) mess = (text, 4096) mess.each { |m| m, msg.chat.id } else [:something_went_wrong], msg.chat.id end end |
#send_message(text, chat_id) ⇒ Object
23 24 25 26 |
# File 'lib/chatgpt_assistant/bots/telegram/chat_actions.rb', line 23 def (text, chat_id) = (text, 4096) .each { |m| bot.api.(chat_id: chat_id, text: m) } end |