File size: 2,003 Bytes
6fafed4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f1b0681
 
6fafed4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b2cedde
6fafed4
 
 
0e93b33
 
 
2dee48c
0e93b33
6fafed4
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import asyncio
import logging
import time
import pyrogram
import string
import random
import requests
from inspect import getfullargspec
from os import path
from random import choice
import aiohttp
import re
import os
from datetime import datetime as dt
from pyrogram import Client
from pyrogram.types import *
from pyrogram import filters
from pyrogram.errors import *
from pyrogram.raw.all import layer
from pyrogram.handlers import MessageHandler
from config import API_HASH, API_ID, BOT_TOKEN
from database import db
from logger import LOGS
from platform import python_version
from pyrogram import __version__ as pyrogram_version

StartTime = time.time()
START_TIME = dt.now()

def send_log(text_log: str):
    url = "https://private-akeno.randydev.my.id/api/v2/send_message_logs"
    params = {
        "text_log": text_log
    }
    response = requests.post(url, params=params)
    if response.status_code != 200:
        return None
    return response.json()["message"]

class Randydev(Client):
    def __init__(self, loop=None):
        self.loop = loop or asyncio.get_event_loop()

        super().__init__(
            "chatbotai",
            app_version=f"akeno ai latest",
            api_id=API_ID,
            api_hash=API_HASH,
            bot_token=BOT_TOKEN,
            workers=300,
            plugins=dict(root="chatbot.plugins"),
            sleep_threshold=180,
        )
    async def start(self):
        try:
            await super().start()
        except FloodWait as e:
            LOGS.debug(e.value)
            await asyncio.sleep(e.value)
        self.start_time = time.time()
        LOGS.info(
            "akn running with Pyrogram v%s (Layer %s) started on @%s. Hi!",
            pyrogram.__version__,
            layer,
            self.me.username,
        )
    async def stop(self):
        try:
            await super().stop()
            LOGS.warning("akn stopped, Bye!")
        except ConnectionError:
            LOGS.warning("akn is already terminated")