Create generator.py
Browse files- generator.py +31 -0
generator.py
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import logging
|
2 |
+
from pyromod import listen
|
3 |
+
from pyrogram import Client, idle
|
4 |
+
from pyrogram.errors import ApiIdInvalid, ApiIdPublishedFlood, AccessTokenInvalid
|
5 |
+
from config import *
|
6 |
+
|
7 |
+
logging.basicConfig(
|
8 |
+
level=logging.WARNING, format="%(asctime)s - %(name)s - %(levelname)s - %(message)s"
|
9 |
+
)
|
10 |
+
logging.getLogger("pyrogram").setLevel(logging.WARNING)
|
11 |
+
|
12 |
+
app = Client(
|
13 |
+
"stringolds",
|
14 |
+
api_id=API_ID,
|
15 |
+
api_hash=API_HASH,
|
16 |
+
bot_token=BOT_TOKEN,
|
17 |
+
plugins=dict(root="StringSessionBot"),
|
18 |
+
)
|
19 |
+
|
20 |
+
if __name__ == "__main__":
|
21 |
+
try:
|
22 |
+
app.start()
|
23 |
+
except (ApiIdInvalid, ApiIdPublishedFlood):
|
24 |
+
raise Exception("Your API_ID/API_HASH is not valid.")
|
25 |
+
except AccessTokenInvalid:
|
26 |
+
raise Exception("Your BOT_TOKEN is not valid.")
|
27 |
+
uname = app.get_me().username
|
28 |
+
print(f"@{uname} Started Successfully!")
|
29 |
+
idle()
|
30 |
+
app.stop()
|
31 |
+
print("Bot stopped!")
|