Class: SlackRubyBot::Server
- Inherits:
-
Object
- Object
- SlackRubyBot::Server
- Includes:
- Hooks::HookSupport, Loggable
- Defined in:
- lib/slack-ruby-bot/server.rb
Direct Known Subclasses
Constant Summary collapse
- TRAPPED_SIGNALS =
%w[INT TERM].freeze
Instance Attribute Summary collapse
-
#aliases ⇒ Object
Returns the value of attribute aliases.
-
#token ⇒ Object
Returns the value of attribute token.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Server
constructor
A new instance of Server.
- #run ⇒ Object
- #start! ⇒ Object
- #start_async ⇒ Object
- #stop! ⇒ Object
Methods included from Hooks::HookSupport
#add_hook_handlers, #flush_hook_blocks, included, #on
Methods included from Loggable
Constructor Details
#initialize(options = {}) ⇒ Server
Returns a new instance of Server.
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/slack-ruby-bot/server.rb', line 13 def initialize( = {}) @token = [:token] @aliases = [:aliases] # Hook Handling flush_hook_blocks add_hook_handlers [:hook_handlers] || { hello: SlackRubyBot::Hooks::Hello.new(logger), message: SlackRubyBot::Hooks::Message.new } end |
Instance Attribute Details
#aliases ⇒ Object
Returns the value of attribute aliases.
7 8 9 |
# File 'lib/slack-ruby-bot/server.rb', line 7 def aliases @aliases end |
#token ⇒ Object
Returns the value of attribute token.
7 8 9 |
# File 'lib/slack-ruby-bot/server.rb', line 7 def token @token end |
Instance Method Details
#run ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'lib/slack-ruby-bot/server.rb', line 26 def run loop do handle_exceptions do handle_signals start! end end end |
#start! ⇒ Object
35 36 37 |
# File 'lib/slack-ruby-bot/server.rb', line 35 def start! client.start! end |
#start_async ⇒ Object
39 40 41 |
# File 'lib/slack-ruby-bot/server.rb', line 39 def start_async client.start_async end |
#stop! ⇒ Object
43 44 45 |
# File 'lib/slack-ruby-bot/server.rb', line 43 def stop! client.stop! if @client end |