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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 98d69941024a79b6b13a609d1043f7041625284f
4
- data.tar.gz: 14411958ac147a0d5a7d01edc9f6e500f4afd085
3
+ metadata.gz: fa77cbf78edf0afa2a74a9a4015d1dbae0702832
4
+ data.tar.gz: ba451d51306d62957fa318a2df2aa83a48cb5d35
5
5
  SHA512:
6
- metadata.gz: b09a53761a76d37699959a4f74e32a658672d4f49f5835043b232816b5d430aba78844ca796ff61310d8c8b6d9fd0ebd4a04f48a63e6134e29597eb948654fe7
7
- data.tar.gz: 3f541bb8be59ea76fb2afac89b1719686acca0807310b74f16b22c964a45f471e2d4f6a50927f61087fdf9f07a3811a5819d6cdf44c66a09da460f2a158f85a0
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
- ![chat example](https://cloud.githubusercontent.com/assets/854386/9875843/23b37e8a-5bba-11e5-8c6f-c4777c8a1eff.png)
7
+ ![chat example](https://cloud.githubusercontent.com/assets/854386/10962172/1461e79a-83a7-11e5-94b4-78c6d53f648c.png)
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
- map { |date| date.match(/\d\d$/) }.join(', ')
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
@@ -17,7 +17,7 @@ module TelegramMeetupBot
17
17
  end
18
18
 
19
19
  def get_all_available_dates
20
- dates = redis.hkeys(key)
20
+ dates = redis.hgetall(key)
21
21
  end
22
22
 
23
23
  def delete_date(date)
@@ -1,3 +1,3 @@
1
1
  module TelegramMeetupBot
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  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) { %w(2015-07-30 2015-07-15 2015-07-16 2015-06-14 2015-08-17) }
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) { %w(2015-07-30 2015-07-15 2015-07-16 2015-06-14 2015-08-17) }
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) { %w(2015-06-30 2016-06-15) }
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.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-05 00:00:00.000000000 Z
11
+ date: 2015-11-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler