Class: TelegramMeetupBot::HandlerHelper
- Inherits:
-
Object
- Object
- TelegramMeetupBot::HandlerHelper
- Defined in:
- lib/telegram_meetup_bot/handler_helper.rb
Instance Attribute Summary collapse
-
#author ⇒ Object
readonly
Returns the value of attribute author.
-
#command ⇒ Object
readonly
Returns the value of attribute command.
-
#error ⇒ Object
readonly
Returns the value of attribute error.
-
#messenger ⇒ Object
readonly
Returns the value of attribute messenger.
Instance Method Summary collapse
- #author_has_username? ⇒ Boolean
- #handle_cal(month) ⇒ Object
- #handle_date(date, time) ⇒ Object
- #handle_date_cancel(date) ⇒ Object
- #handle_date_list(date) ⇒ Object
- #handle_default_command ⇒ Object
-
#initialize(args) ⇒ HandlerHelper
constructor
A new instance of HandlerHelper.
- #send_empty_username_notification ⇒ Object
Constructor Details
#initialize(args) ⇒ HandlerHelper
5 6 7 8 9 |
# File 'lib/telegram_meetup_bot/handler_helper.rb', line 5 def initialize(args) @command = args.fetch(:command) = args.fetch(:author) @messenger = args.fetch(:messenger) end |
Instance Attribute Details
#author ⇒ Object (readonly)
Returns the value of attribute author.
3 4 5 |
# File 'lib/telegram_meetup_bot/handler_helper.rb', line 3 def end |
#command ⇒ Object (readonly)
Returns the value of attribute command.
3 4 5 |
# File 'lib/telegram_meetup_bot/handler_helper.rb', line 3 def command @command end |
#error ⇒ Object (readonly)
Returns the value of attribute error.
3 4 5 |
# File 'lib/telegram_meetup_bot/handler_helper.rb', line 3 def error @error end |
#messenger ⇒ Object (readonly)
Returns the value of attribute messenger.
3 4 5 |
# File 'lib/telegram_meetup_bot/handler_helper.rb', line 3 def messenger @messenger end |
Instance Method Details
#author_has_username? ⇒ Boolean
42 43 44 |
# File 'lib/telegram_meetup_bot/handler_helper.rb', line 42 def .username end |
#handle_cal(month) ⇒ Object
46 47 48 49 50 51 52 |
# File 'lib/telegram_meetup_bot/handler_helper.rb', line 46 def handle_cal(month) dates = Calendar.submited_days_of_month(month) today = Date.today year = month < today.month ? today.next_year.year : today.year month = Date.new(year, month) messenger.send_text list_response(list: dates, month: month) end |
#handle_date(date, time) ⇒ Object
11 12 13 14 15 16 |
# File 'lib/telegram_meetup_bot/handler_helper.rb', line 11 def handle_date(date, time) handle(date) do Calendar.new(date: date, user: , time: time).add_user_to_date messenger.send_text build_response(date: date) end end |
#handle_date_cancel(date) ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'lib/telegram_meetup_bot/handler_helper.rb', line 25 def handle_date_cancel(date) handle(date) do calendar = Calendar.new(date: date, user: ) deleted_user = calendar.delete_user_from_date args = deleted_user ? {} : {key: 'not_subscribed', date: date} messenger.send_text build_response(args) end end |
#handle_date_list(date) ⇒ Object
18 19 20 21 22 23 |
# File 'lib/telegram_meetup_bot/handler_helper.rb', line 18 def handle_date_list(date) handle(date) do users = Calendar.formated_users_for_date(date) messenger.send_text list_response(list: users, date: date) end end |
#handle_default_command ⇒ Object
34 35 36 |
# File 'lib/telegram_meetup_bot/handler_helper.rb', line 34 def handle_default_command messenger.send_text build_response end |
#send_empty_username_notification ⇒ Object
38 39 40 |
# File 'lib/telegram_meetup_bot/handler_helper.rb', line 38 def send_empty_username_notification messenger.send_text build_response(key: 'no_username') end |