talkapi

package module
v0.0.0-...-fb21806 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CmdCall

type CmdCall struct {
	Room,
	From,
	Args string
}

type Message

type Message struct {
	Room,
	From,
	Data,
	DMTo string
}

type Session

type Session struct {
	ErrorChan chan error
	// contains filtered or unexported fields
}

func NewSession

func NewSession(address string, token string) (*Session, error)

NewSession connects to the Talk server and creates a session. The address should be in the form of "host:port".

func (*Session) Close

func (s *Session) Close() error

Close closes the session.

func (*Session) RegisterCmd

func (s *Session) RegisterCmd(name, argsInfo, info string, onCmd func(CmdCall, error)) error

RegisterCmd registers a command. onCmd is called when the command is used. If onCmd returns true, the client stops listening for command usages.

func (*Session) RegisterListener

func (s *Session) RegisterListener(middleware, once bool, regex string) (messageChan chan Message, middlewareResponseChan chan string, err error)

RegisterListener allows for message monitoring and intercepting/editing. Set middleware to true to intercept and edit messages. Set once to true to unregister the listener after the first message is received. Set regex to a valid regex string to only receive messages that match the regex.

messageChan will receive messages that match the regex. middlewareResponseChan is used to send back the edited message. You must send a response if middleware is true even if you don't edit the message. See example/main.go for correct usage of this function.

func (*Session) SendMessage

func (s *Session) SendMessage(m Message) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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