├── requirements.txt ├── run ├── .gitignore ├── README.md └── maker.py /requirements.txt: -------------------------------------------------------------------------------- 1 | pyrogram 2 | tgcrypto 3 | requests 4 | pyfiglet -------------------------------------------------------------------------------- /run: -------------------------------------------------------------------------------- 1 | echo "Installing requirements, please wait..." 2 | pip3 install -r requirements.txt > /dev/null 3 | python3 maker.py -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | :memory:.session 3 | :memory:.sqlite_history 4 | :memory:.sqlite_sequence 5 | .venv 6 | venv 7 | __pycache__ 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | 3 | 4 | 5 |

6 |

7 | Pyrogram V2.x Session String maker 8 |

9 | -------------------------------------------------------------------------------- /maker.py: -------------------------------------------------------------------------------- 1 | import os 2 | import pyfiglet 3 | from time import sleep 4 | from pyrogram import Client 5 | from datetime import datetime 6 | from requests.exceptions import ConnectionError 7 | 8 | # Clean up os 9 | try: 10 | os.remove("my.session") 11 | except Exception: 12 | pass 13 | try: 14 | os.remove("bot.session") 15 | except Exception: 16 | pass 17 | 18 | 19 | # Clean Screen 20 | def clear(): 21 | if os.name == "posix": # Unix/Linux/MacOS/BSD/etc 22 | os.system("clear") 23 | elif os.name == "nt": # Windows 24 | os.system("cls") 25 | else: 26 | pass 27 | 28 | 29 | # Start fn 30 | def start(): 31 | clear() 32 | initial_screen() 33 | 34 | 35 | #Info Screen 36 | def initial_screen(): 37 | banner = pyfiglet.figlet_format("m4mallu") 38 | print(banner) 39 | print("You need to register to get app_id and api_hash in here:\nhttps://my.telegram.org/apps") 40 | print("\nProject source:\nhttps://github.com/m4mallu/Pyrogram-V2-SessionStringMaker") 41 | input("\nPress 'Enter' key to continue >>>") 42 | fill_api() 43 | 44 | 45 | # Fill the user credentials 46 | def fill_api(): 47 | clear() 48 | while True: 49 | api_id = input("Insert app_id: ") 50 | if str(api_id).isdigit(): 51 | break 52 | clear() 53 | print("Invalid app_id!") 54 | sleep(2) 55 | clear() 56 | 57 | app_hash = input("Insert api_hash: ") 58 | if app_hash: 59 | create_session(api_id, app_hash) 60 | 61 | 62 | #Session creation 63 | def create_session(api_id, app_hash): 64 | app = Client("session", int(api_id), app_hash) 65 | try: 66 | clear() 67 | app.start() 68 | except Exception: 69 | clear() 70 | input("Invalid Id/Hash/Mobile Number (Mobile number should be in international format).\nPress 'Enter' key to continue >>>") 71 | fill_api() 72 | except ConnectionError: 73 | clear() 74 | input("Network Error! Please try again later.\nPress 'Enter' key to continue >>>") 75 | fill_api() 76 | session = app.export_session_string() 77 | dt_string = datetime.now().strftime("%d/%m/%Y %H:%M:%S") 78 | try: 79 | Client.send_message(self=app, 80 | chat_id='me', 81 | text=str(f'Session created on: {dt_string}\n\n{session}\n\n' 82 | f'⚠️ keep this code confidential ⚠\n\nCredits: ' 83 | f'https://github.com/m4mallu'), 84 | disable_web_page_preview=True, 85 | ) 86 | except Exception: 87 | print("Error saving session to saved messages\n\n") 88 | pass 89 | clear() 90 | print(f"Done! Your session string is:\n\n{session}") 91 | print("\n\n1. A copy of session string has been send to your >>Saved Messages<<\n2. Save this session string to a " 92 | "file and use it in your bot.\nCredits: https://github.com/m4mallu") 93 | input("\nPress 'Enter' key for main menu >>>") 94 | app.stop() 95 | loop() 96 | 97 | 98 | # Main loop 99 | def loop(): 100 | clear() 101 | print(pyfiglet.figlet_format("Coded by", font="digital")) 102 | print(pyfiglet.figlet_format("m4mallu", font="banner3-D")) 103 | sleep(3) 104 | clear() 105 | x = input("Enter 1 to continue\n\nEnter 2 to exit\n\n>>>") 106 | if x == "1": 107 | start() 108 | elif x == "2": 109 | clear() 110 | print("Thanks for using m4mallu's session string maker!") 111 | exit() 112 | else: 113 | clear() 114 | print("Invalid input!") 115 | sleep(2) 116 | clear() 117 | loop() 118 | 119 | 120 | clear() 121 | loop() 122 | --------------------------------------------------------------------------------