-
-
Notifications
You must be signed in to change notification settings - Fork 16
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
1 parent
2d44714
commit 8cc5250
Showing
8 changed files
with
172 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/bin/sh | ||
if [[ -z "$LIBRARY_PATH" && -d /opt/homebrew ]]; then | ||
echo "Using /opt/homebrew for LIBRARY_PATH and CPATH" | ||
export LIBRARY_PATH=/opt/homebrew/lib | ||
export CPATH=/opt/homebrew/include | ||
fi | ||
export MAUTRIX_VERSION=$(cat go.mod | grep 'maunium.net/go/mautrix ' | awk '{ print $2 }') | ||
export GO_LDFLAGS="-s -w -X main.Tag=$(git describe --exact-match --tags 2>/dev/null) -X main.Commit=$(git rev-parse HEAD) -X 'main.BuildTime=`date '+%b %_d %Y, %H:%M:%S'`' -X 'maunium.net/go/mautrix.GoModVersion=$MAUTRIX_VERSION'" | ||
go build -ldflags "$GO_LDFLAGS" -o mautrix-meta ./cmd/mautrix-meta "$@" |
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,29 @@ | ||
package main | ||
|
||
import ( | ||
_ "go.mau.fi/util/dbutil/litestream" | ||
"maunium.net/go/mautrix/bridgev2/matrix/mxmain" | ||
|
||
"go.mau.fi/mautrix-meta/pkg/connector" | ||
) | ||
|
||
// Information to find out exactly which commit the bridge was built from. | ||
// These are filled at build time with the -X linker flag. | ||
var ( | ||
Tag = "unknown" | ||
Commit = "unknown" | ||
BuildTime = "unknown" | ||
) | ||
|
||
func main() { | ||
m := mxmain.BridgeMain{ | ||
Name: "mautrix-meta", | ||
URL: "https://github.com/mautrix/meta", | ||
Description: "A Matrix-Meta puppeting bridge.", | ||
Version: "0.16.0", | ||
|
||
Connector: connector.NewConnector(), | ||
} | ||
m.InitVersion(Tag, Commit, BuildTime) | ||
m.Run() | ||
} |
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
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,22 @@ | ||
package connector | ||
|
||
import ( | ||
_ "embed" | ||
up "go.mau.fi/util/configupgrade" | ||
|
||
) | ||
|
||
//go:embed example-config.yaml | ||
var ExampleConfig string | ||
|
||
type MetaConfig struct { | ||
Mode string `yaml:"mode"` | ||
} | ||
|
||
func upgradeConfig(helper up.Helper) { | ||
helper.Copy(up.Str, "mode") | ||
} | ||
|
||
func (s *MetaConnector) GetConfig() (string, any, up.Upgrader) { | ||
return ExampleConfig, &s.Config, up.SimpleUpgrader(upgradeConfig) | ||
} |
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,57 @@ | ||
package connector | ||
|
||
import ( | ||
"context" | ||
|
||
"maunium.net/go/mautrix/bridgev2" | ||
) | ||
|
||
type MetaConnector struct { | ||
Bridge *bridgev2.Bridge | ||
Config *MetaConfig | ||
} | ||
|
||
func NewConnector() *MetaConnector { | ||
return &MetaConnector{} | ||
} | ||
|
||
var _ bridgev2.NetworkConnector = (*MetaConnector)(nil) | ||
var _ bridgev2.MaxFileSizeingNetwork = (*MetaConnector)(nil) | ||
|
||
func (m *MetaConnector) SetMaxFileSize(maxSize int64) { | ||
println("SetMaxFileSize unimplemented") | ||
} | ||
|
||
var metaGeneralCaps = &bridgev2.NetworkGeneralCapabilities{ | ||
DisappearingMessages: false, | ||
AggressiveUpdateInfo: false, | ||
} | ||
|
||
func (m *MetaConnector) GetCapabilities() *bridgev2.NetworkGeneralCapabilities { | ||
return metaGeneralCaps | ||
} | ||
|
||
func (s *MetaConnector) GetName() bridgev2.BridgeName { | ||
// Would be nice if we could use MetaConfig.Mode here, but it's not available yet? | ||
return bridgev2.BridgeName{ | ||
DisplayName: "Meta", | ||
NetworkURL: "https://meta.com", | ||
NetworkIcon: "mxc://maunium.net/JxjlbZUlCPULEeHZSwleUXQv", // Instagram icon | ||
NetworkID: "meta", | ||
BeeperBridgeType: "meta", | ||
DefaultPort: 29328, | ||
} | ||
} | ||
|
||
func (m *MetaConnector) Init(*bridgev2.Bridge) { | ||
println("Connector Init unimplemented") | ||
} | ||
|
||
func (m *MetaConnector) Start(context.Context) error { | ||
println("Connector Start unimplemented") | ||
return nil | ||
} | ||
|
||
func (m *MetaConnector) LoadUserLogin(ctx context.Context, login *bridgev2.UserLogin) error { | ||
panic("unimplemented") | ||
} |
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,3 @@ | ||
# Which service is this bridge for? Either "facebook" or "instagram". | ||
# Remember to change the appservice id, bot profile info and bridge username_template too. | ||
mode: instagram |
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,49 @@ | ||
package connector | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
"maunium.net/go/mautrix/bridgev2" | ||
) | ||
|
||
func (m *MetaConnector) CreateLogin(ctx context.Context, user *bridgev2.User, flowID string) (bridgev2.LoginProcess, error) { | ||
if flowID != "cookies" { | ||
return nil, fmt.Errorf("unknown flow ID %s", flowID) | ||
} | ||
|
||
return &CookieLogin{}, nil | ||
} | ||
|
||
func (m *MetaConnector) GetLoginFlows() []bridgev2.LoginFlow { | ||
return []bridgev2.LoginFlow{{ | ||
Name: "Cookies", | ||
Description: "Login using cookies from a web browser", | ||
ID: "cookies", | ||
}} | ||
} | ||
|
||
type CookieLogin struct {} | ||
|
||
var _ bridgev2.LoginProcessCookies = (*CookieLogin)(nil) | ||
|
||
func (p *CookieLogin) Start(ctx context.Context) (*bridgev2.LoginStep, error) { | ||
return &bridgev2.LoginStep{ | ||
Type: bridgev2.LoginStepTypeCookies, | ||
StepID: "fi.mau.meta.cookies", | ||
Instructions: "Please enter cookies from your browser", | ||
CookiesParams: &bridgev2.LoginCookiesParams{ | ||
|
||
}, | ||
}, nil | ||
} | ||
|
||
func (c *CookieLogin) Cancel() {} | ||
|
||
func (p *CookieLogin) SubmitCookies(ctx context.Context, cookies map[string]string) (*bridgev2.LoginStep, error) { | ||
return &bridgev2.LoginStep{ | ||
Type: bridgev2.LoginStepTypeComplete, | ||
StepID: "fi.mau.meta.complete", | ||
Instructions: "Login successful", | ||
}, nil | ||
} |