Class: XNM::Telegram::OnCommand
- Inherits:
-
OnTelegramEvent
- Object
- OnTelegramEvent
- XNM::Telegram::OnCommand
- Defined in:
- lib/xnm/telegram/OnCommand.rb
Instance Attribute Summary collapse
-
#deny_message ⇒ Object
Returns the value of attribute deny_message.
-
#required_perms ⇒ Object
Returns the value of attribute required_perms.
Attributes inherited from OnTelegramEvent
Instance Method Summary collapse
-
#initialize(options) ⇒ OnCommand
constructor
A new instance of OnCommand.
- #nomp_message(message) ⇒ Object
Methods inherited from OnTelegramEvent
Constructor Details
#initialize(options) ⇒ OnCommand
Returns a new instance of OnCommand.
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/xnm/telegram/OnCommand.rb', line 9 def initialize() super() @block = [:block] @command = [:command] @required_perms = [[:permissions]].flatten.uniq @deny_message = [:deny_msg] || 'You are not authorized, %s.' @priority += 5 end |
Instance Attribute Details
#deny_message ⇒ Object
Returns the value of attribute deny_message.
6 7 8 |
# File 'lib/xnm/telegram/OnCommand.rb', line 6 def @deny_message end |
#required_perms ⇒ Object
Returns the value of attribute required_perms.
7 8 9 |
# File 'lib/xnm/telegram/OnCommand.rb', line 7 def required_perms @required_perms end |
Instance Method Details
#nomp_message(message) ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/xnm/telegram/OnCommand.rb', line 22 def () return if .handled return unless .command == @command if .user. @required_perms @block.call else .reply @deny_message % [.user.casual_name] end end |