String Session
You'll need a Pyrogram v2 String Session for the Music bot
You'll need a API_ID and API_HASH in order to generate pyrogram session. Always remember to use good API combo else your account could be deleted.
Generate Session through local/VPS
Method 1
Simply run this code and give the input which is being asked and you will get String Session
#!/bin/bash
# Check if pyrogram is installed and the version is >= 2.0.106
python -c "try:\n import pyrogram\n if hasattr(pyrogram, '__version__') and tuple(map(int, pyrogram.__version__.split('.'))) >= (2, 0, 106):\n print('Pyrogram version is sufficient.')\n exit(0)\n else:\n print('Pyrogram version is older than 2.0.106.')\n exit(1)\nexcept ImportError:\n print('Pyrogram is not installed.')\n exit(1)"
# Install pyrogram if not installed or version is older
echo "Installing pyrogram (version >= 2.0.106)..."
pip install pyrogram>=2.0.106
echo "\n=== Telegram API Credentials ==="
read -p "Enter Your API_ID: " api_id
read -p "Enter Your API_HASH: " api_hash
echo "\nEnter Phone number when asked.\n"
session_name=":memory:"
python -c "
import asyncio
import os
from pyrogram import Client as c
async def main():
api_id = '$api_id'
api_hash = '$api_hash'
session_name = '$session_name'
i = c(session_name, api_id=api_id, api_hash=api_hash)
try:
await i.start()
ss = await i.export_session_string()
xx = f'HERE IS YOUR STRING SESSION, COPY IT, DON\\'T SHARE!!\\n\\n`{ss}`\\n\\nGENERATED BY Stranger'
await i.send_message('me', xx)
print('\\nHERE IS YOUR STRING SESSION, COPY IT, DON\\'T SHARE!!\\n')
print(f'\\n{ss}\\n')
print('\\nGENERATED BY Stranger\\n')
finally:
session_file = f'{session_name}.session'
if os.path.exists(session_file):
os.remove(session_file)
if __name__ == '__main__':
asyncio.run(main())
"How to Run:
Save the code above in a file named
start.sh(or any other name with a.shextension).Make the script executable:
chmod +x start.shRun the script:
./start.sh
Method 2
Clone the Stranger repo and run the gensession file
Enter the details for getting the string session
API_ID
API_HASH
and enter the phone number when asked
Clean the files
Last updated