Class: ActionBot::Controller

Inherits:
Object
  • Object
show all
Defined in:
lib/action_bot/controller.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#paramsObject

Returns the value of attribute params.



3
4
5
# File 'lib/action_bot/controller.rb', line 3

def params
  @params
end

Instance Method Details

#apiObject



23
24
25
# File 'lib/action_bot/controller.rb', line 23

def api
  ActionBot::Base.config.api || bot.api
end

#botObject



27
28
29
# File 'lib/action_bot/controller.rb', line 27

def bot
  ActionBot::Base.config.bot
end

#mention(id, name) ⇒ Object



14
15
16
# File 'lib/action_bot/controller.rb', line 14

def mention(id, name)
  "[#{name}](tg://user?id=#{id})"
end

#notify(tg_chat_id, text, mode = nil) ⇒ Object



5
6
7
8
9
10
11
12
# File 'lib/action_bot/controller.rb', line 5

def notify(tg_chat_id, text, mode = nil)
  return notify_chat(tg_chat_id, text, mode) unless text.respond_to?(:each)

  text.each do |message|
    sleep(0.5)
    notify_chat(tg_chat_id, message, mode)
  end
end

#t(*args) ⇒ Object



18
19
20
21
# File 'lib/action_bot/controller.rb', line 18

def t(*args)
  I18n.locale = load_chat.locale
  I18n.t(*args)
end