Class: SimpleXChat::BasicCommand
- Inherits:
-
Object
- Object
- SimpleXChat::BasicCommand
- Defined in:
- lib/simplex-chat/cmd-runner.rb
Instance Attribute Summary collapse
-
#desc ⇒ Object
readonly
Returns the value of attribute desc.
-
#min_role ⇒ Object
readonly
Returns the value of attribute min_role.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#num_args ⇒ Object
readonly
Returns the value of attribute num_args.
Instance Method Summary collapse
-
#initialize(name, desc = "", num_args: 0, min_role: GroupMemberRole::MEMBER, per_sender_cooldown_secs: nil, per_issuer_cooldown_secs: nil) ⇒ BasicCommand
constructor
TODO: Allow optional arguments.
- #validate_and_execute(client, chat_msg, args) ⇒ Object
Constructor Details
#initialize(name, desc = "", num_args: 0, min_role: GroupMemberRole::MEMBER, per_sender_cooldown_secs: nil, per_issuer_cooldown_secs: nil) ⇒ BasicCommand
TODO: Allow optional arguments
6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/simplex-chat/cmd-runner.rb', line 6 def initialize(name, desc="", num_args: 0, min_role: GroupMemberRole::MEMBER, per_sender_cooldown_secs: nil, per_issuer_cooldown_secs: nil) @name = name @num_args = num_args @desc = desc @min_role = min_role @per_sender_cooldown_secs = per_sender_cooldown_secs @per_issuer_cooldown_secs = per_issuer_cooldown_secs @last_runs = { :per_sender => {}, :per_issuer => {} } @last_runs_lock = Mutex.new end |
Instance Attribute Details
#desc ⇒ Object (readonly)
Returns the value of attribute desc.
3 4 5 |
# File 'lib/simplex-chat/cmd-runner.rb', line 3 def desc @desc end |
#min_role ⇒ Object (readonly)
Returns the value of attribute min_role.
3 4 5 |
# File 'lib/simplex-chat/cmd-runner.rb', line 3 def min_role @min_role end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/simplex-chat/cmd-runner.rb', line 3 def name @name end |
#num_args ⇒ Object (readonly)
Returns the value of attribute num_args.
3 4 5 |
# File 'lib/simplex-chat/cmd-runner.rb', line 3 def num_args @num_args end |
Instance Method Details
#validate_and_execute(client, chat_msg, args) ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/simplex-chat/cmd-runner.rb', line 21 def validate_and_execute(client, chat_msg, args) return if not validate(client, chat_msg, args) begin execute client, chat_msg, args rescue client. chat_msg[:chat_type], chat_msg[:sender], "@#{chat_msg[:contact]}: Failed to execute command" end end |