Class: Async::Matrix::Bridge::Discord::DB::Puppet

Inherits:
Sequel::Model
  • Object
show all
Defined in:
lib/async/matrix/bridge/discord/db/puppet.rb

Overview

Maps a Discord user to a Matrix ghost user.

The ghost’s Matrix ID is derived from the username template in the bridge config (e.g., @discord_123456:example.com). This model tracks the Discord user’s profile info for syncing to Matrix.

puppet = Puppet.create(discord_id: "123", username: "alice", name: "Alice")
puppet.is_bot?          # => false
puppet.double_puppet?   # => true  (if custom_mxid is set)

Instance Method Summary collapse

Instance Method Details

#double_puppet?Boolean

Is this puppet configured for double puppeting?

Returns:

  • (Boolean)


33
34
35
# File 'lib/async/matrix/bridge/discord/db/puppet.rb', line 33

def double_puppet?
  !custom_mxid.nil? && !custom_mxid.empty?
end

#validateObject



27
28
29
30
# File 'lib/async/matrix/bridge/discord/db/puppet.rb', line 27

def validate
  super
  errors.add(:discord_id, "cannot be empty") if discord_id.nil? || discord_id.empty?
end