Class: SimpleXChat::BasicCommandRunner
- Inherits:
-
Object
- Object
- SimpleXChat::BasicCommandRunner
- Defined in:
- lib/simplex-chat/cmd-runner.rb
Instance Method Summary collapse
-
#initialize(client, commands, prefix) ⇒ BasicCommandRunner
constructor
A new instance of BasicCommandRunner.
- #listen(max_backlog_secs: 5.0) ⇒ Object
Constructor Details
#initialize(client, commands, prefix) ⇒ BasicCommandRunner
Returns a new instance of BasicCommandRunner.
108 109 110 111 112 113 114 115 |
# File 'lib/simplex-chat/cmd-runner.rb', line 108 def initialize(client, commands, prefix) @client = client @commands = commands.map { |cmd| { "#{prefix}#{cmd.name}" => cmd } }.reduce({}, &:merge) @prefix = prefix @logger = Logging.logger end |
Instance Method Details
#listen(max_backlog_secs: 5.0) ⇒ Object
117 118 119 120 121 122 123 124 125 126 127 |
# File 'lib/simplex-chat/cmd-runner.rb', line 117 def listen(max_backlog_secs: 5.0) loop do begin break if process_next_event(max_backlog_secs) == :stop rescue SimpleXChat::GenericError => e @logger.error("[!] Caught error: #{e}") rescue => e raise e end end end |