-
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
52 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,41 @@ | ||
package connector | ||
|
||
import ( | ||
"go.mau.fi/util/configupgrade" | ||
_ "embed" | ||
|
||
up "go.mau.fi/util/configupgrade" | ||
) | ||
|
||
type TwitterConfig struct { | ||
//go:embed example-config.yaml | ||
var ExampleConfig string | ||
|
||
type Config struct { | ||
Proxy string `yaml:"proxy"` | ||
GetProxyURL string `yaml:"get_proxy_url"` | ||
|
||
UsernameTemplate string `yaml:"username_template"` | ||
DisplaynameTemplate string `yaml:"displayname_template"` | ||
DisplayNameMaxLength int `yaml:"displayname_max_length"` | ||
|
||
DeliveryReceipts bool `yaml:"delivery_receipts"` | ||
|
||
//displaynameTemplate *template.Template `yaml:"-"` | ||
} | ||
|
||
func upgradeConfig(helper up.Helper) { | ||
helper.Copy(up.Str|up.Null, "proxy") | ||
helper.Copy(up.Str|up.Null, "get_proxy_url") | ||
|
||
helper.Copy(up.Str, "username_template") | ||
helper.Copy(up.Str, "displayname_template") | ||
helper.Copy(up.Int, "displayname_max_length") | ||
|
||
helper.Copy(up.Bool, "delivery_receipts") | ||
} | ||
|
||
func (tc *TwitterConnector) GetConfig() (example string, data any, upgrader configupgrade.Upgrader) { | ||
return "", nil, configupgrade.NoopUpgrader | ||
func (tc *TwitterConnector) GetConfig() (string, any, up.Upgrader) { | ||
return ExampleConfig, &tc.Config, &up.StructUpgrader{ | ||
SimpleUpgrader: up.SimpleUpgrader(upgradeConfig), | ||
Base: ExampleConfig, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Proxy to use for all Twitter connections. | ||
proxy: null | ||
# Alternative to proxy: an HTTP endpoint that returns the proxy URL to use for Twitter connections. | ||
get_proxy_url: null | ||
|
||
# Localpart template of MXIDs for Twitter users. | ||
# {userid} is replaced with the user ID of the Twitter user. | ||
username_template: "twitter_{userid}" | ||
# Displayname template for Twitter users. | ||
# {displayname} is replaced with the display name of the Twitter user. | ||
# {username} is replaced with the username of the Twitter user. | ||
displayname_template: "{displayname} (Twitter)" | ||
# Maximum length of displayname | ||
displayname_max_length: 100 | ||
|
||
# Whether the bridge should send a read receipt from the bridge bot when a message has | ||
# been sent to Twitter. | ||
delivery_receipts: false |