telegram_meetup_bot 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +3 -1
- data/config_samples/responses.yml +1 -1
- data/lib/telegram_meetup_bot/calendar.rb +4 -2
- data/lib/telegram_meetup_bot/messenger.rb +11 -1
- data/lib/telegram_meetup_bot/storage.rb +1 -1
- data/lib/telegram_meetup_bot/version.rb +1 -1
- data/spec/telegram_meetup_bot/calendar_spec.rb +21 -6
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fa77cbf78edf0afa2a74a9a4015d1dbae0702832
|
4
|
+
data.tar.gz: ba451d51306d62957fa318a2df2aa83a48cb5d35
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b40f6356caea3ac1d4957fcef3a3b20fe5ef2b4ba94f4c9391012aaead9e9d9ec1f4cc229996a64e8a30422c1fa5b7532b860f1f6ad84e349be5ed6291bc4fd0
|
7
|
+
data.tar.gz: 9fc15195641a17358ad72c32b038abfd12f23dbeed335a4bcf0dd0f961f5914620f70e20d547cab78bfd7edd975038b2d68ec2b45a24a3f973cb42e4bfa8b724
|
data/README.md
CHANGED
@@ -4,7 +4,9 @@
|
|
4
4
|
|
5
5
|
Telegram bot for meetups organisation. It suits really well for small communities, where people want to attend a place together, but not on regular basis.
|
6
6
|
|
7
|
-

|
8
|
+
|
9
|
+
Available commands: ```/date, /list, /cancel, /cal, /help```
|
8
10
|
|
9
11
|
## Installation
|
10
12
|
|
@@ -6,7 +6,7 @@ old_date: "This date is too old."
|
|
6
6
|
nobody: "No one planned to come on %date%."
|
7
7
|
not_subscribed: "You wasn't subscribed on %date%."
|
8
8
|
no_username: "%first_name%, please set a username in the Telegram settings."
|
9
|
-
cal: "Reserved days in %date%:"
|
9
|
+
cal: "Reserved days (number of people) in %date%:"
|
10
10
|
help: |
|
11
11
|
Hi, %first_name%. Use this commands list:
|
12
12
|
/date 14:00 - add yourself to the today list (time is optional);
|
@@ -43,8 +43,10 @@ module TelegramMeetupBot
|
|
43
43
|
dates = storage.get_all_available_dates
|
44
44
|
min, max = build_date_window(month)
|
45
45
|
|
46
|
-
dates.keep_if { |date| date >= min && date <= max }.sort
|
47
|
-
|
46
|
+
dates = dates.keep_if { |date, _| date >= min && date <= max }.sort
|
47
|
+
dates.map do |date, users_yml|
|
48
|
+
"#{date.match(/\d\d$/)}(#{YAML.load(users_yml).count})"
|
49
|
+
end.join(', ')
|
48
50
|
end
|
49
51
|
|
50
52
|
private
|
@@ -8,7 +8,17 @@ module TelegramMeetupBot
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def send_text(text)
|
11
|
-
api.send_message(chat_id: chat_id, text: text)
|
11
|
+
api.send_message(chat_id: chat_id, text: text, reply_markup: keyboard)
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def keyboard
|
17
|
+
Telegram::Bot::Types::ReplyKeyboardMarkup.new(
|
18
|
+
keyboard: [%w(/date /list /cal /cancel)],
|
19
|
+
one_time_keyboard: false,
|
20
|
+
resize_keyboard: true
|
21
|
+
)
|
12
22
|
end
|
13
23
|
end
|
14
24
|
end
|
@@ -80,28 +80,43 @@ RSpec.describe TelegramMeetupBot::Calendar do
|
|
80
80
|
before { allow(storage).to receive(:get_all_available_dates).and_return(dates) }
|
81
81
|
|
82
82
|
context "when month isn't current" do
|
83
|
-
let(:dates) {
|
83
|
+
let(:dates) {
|
84
|
+
{"2015-07-30"=>"---\n- :id: 65208698\n :username: timur\n :first_name: Timur\n",
|
85
|
+
"2015-07-15"=>"---\n- :id: 65208698\n :username: timur\n :first_name: Timur\n",
|
86
|
+
"2015-07-16"=>"---\n- :id: 65208698\n :username: timur\n :first_name: Timur\n :time: '10:10'\n",
|
87
|
+
"2015-06-14"=>"---\n- :id: 65208698\n :username: timur\n :first_name: Timur\n",
|
88
|
+
"2015-08-17"=>"---\n- :id: 65208698\n :username: timur\n :first_name: Timur\n"}
|
89
|
+
}
|
84
90
|
it "works" do
|
85
91
|
Timecop.freeze(Date.new(2015, month - 1, 1)) do
|
86
|
-
expect(subject.submited_days_of_month(month)).to eq("15, 16, 30")
|
92
|
+
expect(subject.submited_days_of_month(month)).to eq("15(1), 16(1), 30(1)")
|
87
93
|
end
|
88
94
|
end
|
89
95
|
end
|
90
96
|
|
91
97
|
context "when month is current" do
|
92
|
-
let(:dates) {
|
98
|
+
let(:dates) {
|
99
|
+
{"2015-07-30"=>"---\n- :id: 65208698\n :username: timur\n :first_name: Timur\n",
|
100
|
+
"2015-07-15"=>"---\n- :id: 65208698\n :username: timur\n :first_name: Timur\n",
|
101
|
+
"2015-07-16"=>"---\n- :id: 65208698\n :username: timur\n :first_name: Timur\n :time: '10:10'\n",
|
102
|
+
"2015-06-14"=>"---\n- :id: 65208698\n :username: timur\n :first_name: Timur\n",
|
103
|
+
"2015-08-17"=>"---\n- :id: 65208698\n :username: timur\n :first_name: Timur\n"}
|
104
|
+
}
|
93
105
|
it "starts from today" do
|
94
106
|
Timecop.freeze(Date.new(2015, month, 16)) do
|
95
|
-
expect(subject.submited_days_of_month(month)).to eq("16, 30")
|
107
|
+
expect(subject.submited_days_of_month(month)).to eq("16(1), 30(1)")
|
96
108
|
end
|
97
109
|
end
|
98
110
|
end
|
99
111
|
|
100
112
|
context "when month < current_month" do
|
101
|
-
let(:dates) {
|
113
|
+
let(:dates) {
|
114
|
+
{"2015-06-30"=>"---\n- :id: 65208698\n :username: timur\n :first_name: Timur\n",
|
115
|
+
"2016-06-15"=>"---\n- :id: 65208698\n :username: timur\n :first_name: Timur\n"}
|
116
|
+
}
|
102
117
|
it "starts from today" do
|
103
118
|
Timecop.freeze(Date.new(2015, month, 16)) do
|
104
|
-
expect(subject.submited_days_of_month(month - 1)).to eq("15")
|
119
|
+
expect(subject.submited_days_of_month(month - 1)).to eq("15(1)")
|
105
120
|
end
|
106
121
|
end
|
107
122
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: telegram_meetup_bot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Timur Yanberdin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-11-
|
11
|
+
date: 2015-11-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|