WasinBot, a bot interacting with Wasin on Telegram in friendly or for business purpose.
- First you need to create a new telegram bot on Telegram by chatting with BotFather (@BotFather) on Telegram. It will lead you through all the steps of inputing bot name, info, and most importantly getting bot token.
- Set bot token, webhook url, mongodb's username and password via environment variables as follows.
- bot token -
export WASIN_TELEGRAM_BOT_TOKEN=...
replace...
with bot token you got from step 1. - webhook url -
export WASIN_TELEGRAM_BOT_WEBHOOK_URL=https://.../api.php
replace...
with your URL leading to serving fileapi.php
. - mongodb username -
export WASIN_TELEGRAM_BOT_MONGODB_USER=...
by replacing...
with your username. - mongodb password -
export WASIN_TELEGRAM_BOT_MONGODB_PASS=...
by replacing...
with your password.
- bot token -
- Set webhook by executing
php setWebhook.php
. You should receive success message. - Done. Feel free to interact with the bot on telegram.
If you need to set proxy for the bot, you can do so by setting WASIN_TELEGRAM_BOT_PROXY
as environment variable as follows
export WASIN_TELEGRAM_BOT_PROXY=127.0.0.1:1087
If it's set, then the bot will automatically make a request to such proxy IP address, and port through HTTP tunnel.
It's very painful to set environment variables on macOS especially on Sierra (tested on 10.12.4) as all approaches on the Internet aren't working.
The only way to make it work is to use SetEnv
from mod_env
of Apache. See its official doc here.
Define it like this
<Directory "/Users/haxpor/Sites/">
Options Indexes MultiViews FollowSymLinks
SetEnv WASIN_TELEGRAM_BOT_TOKEN <your-bot-token-here>
SetEnv WASIN_TELEGRAM_BOT_PROXY 127.0.0.1:1087
SetEnv WASIN_TELEGRAM_BOT_MONGODB_USER <your-mongodb-username>
SetEnv WASIN_TELEGRAM_BOT_MONGODB_PASS <your-mongodb-password>
</Directory>
You can delete webhook URL you've set with php setWebhook.php delete
.
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.