dog

package
v0.0.0-...-b1dd1d8 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2020 License: MIT Imports: 21 Imported by: 3

Documentation

Index

Constants

View Source
const (
	// Opts flags
	BEXDisabled uint64 = 1 << 0
	DMDisabled  uint64 = 1 << 1
	DebugXMPP   uint64 = 1 << 2
	Human       uint64 = 1 << 3
)
View Source
const BexServer = "https://bex.pg.ikrypto.club"

Variables

View Source
var (
	// Separates this extension from a regular plaintext Cryptodog message.
	BEX_MAGIC = []byte{0x04, 0x45, 0xFF}
)

Functions

func ContainsBEXHeader

func ContainsBEXHeader(input []byte) bool

func EncodeBEX

func EncodeBEX(b []BEX) []byte

func ValidColor

func ValidColor(str string) bool

Types

type BEX

type BEX struct {
	Header        BEXHeader
	Color         string   `json:"color,omitempty"`
	Status        string   `json:"color,omitempty"`
	File          *File    `json:"file,omitempty"`
	MessageType   string   `json:"messageType,omitempty"`
	Message       string   `json:"message,omitempty"`
	SDPType       string   `json:"sdpType,omitempty"`
	SDPData       string   `json:"sdpData,omitempty"`
	ICECandidate  string   `json:"iceCandidate,omitempty"`
	SDPMLineIndex uint64   `json:"sdpMLineIndex,omitempty"`
	SDPMid        string   `json:"sdpMid,omitempty"`
	Target        string   `json:"target,omitempty"`
	Level         uint64   `json:"level,omitempty"`
	TableKey      string   `json:"tableKey,omitempty"`
	Table         []string `json:"table,omitempty"`
}

func DecodeBEX

func DecodeBEX(input []byte) ([]BEX, error)

type BEXHeader

type BEXHeader uint64
const (
	NOT_VALID BEXHeader = 0
	// Packet headers
	SET_COLOR            BEXHeader = 1
	PING                 BEXHeader = 2
	PONG                 BEXHeader = 3
	BEX_COMPOSING        BEXHeader = 4
	BEX_PAUSED           BEXHeader = 5
	FILE_ATTACHMENT      BEXHeader = 6
	TEXT_MESSAGE         BEXHeader = 7
	FLAG_ME_AS_BOT       BEXHeader = 8
	STATUS_ONLINE        BEXHeader = 9
	STATUS_AWAY          BEXHeader = 10
	MOD_ELECTED          BEXHeader = 11
	REMOVE_DEAD_USERS    BEXHeader = 12
	SET_MODERATION_TABLE BEXHeader = 13
	SET_LOCKDOWN_LEVEL   BEXHeader = 14
	WHITELIST_USER       BEXHeader = 15

	// WebRTC
	ICE_CANDIDATE         BEXHeader = 30
	RTC_OFFER             BEXHeader = 31
	RTC_ANSWER            BEXHeader = 32
	RTC_SIGNAL_CAPABILITY BEXHeader = 33
	RTC_SIGNAL_DISABLED   BEXHeader = 34
)

func (BEXHeader) String

func (b BEXHeader) String() string

type Conn

type Conn struct {
	// Public Options
	DB         Database
	URL        string
	Host       string
	Conference string
	Proxy      string
	Opts       uint64
	// contains filtered or unexported fields
}

func New

func New() *Conn

func (*Conn) ActiveRooms

func (c *Conn) ActiveRooms() []string

func (*Conn) Answer

func (c *Conn) Answer(room, user, answer string)

func (*Conn) Ask

func (c *Conn) Ask(room, user, question, answer string)

func (*Conn) DM

func (c *Conn) DM(room, user, message string)

func (*Conn) Disconnect

func (c *Conn) Disconnect()

func (*Conn) GM

func (c *Conn) GM(room string, body string)

func (*Conn) GMf

func (c *Conn) GMf(room string, format string, args ...interface{})

func (*Conn) GetMods

func (c *Conn) GetMods() []string

func (*Conn) GetRoom

func (c *Conn) GetRoom(name string) *Room

func (*Conn) Group

func (c *Conn) Group(room string, b []byte)

func (*Conn) JoinRoom

func (c *Conn) JoinRoom(room, nick string)

func (*Conn) On

func (c *Conn) On(_type EventType, handler EventHandler)

On registers a function that will handle an Event.

func (*Conn) Run

func (c *Conn) Run() error

func (*Conn) SetColor

func (c *Conn) SetColor(color string) error

func (*Conn) SetMods

func (c *Conn) SetMods(s []string)

func (*Conn) Uptime

func (c *Conn) Uptime() time.Duration

type Database

type Database interface {
	Load(k interface{}) (interface{}, bool)
	Store(k, v interface{})
	Delete(k interface{})
}

type Disk_DB

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

func Disk

func Disk(path string) *Disk_DB

func FolderStore

func FolderStore(folderName string) *Disk_DB

func (*Disk_DB) Delete

func (d *Disk_DB) Delete(key interface{})

func (*Disk_DB) Load

func (d *Disk_DB) Load(key interface{}) (interface{}, bool)

func (*Disk_DB) Store

func (d *Disk_DB) Store(key, value interface{})

type Event

type Event struct {
	Type    EventType
	Private bool
	Room    string
	User    string
	Body    string
	File    *File
}

Event describes

type EventHandler

type EventHandler func(Event)

type EventType

type EventType int
const (
	Any EventType = iota
	RateLimit
	NicknameInUse
	Disconnected
	Connected
	UserJoined
	UserLeft
	GroupMessage
	PrivateMessage
	SMPQuestion
	SMPAnswer
	SMPSuccess
	SMPFailure
	Composing
	Paused
	ColorModify
	FileAttachment
	SubscribedToModerator
	RoomJoined
	WebRTCCapable
	WebRTCOffer
	WebRTCAnswer
	WebRTCIceCandidate
	InvalidGroupMessage
)

type File

type File struct {
	PrefixSize uint64
	FileKey    *[32]byte
	FileNonce  *[24]byte
	FileMIME   string
	FileUUID   etc.UUID
}

type ICECandidate

type ICECandidate struct {
	Data          string `json:"data"`
	SDPMid        string `json:"sdpMid"`
	SDPMLineIndex uint64 `json:"sdpMLineIndex"`
}

type Member

type Member struct {
	Bot bool
	// contains filtered or unexported fields
}

func (*Member) Answer

func (m *Member) Answer(data string)

func (*Member) Ask

func (m *Member) Ask(question, answer string)

func (*Member) DM

func (m *Member) DM(data string)

func (*Member) HandleMessageEvent

func (m *Member) HandleMessageEvent(event otr3.MessageEvent, message []byte, err error, trace ...interface{})

func (*Member) HandleSMPEvent

func (m *Member) HandleSMPEvent(event otr3.SMPEvent, progressPercent int, question string)

func (*Member) HandleSecurityEvent

func (m *Member) HandleSecurityEvent(event otr3.SecurityEvent)

func (*Member) Name

func (m *Member) Name() string

func (*Member) Raw

func (m *Member) Raw(str string)

type Room

type Room struct {
	Name             string
	MyName           string
	Mp               *multiparty.Me
	Members          map[string]*Member
	ModerationTables map[string][]string
	// contains filtered or unexported fields
}

func (*Room) DM

func (r *Room) DM(user, data string)

func (*Room) Destroy

func (r *Room) Destroy()

func (*Room) Download

func (r *Room) Download(f *File) ([]byte, error)

func (*Room) GM

func (r *Room) GM(body string)

func (*Room) GetMember

func (r *Room) GetMember(s string) *Member

func (*Room) GetUsernames

func (m *Room) GetUsernames() []string

func (*Room) Group

func (r *Room) Group(b []byte)

func (*Room) GroupFingerprint

func (m *Room) GroupFingerprint(user string) string

func (*Room) IsBlocked

func (r *Room) IsBlocked(user string) bool

func (*Room) IsMod

func (r *Room) IsMod(user string) bool

func (*Room) SendBEXGroup

func (r *Room) SendBEXGroup(b []BEX)

func (*Room) SendBEXPrivate

func (r *Room) SendBEXPrivate(nickname string, b []BEX)

func (*Room) SendGroupComposing

func (m *Room) SendGroupComposing()

Sends group composing message via Binary Extensions.

func (*Room) SendGroupPaused

func (m *Room) SendGroupPaused()

Sends group paused message via Binary Extensions.

func (*Room) SendPrivateComposing

func (m *Room) SendPrivateComposing(target string)

Sends private composing message via Binary Extensions

func (*Room) SendPrivatePaused

func (m *Room) SendPrivatePaused(target string)

Sends private paused message via Binary Extensions

func (*Room) SendXGroupComposing

func (m *Room) SendXGroupComposing()

Sends composing message via XMPP.

func (*Room) SendXGroupPaused

func (m *Room) SendXGroupPaused()

func (*Room) SendXPrivateComposing

func (m *Room) SendXPrivateComposing(target string)

func (*Room) SendXPrivatePaused

func (m *Room) SendXPrivatePaused(target string)

func (*Room) SetModerationTable

func (r *Room) SetModerationTable(tk string, tv []string)

func (*Room) Upload

func (r *Room) Upload(fileMime string, data []byte) (*File, error)

Jump to

Keyboard shortcuts

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