internal

package
v0.0.0-...-57ebd91 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 14, 2024 License: AGPL-3.0 Imports: 45 Imported by: 0

Documentation

Index

Constants

View Source
const (
	WechatLoggedOut        status.BridgeStateErrorCode = "wechat-logged-out"
	WechatNotConnected     status.BridgeStateErrorCode = "wechat-not-connected"
	WechatConnecting       status.BridgeStateErrorCode = "wechat-connecting"
	WechatConnectionFailed status.BridgeStateErrorCode = "wechat-connection-failed"
)
View Source
const (
	PrivateChatTopic = "WeChat private chat"
)

Variables

View Source
var (
	HelpSectionConnectionManagement = commands.HelpSection{Name: "Connection management", Order: 11}
	HelpSectionCreatingPortals      = commands.HelpSection{Name: "Creating portals", Order: 15}
	HelpSectionPortalManagement     = commands.HelpSection{Name: "Portal management", Order: 20}
	HelpSectionInvites              = commands.HelpSection{Name: "Group invites", Order: 25}
	HelpSectionMiscellaneous        = commands.HelpSection{Name: "Miscellaneous", Order: 30}
)
View Source
var (
	ErrStatusBroadcastDisabled = errors.New("status bridging is disabled")

	PortalCreationDummyEvent = event.Type{Type: "me.lxduo.wechat.dummy.portal_created", Class: event.MessageEventType}
)
View Source
var (
	ErrAlreadyLoggedIn = errors.New("already logged in")
)
View Source
var (
	UserAgent = "" /* 130-byte string literal not displayed */

)

Functions

func GetBytes

func GetBytes(url string) ([]byte, error)

func HTTPGetReadCloser

func HTTPGetReadCloser(url string) (io.ReadCloser, error)

func NewGzipReadCloser

func NewGzipReadCloser(reader io.ReadCloser) (io.ReadCloser, error)

func ReplaceEmotion

func ReplaceEmotion(content string) string

Types

type ConvertedMessage

type ConvertedMessage struct {
	Intent  *appservice.IntentAPI
	Type    event.Type
	Content *event.MessageEventContent
	Extra   map[string]interface{}
	Caption *event.MessageEventContent

	ReplyTo  *ReplyInfo
	Error    database.MessageErrorType
	MediaKey []byte
}

type Formatter

type Formatter struct {
	// contains filtered or unexported fields
}

func NewFormatter

func NewFormatter(br *WechatBridge) *Formatter

func (*Formatter) GetMatrixInfoByUID

func (f *Formatter) GetMatrixInfoByUID(roomID id.RoomID, uid types.UID) (id.UserID, string)

func (*Formatter) ParseMatrix

func (f *Formatter) ParseMatrix(html string, mentions *event.Mentions) (string, []string)

type Portal

type Portal struct {
	*database.Portal
	// contains filtered or unexported fields
}

func (*Portal) ChangeAdminStatus

func (p *Portal) ChangeAdminStatus(uids []types.UID, setAdmin bool) id.EventID

func (*Portal) Cleanup

func (p *Portal) Cleanup(puppetsOnly bool)

func (*Portal) CleanupIfEmpty

func (p *Portal) CleanupIfEmpty()

func (*Portal) CreateMatrixRoom

func (p *Portal) CreateMatrixRoom(user *User, groupInfo *wechat.GroupInfo, isFullInfo bool) error

func (*Portal) Delete

func (p *Portal) Delete()

func (*Portal) GetBasePowerLevels

func (p *Portal) GetBasePowerLevels() *event.PowerLevelsEventContent

func (*Portal) GetEncryptionEventContent

func (p *Portal) GetEncryptionEventContent() (evt *event.EncryptionEventContent)

func (*Portal) GetMatrixUsers

func (p *Portal) GetMatrixUsers() ([]id.UserID, error)

func (*Portal) GetUsers

func (p *Portal) GetUsers() []*User

func (*Portal) HandleMatrixInvite

func (p *Portal) HandleMatrixInvite(brSender bridge.User, brTarget bridge.Ghost)

func (*Portal) HandleMatrixKick

func (p *Portal) HandleMatrixKick(brSender bridge.User, brTarget bridge.Ghost)

func (*Portal) HandleMatrixLeave

func (p *Portal) HandleMatrixLeave(brSender bridge.User)

func (*Portal) HandleMatrixMessage

func (p *Portal) HandleMatrixMessage(sender *User, evt *event.Event)

func (*Portal) HandleMatrixMeta

func (p *Portal) HandleMatrixMeta(brSender bridge.User, evt *event.Event)

func (*Portal) HandleMatrixReaction

func (p *Portal) HandleMatrixReaction(sender *User, evt *event.Event)

func (*Portal) HandleMatrixRedaction

func (p *Portal) HandleMatrixRedaction(sender *User, evt *event.Event)

func (*Portal) IsEncrypted

func (p *Portal) IsEncrypted() bool

func (*Portal) IsGroupChat

func (p *Portal) IsGroupChat() bool

func (*Portal) IsPrivateChat

func (p *Portal) IsPrivateChat() bool

func (*Portal) MainIntent

func (p *Portal) MainIntent() *appservice.IntentAPI

func (*Portal) MarkEncrypted

func (p *Portal) MarkEncrypted()

func (*Portal) ReceiveMatrixEvent

func (p *Portal) ReceiveMatrixEvent(user bridge.User, evt *event.Event)

func (*Portal) RestrictMessageSending

func (p *Portal) RestrictMessageSending(restrict bool) id.EventID

func (*Portal) RestrictMetadataChanges

func (p *Portal) RestrictMetadataChanges(restrict bool) id.EventID

func (*Portal) SetReply

func (p *Portal) SetReply(content *event.MessageEventContent, replyTo *ReplyInfo) bool

func (*Portal) SyncParticipants

func (p *Portal) SyncParticipants(source *User, metadata *wechat.GroupInfo, forceAvatarSync bool)

func (*Portal) UpdateAvatar

func (p *Portal) UpdateAvatar(user *User, setBy types.UID, updateInfo bool) bool

func (*Portal) UpdateBridgeInfo

func (p *Portal) UpdateBridgeInfo()

func (*Portal) UpdateMatrixRoom

func (p *Portal) UpdateMatrixRoom(user *User, groupInfo *wechat.GroupInfo, forceAvatarSync bool) bool

func (*Portal) UpdateMetadata

func (p *Portal) UpdateMetadata(user *User, groupInfo *wechat.GroupInfo, forceAvatarSync bool) bool

func (*Portal) UpdateName

func (p *Portal) UpdateName(name string, setBy types.UID, updateInfo bool) bool

func (*Portal) UpdateRoomNickname

func (p *Portal) UpdateRoomNickname(source *User, wxid string)

func (*Portal) UpdateTopic

func (p *Portal) UpdateTopic(topic string, setBy types.UID, updateInfo bool) bool

type PortalMatrixMessage

type PortalMatrixMessage struct {
	// contains filtered or unexported fields
}

type PortalMessage

type PortalMessage struct {
	// contains filtered or unexported fields
}

type Puppet

type Puppet struct {
	*database.Puppet

	MXID id.UserID
	// contains filtered or unexported fields
}

func (*Puppet) ClearCustomMXID

func (p *Puppet) ClearCustomMXID()

func (*Puppet) CustomIntent

func (p *Puppet) CustomIntent() *appservice.IntentAPI

func (*Puppet) DefaultIntent

func (p *Puppet) DefaultIntent() *appservice.IntentAPI

func (*Puppet) GetAvatarURL

func (p *Puppet) GetAvatarURL() id.ContentURI

func (*Puppet) GetDisplayname

func (p *Puppet) GetDisplayname() string

func (*Puppet) GetMXID

func (p *Puppet) GetMXID() id.UserID

func (*Puppet) IntentFor

func (p *Puppet) IntentFor(portal *Portal) *appservice.IntentAPI

func (*Puppet) StartCustomMXID

func (p *Puppet) StartCustomMXID(reloginOnFail bool) error

func (*Puppet) SwitchCustomMXID

func (p *Puppet) SwitchCustomMXID(accessToken string, mxid id.UserID) error

func (*Puppet) Sync

func (p *Puppet) Sync(source *User, contact *types.ContactInfo, forceAvatarSync, forcePortalSync bool)

func (*Puppet) SyncContact

func (p *Puppet) SyncContact(source *User, forceAvatarSync bool, reason string)

func (*Puppet) UpdateAvatar

func (p *Puppet) UpdateAvatar(source *User, forceAvatarSync bool, forcePortalSync bool) bool

func (*Puppet) UpdateName

func (p *Puppet) UpdateName(contact types.ContactInfo, forcePortalSync bool) bool

type ReplyInfo

type ReplyInfo struct {
	MessageID string
	Sender    types.UID
}

type User

type User struct {
	*database.User

	Client *wechat.WechatClient

	Admin           bool
	Whitelisted     bool
	PermissionLevel bridgeconfig.PermissionLevel

	BridgeState *bridge.BridgeStateQueue
	// contains filtered or unexported fields
}

func (*User) Connect

func (u *User) Connect() error

func (*User) DeleteConnection

func (u *User) DeleteConnection()

func (*User) DeleteSession

func (u *User) DeleteSession()

func (*User) EnqueuePortalResync

func (u *User) EnqueuePortalResync(portal *Portal)

func (*User) EnqueuePuppetResync

func (u *User) EnqueuePuppetResync(puppet *Puppet)

func (*User) GetCommandState

func (u *User) GetCommandState() map[string]interface{}

func (*User) GetIDoublePuppet

func (user *User) GetIDoublePuppet() bridge.DoublePuppet

func (*User) GetIGhost

func (user *User) GetIGhost() bridge.Ghost

func (*User) GetMXID

func (u *User) GetMXID() id.UserID

func (*User) GetManagementRoom

func (u *User) GetManagementRoom() id.RoomID

func (*User) GetManagementRoomID

func (u *User) GetManagementRoomID() id.RoomID

func (*User) GetPermissionLevel

func (u *User) GetPermissionLevel() bridgeconfig.PermissionLevel

func (*User) GetPortalByUID

func (u *User) GetPortalByUID(uid types.UID) *Portal

func (*User) GetRemoteID

func (user *User) GetRemoteID() string

func (*User) GetRemoteName

func (user *User) GetRemoteName() string

func (*User) GetSpaceRoom

func (u *User) GetSpaceRoom() id.RoomID

func (*User) IsLoggedIn

func (u *User) IsLoggedIn() bool

func (*User) LoginWtihQRCode

func (u *User) LoginWtihQRCode() []byte

func (*User) MarkLogin

func (u *User) MarkLogin()

func (*User) ResyncContacts

func (u *User) ResyncContacts(forceAvatarSync bool) error

func (*User) ResyncGroups

func (u *User) ResyncGroups(createPortals bool) error

func (*User) SetManagementRoom

func (u *User) SetManagementRoom(roomID id.RoomID)

func (*User) StartPM

func (u *User) StartPM(uid types.UID, reason string) (*Portal, *Puppet, bool, error)

func (*User) UpdateDirectChats

func (u *User) UpdateDirectChats(chats map[id.UserID][]id.RoomID)

type WechatBridge

type WechatBridge struct {
	bridge.Bridge
	Config        *config.Config
	DB            *database.Database
	Formatter     *Formatter
	WechatService *wechat.WechatService
	ExampleConfig string
	// contains filtered or unexported fields
}

func NewWechatBridge

func NewWechatBridge(exampleConfig string) *WechatBridge

func (*WechatBridge) CreatePrivatePortal

func (br *WechatBridge) CreatePrivatePortal(roomID id.RoomID, brInviter bridge.User, brGhost bridge.Ghost)

func (*WechatBridge) FormatPuppetMXID

func (br *WechatBridge) FormatPuppetMXID(uid types.UID) id.UserID

func (*WechatBridge) GetAllIPortals

func (br *WechatBridge) GetAllIPortals() (iportals []bridge.Portal)

func (*WechatBridge) GetAllPortals

func (br *WechatBridge) GetAllPortals() []*Portal

func (*WechatBridge) GetAllPortalsByUID

func (br *WechatBridge) GetAllPortalsByUID(uid types.UID) []*Portal

func (*WechatBridge) GetAllPuppets

func (br *WechatBridge) GetAllPuppets() []*Puppet

func (*WechatBridge) GetAllPuppetsWithCustomMXID

func (br *WechatBridge) GetAllPuppetsWithCustomMXID() []*Puppet

func (*WechatBridge) GetAllUsers

func (br *WechatBridge) GetAllUsers() []*User

func (*WechatBridge) GetConfigPtr

func (br *WechatBridge) GetConfigPtr() interface{}

func (*WechatBridge) GetExampleConfig

func (br *WechatBridge) GetExampleConfig() string

func (*WechatBridge) GetIGhost

func (br *WechatBridge) GetIGhost(id id.UserID) bridge.Ghost

func (*WechatBridge) GetIPortal

func (br *WechatBridge) GetIPortal(mxid id.RoomID) bridge.Portal

func (*WechatBridge) GetIUser

func (br *WechatBridge) GetIUser(userID id.UserID, create bool) bridge.User

ChildOverride

func (*WechatBridge) GetPortalByMXID

func (br *WechatBridge) GetPortalByMXID(mxid id.RoomID) *Portal

func (*WechatBridge) GetPortalByUID

func (br *WechatBridge) GetPortalByUID(key database.PortalKey) *Portal

func (*WechatBridge) GetPuppetByCustomMXID

func (br *WechatBridge) GetPuppetByCustomMXID(mxid id.UserID) *Puppet

func (*WechatBridge) GetPuppetByMXID

func (br *WechatBridge) GetPuppetByMXID(mxid id.UserID) *Puppet

func (*WechatBridge) GetPuppetByUID

func (br *WechatBridge) GetPuppetByUID(uid types.UID) *Puppet

func (*WechatBridge) GetUserByMXID

func (br *WechatBridge) GetUserByMXID(userID id.UserID) *User

func (*WechatBridge) GetUserByMXIDIfExists

func (br *WechatBridge) GetUserByMXIDIfExists(userID id.UserID) *User

func (*WechatBridge) GetUserByUID

func (br *WechatBridge) GetUserByUID(uid types.UID) *User

func (*WechatBridge) HandlePresence

func (br *WechatBridge) HandlePresence(evt *event.Event)

func (*WechatBridge) Init

func (br *WechatBridge) Init()

func (*WechatBridge) IsGhost

func (br *WechatBridge) IsGhost(id id.UserID) bool

func (*WechatBridge) NewManualPortal

func (br *WechatBridge) NewManualPortal(key database.PortalKey) *Portal

func (*WechatBridge) NewPortal

func (br *WechatBridge) NewPortal(dbPortal *database.Portal) *Portal

func (*WechatBridge) NewPuppet

func (br *WechatBridge) NewPuppet(dbPuppet *database.Puppet) *Puppet

func (*WechatBridge) NewUser

func (br *WechatBridge) NewUser(dbUser *database.User) *User

func (*WechatBridge) ParsePuppetMXID

func (br *WechatBridge) ParsePuppetMXID(mxid id.UserID) (uid types.UID, ok bool)

func (*WechatBridge) RegisterCommands

func (br *WechatBridge) RegisterCommands()

func (*WechatBridge) Start

func (br *WechatBridge) Start()

func (*WechatBridge) StartUsers

func (br *WechatBridge) StartUsers()

func (*WechatBridge) Stop

func (br *WechatBridge) Stop()

type WrappedCommandEvent

type WrappedCommandEvent struct {
	*commands.Event
	Bridge *WechatBridge
	User   *User
	Portal *Portal
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL