Tes web domain in DB

This commit is contained in:
yasirarism 2023-05-26 06:17:31 +00:00 committed by GitHub
parent 0bf8595132
commit fd1960a38e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 7 additions and 3 deletions

View file

@ -3,6 +3,7 @@ from logging import ERROR, INFO, StreamHandler, basicConfig, getLogger, handlers
from apscheduler.jobstores.mongodb import MongoDBJobStore from apscheduler.jobstores.mongodb import MongoDBJobStore
from apscheduler.schedulers.asyncio import AsyncIOScheduler from apscheduler.schedulers.asyncio import AsyncIOScheduler
from database import dbname
from motor.motor_asyncio import AsyncIOMotorClient from motor.motor_asyncio import AsyncIOMotorClient
from pymongo import MongoClient from pymongo import MongoClient
from pyrogram import Client from pyrogram import Client
@ -49,7 +50,7 @@ user = Client(
jobstores = {"default": MongoDBJobStore(client=pymonclient, database=DATABASE_NAME, collection="nightmode")} jobstores = {"default": MongoDBJobStore(client=pymonclient, database=DATABASE_NAME, collection="nightmode")}
scheduler = AsyncIOScheduler(jobstores=jobstores, timezone=TZ) scheduler = AsyncIOScheduler(jobstores=jobstores, timezone=TZ)
app.start() app.start()
BOT_ID = app.me.id BOT_ID = app.me.id
BOT_NAME = app.me.first_name BOT_NAME = app.me.first_name

View file

@ -72,6 +72,10 @@ async def start_bot():
except Exception as e: except Exception as e:
LOGGER.error(str(e)) LOGGER.error(str(e))
scheduler.start() scheduler.start()
if "web" not in await dbname.list_collection_names():
for key, value in web.items():
webdb = dbname.web
await webdb.insert_one({key: value})
if os.path.exists("restart.pickle"): if os.path.exists("restart.pickle"):
with open('restart.pickle', 'rb') as status: with open('restart.pickle', 'rb') as status:
chat_id, message_id = pickle.load(status) chat_id, message_id = pickle.load(status)

View file

@ -31,7 +31,7 @@ async def chatbot(self: Client, ctx: Message, strings):
num = 0 num = 0
answer = "" answer = ""
try: try:
response = await openai.ChatCompletion.acreate(model="gpt-3.5-turbo", messages=[{"role": "user", "content": pertanyaan}], temperature=0.2, stream=True) response = await openai.ChatCompletion.acreate(model="gpt-3.5-turbo", messages=[{"role": "user", "content": pertanyaan}], temperature=0.7, stream=True)
async for chunk in response: async for chunk in response:
if not chunk.choices[0].delta or chunk.choices[0].delta.get("role"): if not chunk.choices[0].delta or chunk.choices[0].delta.get("role"):
continue continue

View file

@ -55,7 +55,6 @@ web = {
"oplovers": "https://oploverz.top", "oplovers": "https://oploverz.top",
} }
def split_arr(arr, size: 5): def split_arr(arr, size: 5):
arrs = [] arrs = []
while len(arr) > size: while len(arr) > size: