!Currently in production!
This application is based on https://github.com/telegram-bot-rb/telegram-bot gem and using Telegram API
Purposes of project:
- to create custom complex ruby application architecture from scratch without any frameworks (for education purposes)
- quick development and integration of multiple telegram bots in one application
To see example bot in action, please, telegram to @socialup_example_bot
App includes:
- Database (Postgres), ActiveRecord ORM
- Key-value database (Redis) integration
- Background processing (Sidekiq) with web UI (SidekiqUI)
- Schedules for background workers (Sidekiq-scheduler)
- Background workers statistic (Sidekiq-statistic)
- Multiple environments (production, development, test)
- Docker-compose file to quickly run the whole app in isolation
- Console action logging (colorized for better readability)
- Prepared test environment (using RSpec by default)
- Web application powered by Ruby padrino framework
Please keep in mind that you have to install redis
and postgres
on your local machine
Or just use included docker-compose file
First of all you need to create your own telegram bot and obtain an API key. Follow this steps, it's very simple and will take less than 5 mins:
- Open telegram and find user '@botfather' in search
- Press 'Start' button to begin conversation
- Choose command '/newbot'
- Enter desired name of your future bot (for instance 'SushiDeliveryBot')
- Enter desired username (for instance 'sushi_delivery_bot')
- Save obtained API key. You will set ENV variable with this key later
- You should to set inline mode and turn off privacy mode for your bot. Inline mode will allow you to use inline keyboards and inline queries. Disabled privacy will allow you to sync user messages to DB. Find this settings in bot settings (@BotFather)
- Create env file for dev environment:
cp .env.example .env.development
- Replace default ENV values, set bot token and username, set your own telegram user id
- Run
docker-compose build
- Run
docker-compose run console bin/setup
- Run
docker-compose up
- Send to your telegram bot command
/enable
to set enabled state - Send
/start
and enjoy
rake
- will run all spec testsrake redis:flushall
- clear all Redis keys and valuesrake bots:disable_all
- disable all bots (setsenabled: false
inbots
table)rake translations:check
- Check if all translations is imported to DB. It compares registered keys inTranslation
model with existing translation records in DBrake db:new_migration name=create_some_table
- Generate migration file
Make sure you:
- created
.env.test
file with proper ENV values - performed test DB migration:
docker-compose -f docker-compose.test.yml run console rake db:migrate RAILS_ENV=test
- Use command
docker-compose -f docker-compose.test.yml run console rspec
to run all tests - To run particular test use
docker-compose -f docker-compose.test.yml run console rspec ./spec/controllers/example_bot_controller_spec.rb
Use bin/deploy
script file to perform actions needed for project deployment
bin/console
to run console with preloaded codebasebin/deploy
for performing deployment stepsbin/setup
to perform initial project setup
Bug reports and pull requests are welcome on GitHub at https://github.com/vrtsev/Telegrammer. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.
The project is available as open source under the terms of the MIT License.
Everyone interacting in the Telegrammer project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.