2
2
3
3
API_ID = config ("API_ID" , default = None , cast = int )
4
4
API_HASH = config ("API_HASH" , default = None )
5
- SESSION = config ("SESSION " , default = None ) #pyro session
5
+ BOT_TOKEN = config ("BOT_TOKEN " , default = None )
6
6
AUTH = config ("AUTH" , default = None , cast = int )
7
7
8
8
import os , asyncio , logging
9
9
from pyrogram import Client , filters , idle
10
10
from pyrogram .types import ChatJoinRequest
11
11
from pyrogram .errors import FloodWait , MessageNotModified
12
12
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 )
18
14
19
15
logging .getLogger ("pyrogram" ).setLevel (logging .WARNING )
20
16
logging .basicConfig (
23
19
format = " %(asctime)s - [INDOAPPROVEBOT] >> %(levelname)s << %(message)s" ,
24
20
handlers = [logging .FileHandler ("indoapprovebot.log" ), logging .StreamHandler ()])
25
21
26
- @client .on_chat_join_request (filters .chat (chat_id ))
22
+ @bot_client .on_chat_join_request (filters .chat (chat_id ))
27
23
async def approve (c : Client , m : ChatJoinRequest ):
28
24
if not m .from_user :
29
25
return
@@ -34,9 +30,15 @@ async def approve(c: Client, m: ChatJoinRequest):
34
30
await asyncio .sleep (e .x + 2 )
35
31
await c .approve_chat_join_request (m .chat .id , m .from_user .id )
36
32
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 ()
41
42
42
- client .run ()
43
+ if __name__ == "__main__" :
44
+ bot_client .loop .run_until_complete (run_bot_ ())
0 commit comments