Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vilena Aleksandrova - 3 #58

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Aleksandrova_Vilena/3/bot/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.idea/
/.env
lib/ruby/
1 change: 1 addition & 0 deletions Aleksandrova_Vilena/3/bot/.rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--require spec_helper
24 changes: 24 additions & 0 deletions Aleksandrova_Vilena/3/bot/Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# frozen_string_literal: true

source 'https://rubygems.org'

git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }

# gem "rails"
gem 'activerecord'
gem 'dotenv' # for using env. variables
gem 'multi_json'
gem 'nanoc', '~> 4.12'
gem 'pry', '~> 0.14.1'
gem 'puma'
gem 'rake', '~> 13.0.3'
gem 'recursive-open-struct', '~> 1.1.3'
gem 'robocop'
gem 'rspec' # for running tests
gem 'sinatra'
gem 'sinatra-activerecord', '~> 2.0'
gem 'singleton'
gem 'sqlite3' # db for devtesting
gem 'telegram-bot-ruby'
gem 'whenever', require: false
gem 'whenever-test'
182 changes: 182 additions & 0 deletions Aleksandrova_Vilena/3/bot/Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
GEM
remote: https://rubygems.org/
specs:
activemodel (6.1.3.2)
activesupport (= 6.1.3.2)
activerecord (6.1.3.2)
activemodel (= 6.1.3.2)
activesupport (= 6.1.3.2)
activesupport (6.1.3.2)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 1.6, < 2)
minitest (>= 5.1)
tzinfo (~> 2.0)
zeitwerk (~> 2.3)
addressable (2.7.0)
public_suffix (>= 2.0.2, < 5.0)
axiom-types (0.1.1)
descendants_tracker (~> 0.0.4)
ice_nine (~> 0.11.0)
thread_safe (~> 0.3, >= 0.3.1)
chronic (0.10.2)
coderay (1.1.3)
coercible (1.0.0)
descendants_tracker (~> 0.0.1)
colored (1.2)
concurrent-ruby (1.1.8)
cri (2.15.11)
ddmemoize (1.0.0)
ddmetrics (~> 1.0)
ref (~> 2.0)
ddmetrics (1.0.1)
ddplugin (1.0.3)
descendants_tracker (0.0.4)
thread_safe (~> 0.3, >= 0.3.1)
diff-lcs (1.4.4)
dotenv (2.7.6)
equalizer (0.0.11)
faraday (1.4.1)
faraday-excon (~> 1.1)
faraday-net_http (~> 1.0)
faraday-net_http_persistent (~> 1.1)
multipart-post (>= 1.2, < 3)
ruby2_keywords (>= 0.0.4)
faraday-excon (1.1.0)
faraday-net_http (1.0.1)
faraday-net_http_persistent (1.1.0)
hamster (3.0.0)
concurrent-ruby (~> 1.0)
i18n (1.8.10)
concurrent-ruby (~> 1.0)
ice_nine (0.11.2)
inflecto (0.0.2)
json_schema (0.21.0)
method_source (1.0.0)
minitest (5.14.4)
multi_json (1.15.0)
multipart-post (2.1.1)
mustermann (1.1.1)
ruby2_keywords (~> 0.0.1)
nanoc (4.12.1)
addressable (~> 2.5)
colored (~> 1.2)
nanoc-checking (~> 1.0)
nanoc-cli (= 4.12.1)
nanoc-core (= 4.12.1)
nanoc-deploying (~> 1.0)
parallel (~> 1.12)
tty-command (~> 0.8)
tty-which (~> 0.4)
nanoc-checking (1.0.1)
nanoc-cli (~> 4.11, >= 4.11.15)
nanoc-core (~> 4.11, >= 4.11.15)
nanoc-cli (4.12.1)
cri (~> 2.15)
diff-lcs (~> 1.3)
nanoc-core (= 4.12.1)
zeitwerk (~> 2.1)
nanoc-core (4.12.1)
concurrent-ruby (~> 1.1)
ddmemoize (~> 1.0)
ddmetrics (~> 1.0)
ddplugin (~> 1.0)
hamster (~> 3.0)
json_schema (~> 0.19)
slow_enumerator_tools (~> 1.0)
tty-platform (~> 0.2)
zeitwerk (~> 2.1)
nanoc-deploying (1.0.1)
nanoc-checking (~> 1.0)
nanoc-cli (~> 4.11, >= 4.11.15)
nanoc-core (~> 4.11, >= 4.11.15)
nio4r (2.5.7)
parallel (1.20.1)
pastel (0.8.0)
tty-color (~> 0.5)
pry (0.14.1)
coderay (~> 1.1)
method_source (~> 1.0)
public_suffix (4.0.6)
puma (5.2.2)
nio4r (~> 2.0)
rack (2.2.3)
rack-protection (2.1.0)
rack
rake (13.0.3)
recursive-open-struct (1.1.3)
ref (2.0.0)
robocop (0.1.1)
rack
rspec (3.10.0)
rspec-core (~> 3.10.0)
rspec-expectations (~> 3.10.0)
rspec-mocks (~> 3.10.0)
rspec-core (3.10.1)
rspec-support (~> 3.10.0)
rspec-expectations (3.10.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.10.0)
rspec-mocks (3.10.2)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.10.0)
rspec-support (3.10.2)
ruby2_keywords (0.0.4)
sinatra (2.1.0)
mustermann (~> 1.0)
rack (~> 2.2)
rack-protection (= 2.1.0)
tilt (~> 2.0)
sinatra-activerecord (2.0.22)
activerecord (>= 4.1)
sinatra (>= 1.0)
singleton (0.1.1)
slow_enumerator_tools (1.1.0)
sqlite3 (1.4.2)
telegram-bot-ruby (0.15.0)
faraday
inflecto
virtus
thread_safe (0.3.6)
tilt (2.0.10)
tty-color (0.6.0)
tty-command (0.10.1)
pastel (~> 0.8)
tty-platform (0.3.0)
tty-which (0.4.2)
tzinfo (2.0.4)
concurrent-ruby (~> 1.0)
virtus (1.0.5)
axiom-types (~> 0.1)
coercible (~> 1.0)
descendants_tracker (~> 0.0, >= 0.0.3)
equalizer (~> 0.0, >= 0.0.9)
whenever (1.0.0)
chronic (>= 0.6.3)
whenever-test (1.0.1)
whenever
zeitwerk (2.4.2)

PLATFORMS
x86_64-linux

DEPENDENCIES
activerecord
dotenv
multi_json
nanoc (~> 4.12)
pry (~> 0.14.1)
puma
rake (~> 13.0.3)
recursive-open-struct (~> 1.1.3)
robocop
rspec
sinatra
sinatra-activerecord (~> 2.0)
singleton
sqlite3
telegram-bot-ruby
whenever
whenever-test

BUNDLED WITH
2.2.17
54 changes: 54 additions & 0 deletions Aleksandrova_Vilena/3/bot/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Telegram Bot

A simple telegram bot that allows to study endlish words.

## Description

Bot has the following functionality:
- A user can start/stop the studying process.

## Getting Started

### Gems
```
gem 'activerecord'
gem 'dotenv' # for using env. variables
gem 'multi_json'
gem 'nanoc', '~> 4.12'
gem 'pry', '~> 0.14.1'
gem 'puma'
gem 'rake', '~> 13.0.3'
gem 'robocop'
gem 'rspec' # for running tests
gem 'sinatra'
gem 'sinatra-activerecord', '~> 2.0'
gem 'singleton'
gem 'sqlite3' # db for testing
gem 'telegram-bot-ruby'
gem 'whenever', require: false
gem 'whenever-test'
```
### Before executing
```
1. Run tunels using ngrok tool for server emulating:
./ngrok authtoken {ngrok_token}
./ngrok http {port}
2. Send post request to telegram API that allows to redirect
curl --location --request POST 'https://api.telegram.org/bot{token}/setWebhook' --header 'Content-Type: application/json' --data-raw '{"url": {url}}'
```

### Executing program

* Run ``` bundle install ```
* Run ``` bundle exec rake db:seed ```
* Run ``` bundle exec rake db:migrate ```
* Run ``` bundle exec rake db:seed ```
* Run ``` rackup -p {port} ```

```
P.S. In this case it's enough to run: 'bundle install', 'rackup -p {port}'
```

### Task for cron
* Start ``` whenever --update-crontab --set environment='development' ```
* Stop ``` whenever --clear-crontab ```
12 changes: 12 additions & 0 deletions Aleksandrova_Vilena/3/bot/Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# frozen_string_literal: true

require_relative 'config/environment'
require 'sinatra/activerecord/rake'
require_relative 'lib/cron_worker'

namespace :payload do
desc 'Send out lesson messages'
task :send_messages do
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rails/RakeEnvironment: Include :environment task as a dependency for all Rake tasks.

CronWorker.perform
end
end
Loading