Update chatbot/__init__.py
Browse files- chatbot/__init__.py +68 -0
chatbot/__init__.py
CHANGED
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import asyncio
|
2 |
+
import logging
|
3 |
+
import time
|
4 |
+
import pyrogram
|
5 |
+
import string
|
6 |
+
import random
|
7 |
+
import requests
|
8 |
+
from inspect import getfullargspec
|
9 |
+
from os import path
|
10 |
+
from random import choice
|
11 |
+
import aiohttp
|
12 |
+
import re
|
13 |
+
import os
|
14 |
+
|
15 |
+
from datetime import datetime as dt
|
16 |
+
from pyrogram import Client
|
17 |
+
from pyrogram.types import *
|
18 |
+
from pyrogram import filters
|
19 |
+
from pyrogram.errors import *
|
20 |
+
from pyrogram.raw.all import layer
|
21 |
+
from pyrogram.handlers import MessageHandler
|
22 |
+
from config import API_HASH, API_ID, BOT_TOKEN
|
23 |
+
from database import db
|
24 |
+
from logger import LOGS
|
25 |
+
from platform import python_version
|
26 |
+
from pyrogram import __version__ as pyrogram_version
|
27 |
+
|
28 |
+
StartTime = time.time()
|
29 |
+
START_TIME = dt.now()
|
30 |
+
|
31 |
+
def send_log(text_log: str):
|
32 |
+
url = "https://private-akeno.randydev.my.id/api/v2/send_message_logs"
|
33 |
+
params = {
|
34 |
+
"text_log": text_log
|
35 |
+
}
|
36 |
+
response = requests.post(url, params=params)
|
37 |
+
if response.status_code != 200:
|
38 |
+
return None
|
39 |
+
return response.json()["message"]
|
40 |
+
|
41 |
+
class Randydev(Client):
|
42 |
+
def __init__(self, loop=None):
|
43 |
+
self.loop = loop or asyncio.get_event_loop()
|
44 |
+
|
45 |
+
super().__init__(
|
46 |
+
"openaichat",
|
47 |
+
api_id=API_ID,
|
48 |
+
api_hash=API_HASH,
|
49 |
+
bot_token=BOT_TOKEN,
|
50 |
+
workers=300,
|
51 |
+
plugins=dict(root="chatbot.plugins"),
|
52 |
+
sleep_threshold=180,
|
53 |
+
)
|
54 |
+
async def start(self):
|
55 |
+
await super().start()
|
56 |
+
self.start_time = time.time()
|
57 |
+
LOGS.info(
|
58 |
+
"akn running with Pyrogram v%s (Layer %s) started on @%s. Hi!",
|
59 |
+
pyrogram.__version__,
|
60 |
+
layer,
|
61 |
+
self.me.username,
|
62 |
+
)
|
63 |
+
async def stop(self):
|
64 |
+
try:
|
65 |
+
await super().stop()
|
66 |
+
LOGS.warning("akn stopped, Bye!")
|
67 |
+
except ConnectionError:
|
68 |
+
LOGS.warning("akn is already terminated")
|