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
DingTalk::Adapter, Discord::Adapter, Feishu::Adapter, Telegram::Adapter, Wecom::Adapter, Weixin::Adapter
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.
37 38 39 |
# File 'lib/clacky/server/channel/adapters/base.rb', line 37 def self.platform_config(raw) raise NotImplementedError, "#{self} must implement .platform_config" end |
.platform_id ⇒ Symbol
Returns e.g. :feishu, :wecom.
30 31 32 |
# File 'lib/clacky/server/channel/adapters/base.rb', line 30 def self.platform_id raise NotImplementedError, "#{self} must implement .platform_id" end |
Instance Method Details
#platform_id ⇒ Symbol
42 43 44 |
# File 'lib/clacky/server/channel/adapters/base.rb', line 42 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.
63 64 65 |
# File 'lib/clacky/server/channel/adapters/base.rb', line 63 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.
49 50 51 |
# File 'lib/clacky/server/channel/adapters/base.rb', line 49 def start(&) raise NotImplementedError, "#{self.class} must implement #start" end |
#stop ⇒ Object
Stop the adapter and release resources.
54 55 56 |
# File 'lib/clacky/server/channel/adapters/base.rb', line 54 def stop raise NotImplementedError, "#{self.class} must implement #stop" end |
#supports_message_updates? ⇒ Boolean
Returns true if the platform supports editing a sent message.
74 75 76 |
# File 'lib/clacky/server/channel/adapters/base.rb', line 74 def false end |
#update_message(chat_id, message_id, text) ⇒ Boolean
Update an existing message in-place (for streaming progress).
69 70 71 |
# File 'lib/clacky/server/channel/adapters/base.rb', line 69 def (chat_id, , text) false end |
#validate_config(config) ⇒ Array<String>
Validate the provided config hash.
80 81 82 |
# File 'lib/clacky/server/channel/adapters/base.rb', line 80 def validate_config(config) [] end |