-
Notifications
You must be signed in to change notification settings - Fork 152
/
Copy pathbot.py
76 lines (67 loc) · 2.16 KB
/
bot.py
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
73
74
75
76
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# (c) Shrimadhav U K
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
""" MtProto Bot """
from pyrogram import (
Client,
__version__
)
from pyrogram.enums import ParseMode
from . import (
API_HASH,
APP_ID,
LOGGER,
TG_BOT_SESSION,
TG_BOT_TOKEN,
TG_BOT_WORKERS,
TG_SLEEP_THRESHOLD
)
from .user import User
class Bot(Client):
""" modded client for MessageDeletERoBot """
BOT_ID: int = None
USER: User = None
USER_ID: int = None
def __init__(self):
super().__init__(
name=TG_BOT_SESSION,
api_hash=API_HASH,
api_id=APP_ID,
plugins={
"root": "bot.plugins",
"exclude": [
"oatc"
]
},
workers=TG_BOT_WORKERS,
bot_token=TG_BOT_TOKEN,
sleep_threshold=TG_SLEEP_THRESHOLD,
parse_mode=ParseMode.HTML
)
self.LOGGER = LOGGER
async def start(self):
await super().start()
usr_bot_me = self.me
self.BOT_ID = usr_bot_me.id
self.LOGGER(__name__).info(
f"@{usr_bot_me.username} based on Pyrogram v{__version__} "
)
self.USER, self.USER_ID = await User().start()
# hack to get the entities in-memory
await self.USER.send_message(
usr_bot_me.username,
"join https://t.me/SpEcHlDe/857"
)
async def stop(self, *args):
await super().stop()
self.LOGGER(__name__).info("Bot stopped. Bye.")