1
1
from pyrogram import filters
2
- from pyrogram .types import InlineKeyboardMarkup , InlineKeyboardButton , TermsOfService , ForceReply
3
2
from pyrogram import Client
4
3
from pyrogram .errors import FloodWait
5
4
from pyrogram import errors
5
+ from pyrogram .types import InlineKeyboardMarkup , InlineKeyboardButton , ForceReply
6
+
6
7
import asyncio
7
8
8
9
from psm import psm
@@ -16,17 +17,18 @@ async def client_session(message):
16
17
api_hash = str (app_hashs [message .from_user .id ]),
17
18
)
18
19
19
- @psm .on_message (filters .command ('phone' ))
20
+
21
+ @psm .on_message (filters .command ("phone" ))
20
22
async def phone_number (_ , message ):
21
23
try :
22
24
app = await client_session (message )
23
25
except KeyError :
24
- await message .reply (' You did not set Variables correctly, read /start again.' )
26
+ await message .reply (" You did not set Variables correctly, read /start again." )
25
27
return
26
28
try :
27
- phonenum = message .text .split (None , 1 )[1 ].replace (' ' , '' )
29
+ phonenum = message .text .split (None , 1 )[1 ].replace (" " , "" )
28
30
except IndexError :
29
- await message .reply (' Must pass args, example: `/phone +1234578900`' )
31
+ await message .reply (" Must pass args, example: `/phone +1234578900`" )
30
32
return
31
33
try :
32
34
await app .connect ()
@@ -36,51 +38,68 @@ async def phone_number(_, message):
36
38
try :
37
39
sent_code = await app .send_code (phonenum )
38
40
except FloodWait as e :
39
- await message .reply (f'I cannot create session for you.\n You have a floodwait of: `{ e .x } seconds`' )
41
+ await message .reply (
42
+ f"I cannot create session for you.\n You have a floodwait of: `{ e .x } seconds`"
43
+ )
40
44
return
41
45
except errors .exceptions .bad_request_400 .PhoneNumberInvalid :
42
- await message .reply ('Phone number is invalid, Make sure you double check before sending.' )
46
+ await message .reply (
47
+ "Phone number is invalid, Make sure you double check before sending."
48
+ )
43
49
return
44
- await message .reply ('send me your code in 25 seconds, make sure you reply to this message and wait for a response.' , reply_markup = ForceReply (True ))
50
+ await message .reply (
51
+ "send me your code in 25 seconds, make sure you reply to this message and wait for a response." ,
52
+ reply_markup = ForceReply (True ),
53
+ )
45
54
await asyncio .sleep (25 )
46
55
try :
47
- await app .sign_in (phonenum , sent_code .phone_code_hash , code_caches [message .from_user .id ])
56
+ await app .sign_in (
57
+ phonenum , sent_code .phone_code_hash , code_caches [message .from_user .id ]
58
+ )
48
59
except KeyError :
49
- await message .reply (' Timed out, Try again.' )
60
+ await message .reply (" Timed out, Try again." )
50
61
return
51
62
except errors .exceptions .unauthorized_401 .SessionPasswordNeeded :
52
63
try :
53
64
await app .check_password (passwords [message .from_user .id ])
54
65
except KeyError :
55
- await message .reply ('Timed out, try again later' )
66
+ await message .reply (
67
+ "You have not set your password in the `/variables`, try doing that before you continue"
68
+ )
56
69
return
57
70
except errors .exceptions .bad_request_400 .PhoneCodeInvalid :
58
- await message .reply (' The code you sent seems Invalid, Try again.' )
71
+ await message .reply (" The code you sent seems Invalid, Try again." )
59
72
return
60
73
except errors .exceptions .bad_request_400 .PhoneCodeExpired :
61
- await message .reply (' The Code you sent seems Expired. Try again.' )
74
+ await message .reply (" The Code you sent seems Expired. Try again." )
62
75
return
63
- await app .send_message ('me' , f' ```{ (await app .export_session_string ())} ```' )
76
+ await app .send_message ("me" , f" ```{ (await app .export_session_string ())} ```" )
64
77
button = InlineKeyboardMarkup (
65
- [[InlineKeyboardButton ('Go to Saved Messages' , url = f'tg://user?id={ message .from_user .id } ' )]]
78
+ [
79
+ [
80
+ InlineKeyboardButton (
81
+ "Go to Saved Messages" , url = f"tg://user?id={ message .from_user .id } "
82
+ )
83
+ ]
84
+ ]
66
85
)
67
86
await message .reply (
68
- ' All Done! Check your Saved Messages for your Session String.\n \n Make sure you run /clear to clear caches of your variables' ,
69
- reply_markup = button
87
+ " All Done! Check your Saved Messages for your Session String.\n \n Make sure you run /clear to clear caches of your variables" ,
88
+ reply_markup = button ,
70
89
)
71
90
72
91
73
- @psm .on_message (filters .command (' token' ))
92
+ @psm .on_message (filters .command (" token" ))
74
93
async def bot_token (_ , message ):
75
94
try :
76
95
app = await client_session (message )
77
96
except KeyError :
78
- await message .reply (' You did not set Variables correctly, read /start again.' )
97
+ await message .reply (" You did not set Variables correctly, read /start again." )
79
98
return
80
99
try :
81
- bottoken = message .text .split (None , 1 )[1 ].replace (' ' , '' )
100
+ bottoken = message .text .split (None , 1 )[1 ].replace (" " , "" )
82
101
except IndexError :
83
- await message .reply (' Must pass args, example: `/token 1234:ABCD1234`' )
102
+ await message .reply (" Must pass args, example: `/token 1234:ABCD1234`" )
84
103
return
85
104
try :
86
105
await app .connect ()
@@ -90,9 +109,10 @@ async def bot_token(_, message):
90
109
try :
91
110
await app .sign_in_bot (bottoken )
92
111
except errors .exceptions .bad_request_400 .AccessTokenInvalid :
93
- await message .reply ('BotToken Invalid: make sure you are sending a valid BotToken from @BotFather' )
112
+ await message .reply (
113
+ "BotToken Invalid: make sure you are sending a valid BotToken from @BotFather"
114
+ )
94
115
return
95
116
await message .reply (
96
- f'**Here is your Bot Session:**\n ```{ (await app .export_session_string ())} ```\n \n Make sure you run /clear to clear caches of your variables'
97
- )
98
-
117
+ f"**Here is your Bot Session:**\n ```{ (await app .export_session_string ())} ```\n \n Make sure you run /clear to clear caches of your variables"
118
+ )
0 commit comments