TheHamkerCat 2 jaren geleden
bovenliggende
commit
c795cc1c01
3 gewijzigde bestanden met toevoegingen van 37 en 8 verwijderingen
  1. 3 6
      wbb/__init__.py
  2. 2 2
      wbb/modules/quotly.py
  3. 32 0
      wbb/modules/userbot.py

+ 3 - 6
wbb/__init__.py

@@ -103,24 +103,21 @@ loop.run_until_complete(load_sudoers())
 
 if not SESSION_STRING:
     app2 = Client(
-        name="userbot",
+        name="sessions/userbot",
         api_id=API_ID,
         api_hash=API_HASH,
         phone_number=PHONE_NUMBER,
     )
 else:
     app2 = Client(
-        name="userbot",
-        api_id=API_ID,
-        api_hash=API_HASH,
-        session_string=SESSION_STRING,
+        name="sessions/userbot", api_id=API_ID, api_hash=API_HASH, session_string=SESSION_STRING
     )
 
 aiohttpsession = ClientSession()
 
 arq = ARQ(ARQ_API_URL, ARQ_API_KEY, aiohttpsession)
 
-app = Client("wbb", bot_token=BOT_TOKEN, api_id=API_ID, api_hash=API_HASH)
+app = Client("sessions/wbb", bot_token=BOT_TOKEN, api_id=API_ID, api_hash=API_HASH)
 
 log.info("Starting bot client")
 app.start()

+ 2 - 2
wbb/modules/quotly.py

@@ -122,8 +122,8 @@ async def quotly_func(client, message: Message):
             "Incorrect argument, check quotly module in help section."
         )
     try:
-        if not message:
-            return await m.edit("Something went wrong.")
+        #if not message:
+        #    return await m.edit("Something went wrong.")
 
         sticker = await quotify(messages)
         if not sticker[0]:

+ 32 - 0
wbb/modules/userbot.py

@@ -230,6 +230,38 @@ async def shellrunner(_, message: Message):
             text=f"**INPUT:**\n```{escape(text)}```\n\n**OUTPUT: **\n`No output`",
         )
 
+HISTORY = [
+        {"role": "system", "content": "You are a human, behave and response like a human, don't behave like a bot because you are not an ai bot.\n\nAlways end a message with a question or new topic"}
+    ]
+from wbb.utils.http import post
+from asyncio import sleep
+
+@app2.on_message(
+        filters.chat([-1002139890459, "thehamkercat"])
+        & filters.text
+)
+async def asd_temp(_, message: Message):
+    if (message.from_user.username or "").lower() in ["thehamkercat", "jojiiofficial"]:
+        return
+    text = message.text
+
+    HISTORY.append({"role": "user", "content": text})
+
+    response = await post(
+             "http://localhost:1234/v1/chat/completions",
+             headers={"Content-Type": "application/json"},
+             json={
+                 "messages": HISTORY,
+                  "temperature": 0.7, 
+                  "max_tokens": -1,
+                  "stream": False,
+                }
+            )
+    resp_text = response['choices'][0]['message']['content']
+    HISTORY.append({"role": "assistant", "content": resp_text})
+    await sleep(10)
+    return await message.reply(resp_text)
+
 
 @app2.on_message(
     filters.command("reserve", prefixes=USERBOT_PREFIX)