Skip to content

Commit 854729b

Browse files
authored
Update main.py
1 parent d31480b commit 854729b

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

main.py

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,15 @@
22

33
API_ID = config("API_ID", default=None, cast=int)
44
API_HASH = config("API_HASH", default=None)
5-
SESSION = config("SESSION", default=None) #pyro session
5+
BOT_TOKEN = config("BOT_TOKEN", default=None)
66
AUTH = config("AUTH", default=None, cast=int)
77

88
import os, asyncio, logging
99
from pyrogram import Client, filters, idle
1010
from pyrogram.types import ChatJoinRequest
1111
from pyrogram.errors import FloodWait, MessageNotModified
1212

13-
client = Client(
14-
session_name=SESSION,
15-
api_hash=API_HASH,
16-
api_id=API_ID)
17-
13+
bot_client = Client("APPROVEBOT", bot_token=BOT_TOKEN, api_id=API_ID, api_hash=API_HASH)
1814

1915
logging.getLogger("pyrogram").setLevel(logging.WARNING)
2016
logging.basicConfig(
@@ -23,7 +19,7 @@
2319
format=" %(asctime)s - [INDOAPPROVEBOT] >> %(levelname)s << %(message)s",
2420
handlers=[logging.FileHandler("indoapprovebot.log"), logging.StreamHandler()])
2521

26-
@client.on_chat_join_request(filters.chat(chat_id))
22+
@bot_client.on_chat_join_request(filters.chat(chat_id))
2723
async def approve(c: Client, m: ChatJoinRequest):
2824
if not m.from_user:
2925
return
@@ -34,9 +30,15 @@ async def approve(c: Client, m: ChatJoinRequest):
3430
await asyncio.sleep(e.x + 2)
3531
await c.approve_chat_join_request(m.chat.id, m.from_user.id)
3632

37-
@client.on_message(filters.user(AUTH))
38-
async def alive(c, m):
39-
if m.text == '!alive':
40-
await m.reply_text("I'm alive!")
33+
@bot_client.on_message(filters.user(AUTH))
34+
async def well_yes(c, m):
35+
await m.reply_text(f"{c.my_bot.username} is alive!")
36+
37+
async def run_bot_():
38+
await bot_client.start()
39+
bot_client.my_bot = await bot_client.get_me()
40+
logging.log(f"Started bot as : {bot_client.my_bot.username}")
41+
await idle()
4142

42-
client.run()
43+
if __name__ == "__main__":
44+
bot_client.loop.run_until_complete(run_bot_())

0 commit comments

Comments
 (0)