Create bot.py
Browse files- stylish/bot.py +46 -0
stylish/bot.py
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
# souce : https://raw.githubusercontent.com/levina-lab/guard-bot/guard/eduu/bot.py
|
3 |
+
|
4 |
+
import time
|
5 |
+
import logging
|
6 |
+
|
7 |
+
import pyrogram
|
8 |
+
from pyrogram import Client
|
9 |
+
from pyrogram.enums import ParseMode
|
10 |
+
from pyrogram.errors import BadRequest
|
11 |
+
from pyrogram.raw.all import layer
|
12 |
+
|
13 |
+
from config import Config
|
14 |
+
logger = logging.getLogger(__name__)
|
15 |
+
|
16 |
+
|
17 |
+
class Stylish(Client):
|
18 |
+
def __init__(self):
|
19 |
+
name = self.__class__.__name__.lower()
|
20 |
+
|
21 |
+
super().__init__(
|
22 |
+
name=name,
|
23 |
+
app_version=f"stylish latest",
|
24 |
+
api_id=Config.API_ID,
|
25 |
+
api_hash=Config.API_HASH,
|
26 |
+
bot_token=Config.BOT_TOKEN,
|
27 |
+
workers=Config.WORKERS,
|
28 |
+
plugins=dict(root="stylish.modules"),
|
29 |
+
sleep_threshold=180,
|
30 |
+
)
|
31 |
+
|
32 |
+
async def start(self):
|
33 |
+
await super().start()
|
34 |
+
|
35 |
+
self.start_time = time.time()
|
36 |
+
|
37 |
+
logger.info(
|
38 |
+
"stylish running with Pyrogram v%s (Layer %s) started on @%s. Hi!",
|
39 |
+
pyrogram.__version__,
|
40 |
+
layer,
|
41 |
+
self.me.username,
|
42 |
+
)
|
43 |
+
|
44 |
+
async def stop(self):
|
45 |
+
await super().stop()
|
46 |
+
logger.warning("Stylish stopped, Bye!")
|