Method: MatrixSdk::Bot::Base#initialize
- Defined in:
- lib/matrix_sdk/bot/base.rb
#initialize(hs_url, **params) ⇒ Base
Returns a new instance of Base.
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/matrix_sdk/bot/base.rb', line 30 def initialize(hs_url, **params) @client = case hs_url when MatrixSdk::Api MatrixSdk::Client.new hs_url when MatrixSdk::Client hs_url when %r{^https?://.*} MatrixSdk::Client.new hs_url, **params else MatrixSdk::Client.new_for_domain hs_url, **params end @client.on_event.add_handler { |ev| _handle_event(ev) } @client.on_invite_event.add_handler do |ev| break unless settings.accept_invites? logger.info "Received invite to #{ev[:room_id]}, joining." client.join_room(ev[:room_id]) end @event = nil logger.warn 'The bot abstraction is not fully finalized and can be expected to change.' end |