morpheus

package
v0.0.0-...-d87adc8 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2018 License: BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ConsoleUserID          string = "@morpheus:localhost"
	ConsoleUserDisplayName string = "morpheus"
	ConsoleRoomID          string = "!console:localhost"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Callbacks

type Callbacks struct {
	AddUser    func(r *Room, u *User)
	DelUser    func(r *Room, u *User)
	UpdateUser func(r *Room, u *User)

	AddRoom    func(r *Room)
	DelRoom    func(r *Room)
	UpdateRoom func(r *Room, state RoomState)

	ArrvMessage func(r *Room, e *Event)

	Cmd func(r *Room, args []string)
}

type Client

type Client struct {
	Rs Rooms
	// contains filtered or unexported fields
}

func NewClient

func NewClient(configName string, configPaths []string, call Callbacks) (*Client, error)

func (*Client) AddRoom

func (c *Client) AddRoom(roomID, name, canonAlias, topic string) *Room

func (*Client) ConsolePrint

func (c *Client) ConsolePrint(txtType MsgTxtType, args ...interface{})

func (*Client) ConsolePrintf

func (c *Client) ConsolePrintf(txtType MsgTxtType, format string, args ...interface{})

func (*Client) DebugBuf

func (c *Client) DebugBuf() *bytes.Buffer

func (*Client) DebugPrint

func (c *Client) DebugPrint(args ...interface{})

func (*Client) DebugPrintf

func (c *Client) DebugPrintf(format string, args ...interface{})

func (*Client) GetDisplayName

func (c *Client) GetDisplayName() string

func (*Client) GetPrevEvents

func (c *Client) GetPrevEvents(r *Room, num uint) (uint, error)

func (*Client) GetUserID

func (c *Client) GetUserID() string

func (*Client) JoinRoom

func (c *Client) JoinRoom(roomIDorAlias string)

TODO: Return error

func (*Client) LeaveRoom

func (c *Client) LeaveRoom(roomID string)

TODO: Return error

func (*Client) Login

func (c *Client) Login() error

func (*Client) SendText

func (c *Client) SendText(roomID, body string)

TODO: Handle error, maybe hold message if unsuccesful

func (*Client) StopSync

func (c *Client) StopSync()

TODO: Actually stop the c.cli.Sync()

func (*Client) Sync

func (c *Client) Sync() error

type Config

type Config struct {
	Username    string
	UserID      string
	DisplayName string
	Password    string
	Homeserver  string
}

type Event

type Event struct {
	Type     string
	ID       string
	Ts       int64
	Sender   string
	StateKey *string
	Content  interface{}
}

type Events

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

func NewEvents

func NewEvents() (evs Events)

func (*Events) Back

func (evs *Events) Back() *list.Element

func (*Events) Front

func (evs *Events) Front() *list.Element

func (*Events) Iterator

func (evs *Events) Iterator() *EventsIterator

func (*Events) LastEvent

func (evs *Events) LastEvent() *Event

func (*Events) Len

func (evs *Events) Len() int

func (*Events) PushBack

func (evs *Events) PushBack(e interface{})

func (*Events) PushBackEvent

func (evs *Events) PushBackEvent(e *Event)

func (*Events) PushFront

func (evs *Events) PushFront(e interface{})

func (*Events) PushFrontEvent

func (evs *Events) PushFrontEvent(e *Event)

type EventsIterator

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

func (*EventsIterator) Next

func (evsIt *EventsIterator) Next() *list.Element

type ExpBackoff

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

func NewExpBackoff

func NewExpBackoff(max uint32) ExpBackoff

func (*ExpBackoff) Inc

func (eb *ExpBackoff) Inc()

func (*ExpBackoff) Reset

func (eb *ExpBackoff) Reset()

func (*ExpBackoff) Wait

func (eb *ExpBackoff) Wait()

type GenMap

type GenMap map[string]interface{}

func NewGenMap

func NewGenMap() GenMap

func (*GenMap) StringKey

func (m *GenMap) StringKey(k string) string

type Membership

type Membership int
const (
	MemInvite     Membership = iota
	MemJoin       Membership = iota
	MemLeave      Membership = iota
	MemBan        Membership = iota
	MembershipLen Membership = iota
)

func (Membership) String

func (mem Membership) String() string

type Message

type Message struct {
	MsgType string
	//ID      string
	//Ts      int64
	//Sender  string
	Content interface{}
}

type MsgTxtType

type MsgTxtType int
const (
	MsgTxtTypeText   MsgTxtType = iota
	MsgTxtTypeEmote  MsgTxtType = iota
	MsgTxtTypeNotice MsgTxtType = iota
)

type Room

type Room struct {
	Users Users
	//Msgs        *list.List
	Events Events

	HasFirstMsg bool
	HasLastMsg  bool

	Rooms *Rooms

	ExpBackoff ExpBackoff
	UI         interface{}
	// contains filtered or unexported fields
}

func NewRoom

func NewRoom(rs *Rooms, id string, mem Membership, name, canonAlias, topic string) (r *Room)

func (*Room) CanonAlias

func (r *Room) CanonAlias() string

func (*Room) ClearFrontEvents

func (r *Room) ClearFrontEvents(n int)

func (*Room) DispName

func (r *Room) DispName() string

func (*Room) ID

func (r *Room) ID() string

func (*Room) Mem

func (r *Room) Mem() Membership

func (*Room) Name

func (r *Room) Name() string

func (*Room) PushEvent

func (r *Room) PushEvent(ev *gomatrix.Event) error

func (*Room) PushFrontMessage

func (r *Room) PushFrontMessage(msgType, id string, ts int64, userID string,
	content map[string]interface{}) error

func (*Room) PushFrontToken

func (r *Room) PushFrontToken(token string)

func (*Room) PushMessage

func (r *Room) PushMessage(msgType, id string, ts int64, userID string,
	content map[string]interface{}) error

func (*Room) PushTextMessage

func (r *Room) PushTextMessage(txtType MsgTxtType, id string, ts int64, userID, body string) error

func (*Room) PushToken

func (r *Room) PushToken(token string)

func (*Room) SetCanonAlias

func (r *Room) SetCanonAlias(alias string)

func (*Room) SetMembership

func (r *Room) SetMembership(mem Membership)

func (*Room) SetName

func (r *Room) SetName(name string)

func (*Room) SetTopic

func (r *Room) SetTopic(topic string)

func (*Room) String

func (r *Room) String() string

func (*Room) Topic

func (r *Room) Topic() string

type RoomState

type RoomState int
const (
	RoomStateAll        RoomState = iota
	RoomStateName       RoomState = iota
	RoomStateDispName   RoomState = iota
	RoomStateTopic      RoomState = iota
	RoomStateMembership RoomState = iota
)

type Rooms

type Rooms struct {
	R []*Room

	UI interface{}
	// contains filtered or unexported fields
}

func NewRooms

func NewRooms(call Callbacks) (rs Rooms)

func (*Rooms) AddConsoleMessage

func (rs *Rooms) AddConsoleMessage(msgType string, content map[string]interface{}) error

func (*Rooms) AddConsoleTextMessage

func (rs *Rooms) AddConsoleTextMessage(txtType MsgTxtType, body string) error

func (*Rooms) AddUpdate

func (rs *Rooms) AddUpdate(myUserID *string, roomID string, mem Membership) *Room

Add or Update the Room

func (*Rooms) ByID

func (rs *Rooms) ByID(id string) *Room

func (*Rooms) ByName

func (rs *Rooms) ByName(name string) []*Room

func (*Rooms) ConsoleRoom

func (rs *Rooms) ConsoleRoom() *Room

func (*Rooms) Del

func (rs *Rooms) Del(roomID string) (*Room, error)

func (*Rooms) SetConsoleRoom

func (rs *Rooms) SetConsoleRoom(r *Room)

func (*Rooms) SetRoomName

func (rs *Rooms) SetRoomName(r *Room, name string)

type StateRoomCanonAlias

type StateRoomCanonAlias struct {
	Alias string
}

type StateRoomJoinRules

type StateRoomJoinRules struct {
	IsPublic bool
}

type StateRoomMember

type StateRoomMember struct {
	Name       string
	Membership Membership
}

type StateRoomName

type StateRoomName struct {
	Name string
}

type StateRoomTopic

type StateRoomTopic struct {
	Topic string
}

type TextMessage

type TextMessage struct {
	Body string
	Type MsgTxtType
}

type Token

type Token string

type User

type User struct {
	UI interface{}
	// contains filtered or unexported fields
}

func NewUser

func NewUser(id string) *User

func (*User) DispName

func (u *User) DispName() string

func (*User) ID

func (u *User) ID() string

func (*User) Mem

func (u *User) Mem() Membership

func (*User) Name

func (u *User) Name() string

func (*User) Power

func (u *User) Power() int

func (*User) String

func (u *User) String() string

type Users

type Users struct {
	U []*User

	MemCount [MembershipLen]int

	Room *Room
	// contains filtered or unexported fields
}

func (*Users) AddUpdate

func (us *Users) AddUpdate(id, name string, power int, mem Membership) (*User, error)

Add or Update the User

func (*Users) ByID

func (us *Users) ByID(id string) *User

func (*Users) Del

func (us *Users) Del(u *User)

func (*Users) MemCountDelta

func (us *Users) MemCountDelta(memOld, memNew Membership, deltaOld, deltaNew int)

func (*Users) SetUserName

func (us *Users) SetUserName(u *User, name string)

Jump to

Keyboard shortcuts

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