-
Notifications
You must be signed in to change notification settings - Fork 0
Installation
- You have installed Ruby. Look for the required version in the file .ruby-version. You can use rbenv to pick a right version for this application.
- You have installed bundler
-
After cloning days-of-code, run
bundle install
to fetch its dependencies. -
Create your own test bot (see instructions below).
-
Create postgres databases for test and development environments, e.g.
telegram_bot_development
andtelegram_bot_test
-
Create
.env.development
and.env.test
files in the app root. Set variablesDATABASE_URL
,BOT_TOKEN
,CHAT_ID
,DATE_START
andDATE_END
there. Use.env.development.sample
file for reference. Remember to set a differentDATABASE_URL
for the test and development environments. E.g.postgresql://postgres:password@localhost:5432/telegram_bot_development
andpostgresql://postgres:password@localhost:5432/telegram_bot_test
You can set environment variables PROXY_SERVER
and PROXY_PORT
if you use a proxy to connect to Telegram servers.
- To prevent problems with connection to Telegram API, before bot launch you need to start some preventing online restrictions tool.
You can launch the app in one of two ways:
-
bundle exec ruby bot_control.rb start
(w/o console output) bundle exec ruby bot.rb
Open Telegram, add bot @BotPhaser, and create a bot:
/start
/newbot
etc. Finally, you'll receive Your API-token from bot_father : XXXXXXXXX:YYYYYYY-YYYYYYYYYYYYYYYYY_YY. To get chat id you may do the following. On private chat with your bot, send a random message. You will search this message later. Then, on your browser make a request with url:
https://api.telegram.org/botXXXXXXXXX:YYYYYYY-YYYYYYYYYYYYYYYYY_YY/getUpdates
The request returns a json response, in json text search your random message and get chat id in that object.
psql postgres
create database telegram_bot_development;
There's also a need to run migrations:
bundle exec rake db:migrate
And optional seeds:
bundle exec ruby db/seeds.rb