wm: soxangoo-bot

Download patch

ref: 74ca96eacd016d656157660a289c9d68fcb18db1
parent: c7c39ce29db8631d72f3d5c5b73c04751e0d67e5
author: jm <scorpion_rn@yahoo.com>
date: Mon Jan 15 08:16:26 EST 2024

Token Removed

--- a/main.rb
+++ b/main.rb
@@ -1,12 +1,12 @@
 require "openai"
-require 'telegram/bot'
+require "telegram/bot"
 
 BOTID = "Soxangoo_bot"
 ADMIN = 331358784
 
-@silent = false
-@token = "6449806349:AAER7n4sp9fZSlUfb_d4g3m-ZziNTWL25Fk"
-@client = OpenAI::Client.new(access_token: "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")
+$silent = false
+$token = "Your-Telegram-Bot-Token"
+$client = OpenAI::Client.new(access_token: "Your-OpenAI-Key")
 
 Signal.trap('INT') do
   bot.stop
@@ -13,7 +13,7 @@
 end
 
 def SendChat(message)
-  response = @client.chat(
+  response = $client.chat(
     parameters: {
       model: "gpt-3.5-turbo",
       messages: [{ role: "system", content: message}],
@@ -25,11 +25,11 @@
 def CheckAdmin?(id, message)
   if (id == ADMIN) then
     if (message.eql?("off"))
-      @silent = true
+      $silent = true
       return true
     end
     if (message.eql?("on"))
-      @silent = false
+      $silent = false
       return true
     end
   end
@@ -36,7 +36,7 @@
   return false
 end
 
-Telegram::Bot::Client.run(@token) do |bot|
+Telegram::Bot::Client.run($token) do |bot|
   bot.listen do |message|
     case message
     when Telegram::Bot::Types::Message
@@ -43,7 +43,7 @@
       if message.text.is_a?(String) then
         received_message = message.text;
         begin
-          if (!@silent) || message.from.id == ADMIN then
+          if (!$silent) || message.from.id == ADMIN then
             # GP Message
             if message.chat.type.eql?("supergroup") then
               # Replied Message
@@ -64,7 +64,7 @@
                 bot.api.send_message(chat_id: message.chat.id, reply_to_message_id: message.message_id, text: "#{response['choices'][0]['message']['content']}", parse_mode: 'Markdown');
 
               end
-            # PV Message
+              # PV Message
             elsif message.chat.type.eql?("private") then
               if (CheckAdmin?(message.chat.id, received_message))
                 return
@@ -85,5 +85,4 @@
     end
   end
 end
-