Class: Clacky::Channel::Adapters::Base
- Inherits:
-
Object
- Object
- Clacky::Channel::Adapters::Base
- Defined in:
- lib/clacky/server/channel/adapters/base.rb
Overview
Base adapter interface for IM platforms. Subclasses must implement every abstract method below.
Direct Known Subclasses
Class Method Summary collapse
-
.platform_config(raw) ⇒ Hash
Map raw config hash (from ChannelConfig) to symbol-keyed platform config.
-
.platform_id ⇒ Symbol
E.g.
Instance Method Summary collapse
- #platform_id ⇒ Symbol
-
#send_text(chat_id, text, reply_to: nil) ⇒ Hash
Send a plain text (or Markdown) message to a chat.
-
#start {|event Hash| ... } ⇒ Object
Start the adapter and begin receiving messages.
-
#stop ⇒ Object
Stop the adapter and release resources.
-
#supports_message_updates? ⇒ Boolean
True if the platform supports editing a sent message.
-
#update_message(chat_id, message_id, text) ⇒ Boolean
Update an existing message in-place (for streaming progress).
-
#validate_config(config) ⇒ Array<String>
Validate the provided config hash.
Class Method Details
.platform_config(raw) ⇒ Hash
Map raw config hash (from ChannelConfig) to symbol-keyed platform config.
33 34 35 |
# File 'lib/clacky/server/channel/adapters/base.rb', line 33 def self.platform_config(raw) raise NotImplementedError, "#{self} must implement .platform_config" end |
.platform_id ⇒ Symbol
Returns e.g. :feishu, :wecom.
26 27 28 |
# File 'lib/clacky/server/channel/adapters/base.rb', line 26 def self.platform_id raise NotImplementedError, "#{self} must implement .platform_id" end |
Instance Method Details
#platform_id ⇒ Symbol
38 39 40 |
# File 'lib/clacky/server/channel/adapters/base.rb', line 38 def platform_id self.class.platform_id end |
#send_text(chat_id, text, reply_to: nil) ⇒ Hash
Send a plain text (or Markdown) message to a chat.
59 60 61 |
# File 'lib/clacky/server/channel/adapters/base.rb', line 59 def send_text(chat_id, text, reply_to: nil) raise NotImplementedError, "#{self.class} must implement #send_text" end |
#start {|event Hash| ... } ⇒ Object
Start the adapter and begin receiving messages. This method blocks until stopped — call it inside a Thread.
45 46 47 |
# File 'lib/clacky/server/channel/adapters/base.rb', line 45 def start(&) raise NotImplementedError, "#{self.class} must implement #start" end |
#stop ⇒ Object
Stop the adapter and release resources.
50 51 52 |
# File 'lib/clacky/server/channel/adapters/base.rb', line 50 def stop raise NotImplementedError, "#{self.class} must implement #stop" end |
#supports_message_updates? ⇒ Boolean
Returns true if the platform supports editing a sent message.
70 71 72 |
# File 'lib/clacky/server/channel/adapters/base.rb', line 70 def false end |
#update_message(chat_id, message_id, text) ⇒ Boolean
Update an existing message in-place (for streaming progress).
65 66 67 |
# File 'lib/clacky/server/channel/adapters/base.rb', line 65 def (chat_id, , text) false end |
#validate_config(config) ⇒ Array<String>
Validate the provided config hash.
76 77 78 |
# File 'lib/clacky/server/channel/adapters/base.rb', line 76 def validate_config(config) [] end |