Meta-AI / chatbot /__init__.py
randydev's picture
Update chatbot/__init__.py
bc87a54 verified
import asyncio
import logging
import time
import pyrogram
import string
import random
import requests
import aiohttp
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()
class Randydev(Client):
def __init__(self, loop=None):
self.loop = loop or asyncio.get_event_loop()
super().__init__(
"openaichat",
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:
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")