Here is an example of .env file you need to use:
Make sure to have telethon and python-dotenv installed.
| # search a query in a list of strings | |
| import re | |
| my_list = ['Horrible donkey', 'irritable monkey', 'international idiot'] | |
| search_for = 'd' | |
| # list comprehension |
| var = {} | |
| count = 1 | |
| limit = 10 | |
| while True: | |
| data = input('enter data ') | |
| var.update({count:data}) |
| import asyncio | |
| from settings import API_ID, API_HASH | |
| from telethon import TelegramClient | |
| from utils import _ | |
| async def get_chat_id(ref=None): | |
| async with TelegramClient('tg_session', API_ID, API_HASH) as client: | |
| if not ref: | |
| ref = input('Enter link/phone/username/id to get chat info: ') |
You must ensure that you have Telethon installed. Run pip install telethon to install.
[optional]
You can can create file called .env in the directory from which you are running the script.
.env
First of all you make a bot whose multiple instances are to be run from the same server.
Suppose the bot is run by invoking main.py with the bot_name and token as command line arguments.
Syntax:
[PYTHON] [ENTRY_POINT] [bot_name] [token]
Example:
python main.py mysamplebot "173453434:42jhs894_13234jsjgasjs"
| # MIT License | |
| # Aahnik 2021 | |
| # a script to organize the files in loconotion output | |
| # also updates html and css files | |
| # unix (linux / mac) style file paths are used in the program, | |
| # will fail inevitably if run on windows | |
| # ditch windows | |
| import logging | |
| import os |
| # AAHNIK 2021 | |
| # ditch windows, may fail there | |
| # for my personal use, i dont care to write a more detailed docs | |
| import os | |
| path = os.getcwd() | |
| path = "/home/aahnik/Downloads/Telegram Desktop/dharmic_cause_ChatExport_2021-04-30/files" |
| # pip install python-dotenv python-telegram-bot | |
| # create a .env file with | |
| # BOT_TOKEN=... | |
| # in the same dir as of this script | |
| import logging | |
| from dotenv import load_dotenv | |
| from telegram.ext.filters import Filters | |
| from telegram import ParseMode | |
| import os |