internal

package
v0.0.0-...-747a129 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: 57 Imported by: 0

Documentation

Index

Constants

View Source
const (
	QQLoggedOut        status.BridgeStateErrorCode = "qq-logged-out"
	QQNotConnected     status.BridgeStateErrorCode = "qq-not-connected"
	QQConnecting       status.BridgeStateErrorCode = "qq-connecting"
	QQConnectionFailed status.BridgeStateErrorCode = "qq-connection-failed"
)
View Source
const BridgeStatusConnected = "CONNECTED"
View Source
const DefaultSyncProxyBackoff = 1 * time.Second
View Source
const MaxSyncProxyBackoff = 60 * time.Second
View Source
const (
	PrivateChatTopic = "QQ 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 (
	ErrNoCustomMXID    = errors.New("no custom mxid set")
	ErrMismatchingMXID = errors.New("whoami result does not match custom mxid")
)
View Source
var (
	ErrStatusBroadcastDisabled = errors.New("status bridging is disabled")

	PortalCreationDummyEvent = event.Type{Type: "me.lxduo.qq.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 RandomString

func RandomString(len int) string

func RandomStringRange

func RandomStringRange(length int, str string) string

Types

type BridgeStatus

type BridgeStatus struct {
	StateEvent string    `json:"state_event"`
	Timestamp  int64     `json:"timestamp"`
	TTL        int       `json:"ttl"`
	Source     string    `json:"source"`
	Error      string    `json:"error,omitempty"`
	Message    string    `json:"message,omitempty"`
	UserID     id.UserID `json:"user_id,omitempty"`
	RemoteID   string    `json:"remote_id,omitempty"`
	RemoteName string    `json:"remote_name,omitempty"`

	Info map[string]interface{} `json:"info,omitempty"`
}

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 *QQBridge) *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) []message.IMessageElement

type PingData

type PingData struct {
	Timestamp int64 `json:"timestamp"`
}

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 *client.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) HandleQQGroupMemberInvite

func (p *Portal) HandleQQGroupMemberInvite(source *User, senderUID types.UID, targetUID types.UID)

func (*Portal) HandleQQGroupMemberKick

func (p *Portal) HandleQQGroupMemberKick(source *User, senderUID types.UID, targetUID types.UID)

func (*Portal) HandleQQMessageRevoke

func (p *Portal) HandleQQMessageRevoke(source *User, msgSeq int32, ts int64, operator int64)

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 *client.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 *client.GroupInfo, forceAvatarSync bool) bool

func (*Portal) UpdateMetadata

func (p *Portal) UpdateMetadata(user *User, groupInfo *client.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(info *client.GroupMemberInfo)

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) 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) GetFilterJSON

func (p *Puppet) GetFilterJSON(_ id.UserID) *mautrix.Filter

func (*Puppet) GetMXID

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

func (*Puppet) IntentFor

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

func (*Puppet) LoadFilterID

func (p *Puppet) LoadFilterID(_ id.UserID) string

func (*Puppet) LoadNextBatch

func (p *Puppet) LoadNextBatch(_ id.UserID) string

func (*Puppet) LoadRoom

func (p *Puppet) LoadRoom(_ id.RoomID) *mautrix.Room

func (*Puppet) OnFailedSync

func (p *Puppet) OnFailedSync(_ *mautrix.RespSync, err error) (time.Duration, error)

func (*Puppet) ProcessResponse

func (p *Puppet) ProcessResponse(resp *mautrix.RespSync, _ string) error

func (*Puppet) SaveFilterID

func (p *Puppet) SaveFilterID(_ id.UserID, _ string)

func (*Puppet) SaveNextBatch

func (p *Puppet) SaveNextBatch(_ id.UserID, nbt string)

func (*Puppet) SaveRoom

func (p *Puppet) SaveRoom(_ *mautrix.Room)

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 QQBridge

type QQBridge struct {
	bridge.Bridge
	Config        *config.Config
	DB            *database.Database
	Formatter     *Formatter
	ExampleConfig string

	WebsocketHandler *WebsocketCommandHandler
	// contains filtered or unexported fields
}

func NewQQBridge

func NewQQBridge(exampleConfig string) *QQBridge

func (*QQBridge) CreatePrivatePortal

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

func (*QQBridge) FormatPuppetMXID

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

func (*QQBridge) GetAllIPortals

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

func (*QQBridge) GetAllPortals

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

func (*QQBridge) GetAllPortalsByUID

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

func (*QQBridge) GetAllPuppets

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

func (*QQBridge) GetAllPuppetsWithCustomMXID

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

func (*QQBridge) GetAllUsers

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

func (*QQBridge) GetConfigPtr

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

func (*QQBridge) GetExampleConfig

func (br *QQBridge) GetExampleConfig() string

func (*QQBridge) GetIGhost

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

func (*QQBridge) GetIPortal

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

func (*QQBridge) GetIUser

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

ChildOverride

func (*QQBridge) GetPortalByMXID

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

func (*QQBridge) GetPortalByUID

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

func (*QQBridge) GetPuppetByCustomMXID

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

func (*QQBridge) GetPuppetByMXID

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

func (*QQBridge) GetPuppetByUID

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

func (*QQBridge) GetUserByMXID

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

func (*QQBridge) GetUserByMXIDIfExists

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

func (*QQBridge) GetUserByUID

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

func (*QQBridge) GetUserByUin

func (br *QQBridge) GetUserByUin(uin string) *User

func (*QQBridge) HandlePresence

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

func (*QQBridge) Init

func (br *QQBridge) Init()

func (*QQBridge) IsGhost

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

func (*QQBridge) NewManualPortal

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

func (*QQBridge) NewPortal

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

func (*QQBridge) NewPuppet

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

func (*QQBridge) NewUser

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

func (*QQBridge) ParsePuppetMXID

func (br *QQBridge) ParsePuppetMXID(mxid id.UserID) (types.UID, bool)

func (*QQBridge) PingServer

func (br *QQBridge) PingServer() (start, serverTs, end time.Time)

func (*QQBridge) RegisterCommands

func (br *QQBridge) RegisterCommands()

func (*QQBridge) RequestStartSync

func (br *QQBridge) RequestStartSync()

func (*QQBridge) SendBridgeStatus

func (br *QQBridge) SendBridgeStatus()

func (*QQBridge) Start

func (br *QQBridge) Start()

func (*QQBridge) StartUsers

func (br *QQBridge) StartUsers()

func (*QQBridge) Stop

func (br *QQBridge) Stop()

type ReplyInfo

type ReplyInfo struct {
	ReplySeq int32
	Time     int32
	Sender   types.UID
}

type Request

type Request struct {
	Method string
	URL    string
	Header map[string]string
	Limit  int64
	Body   io.Reader
}

Request is a file download request

func (Request) Bytes

func (r Request) Bytes() ([]byte, error)

type StartSyncRequest

type StartSyncRequest struct {
	AccessToken string      `json:"access_token"`
	DeviceID    id.DeviceID `json:"device_id"`
	UserID      id.UserID   `json:"user_id"`
}

type User

type User struct {
	*database.User

	Client     *client.QQClient
	DeviceInfo *client.DeviceInfo

	Admin           bool
	Whitelisted     bool
	PermissionLevel bridgeconfig.PermissionLevel

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

func (*User) Connect

func (u *User) Connect() bool

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() *commands.CommandState

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) LoginPassword

func (u *User) LoginPassword(uin int64, password string) (*client.LoginResponse, error)

func (*User) LoginQR

func (u *User) LoginQR() (<-chan *client.QRCodeLoginResponse, error)

func (*User) LoginToken

func (u *User) LoginToken(encodedDevice, encodedToken string) error

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) SetCommandState

func (u *User) SetCommandState(s *commands.CommandState)

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 WebsocketCommandHandler

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

func NewWebsocketCommandHandler

func NewWebsocketCommandHandler(br *QQBridge) *WebsocketCommandHandler

func (*WebsocketCommandHandler) HandleSyncProxyError

func (mx *WebsocketCommandHandler) HandleSyncProxyError(syncErr *mautrix.RespError, startErr error)

type WrappedCommandEvent

type WrappedCommandEvent struct {
	*commands.Event
	Bridge *QQBridge
	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