Inline-directory-bot [Telegram]
Renjith๐ ๐ฌ๐ข๐ฆ๐ฉ๐ฅ๐ย ๐๐ง๐ฅ๐ข๐ง๐ ๐๐๐ฅ๐๐ ๐ซ๐๐ฆ ๐๐จ๐ญ ๐๐๐ง ๐ฌ๐๐ซ๐ฏ๐ ๐๐ฆ๐ฉ๐ฅ๐จ๐ฒ๐๐ ๐๐๐ญ๐๐ข๐ฅ๐ฌ ๐ข๐ง ๐ ๐๐ฅ๐จ๐ฌ๐๐ ๐๐ข๐ซ๐๐ฅ๐ ๐ฐ๐ข๐ญ๐ก ๐ฅ๐จ๐ญ๐ฌ ๐จ๐ ๐๐๐๐ญ๐ฎ๐ซ๐๐ฌ.
This bot is specially made for those who are working in a large size institution having an official group/channel in Telegram.
๐น Working:
The bot needs a group/channel in which the members of the same can only get the inline search results.
๐น Mandatory Things:
๐ Need a Telegram Group / Channel to perform. The bot needs to be an admin.
๐ The bot needs to be in inline mode.
๐ Need ADMIN USERS to do special functions.
๐ Need SUDO USERS to broadcast messages to bot subscribers.
๐น Bot Commands: [Admin Only]
start - Check alive add - Add contact to database (Admin only) load - Load data from CSV (Admin only) send - Broadcast message to bot subs(Sudo Only) users - List users of the bot (Sudo Only) photo - Update thumbnail photo (Admin only) delete - Mass delete contacts (Admin only) email - Update E-Mail address (user) admins - View Admin user of the bot (user) mobile- Update mobile number (user) extension - Update extension umber (user)
๐น Mandatory Variables:
TG_BOT_TOKEN - Get from @BotFather
APP_ID - Get from my.telegram.org
API_HASH - Get from my.telegram.org
DB_URI = os.environ.get("DATABASE_URL", "")
For Heroku, just leave the DB_URI field as the above. In VPS /Linux servers, See the bottom section to create a database.
DEFAULT_CHAT_ROOM = int(-100xxxxxxxxxxxxxx)
Group / Channel Id of the chat circle which bot serves the result as a pm to the members.
ADMIN_USERS = [xxxxxxxxxxx xxxxxxxxxxx xxxxxxxxxxx]
Admin user ids separated by <space>
SUDo_USERS = [xxxxxxxxxxx xxxxxxxxxxx xxxxxxxxxxx]
Sudo user ids separated by <space>
๐น In Linux servers or VPS: Please follow the steps:
[To create a database URI:]
This bot needs a database. So, you'll need to have a database installed on your system. I personally use Postgres, so I recommend using it for optimal compatibility.
In the case of Postgres, this is how you would set up a database on a Debian/Ubuntu system. Other distributions may vary.
- Open terminal as superuser
sudo su
2. Install PostgreSQL database:
sudo apt-get update && sudo apt-get install postgresql
3. Change to the Postgres user:
sudo su - postgres
4. Create a new database user :
(change YOUR_USER appropriately)
createuser -P -s -e YOUR_USER_NAME
5. This will be followed by you need to input your password.
6. Create a new database table:
createdb -O YOUR_USER YOUR_DB_NAME
7. Create the database with your own values :
Change YOUR_USER and YOUR_DB_NAME appropriately.
psql YOUR_DB_NAME -h YOUR_HOST YOUR_USER
This will allow you to connect to your database via your terminal. By default, YOUR_HOST should be localhost:5432
You should now be able to build your database URI. This will be:
sqldbtype://username:pw@hostname:port/db_name
8. An example database URI could be like:
postgresql://johnson:1234@localhost:5432/clonebotdb
Replace sqldb type with whichever dB you're using (eg postgresql, mysql, sqllite, etc) repeat for your username, password, hostname (localhost?), port (5432?), and db name.
9. Createย config.pyย in the main directory:
With mandatory variables andย database URI create a config.py
Open the main bot directory > right-click > open a terminal here >
Or
Open a terminal > change to the bot main directory by cd /xxx/xxx
10. Finally, Run the following in the Terminal:
virtualenv -p python3 venv . ./venv/bin/activate pip3 install -r requirements.txt python3 bot.py
๐น Configuration Procedure: TO KNOW THE COMMAND USAGE CLICK HERE