Documentation ¶
Index ¶
- Constants
- func DebugHandler(room *Room, input chan PacketEvent, cmdChan chan string)
- func JoinEventHandler(room *Room, input chan PacketEvent, cmdChan chan string)
- func LinkTitleHandler(room *Room, input chan PacketEvent, cmdChan chan string)
- func MessageLogHandler(room *Room, input chan PacketEvent, cmdChan chan string)
- func NickChangeHandler(room *Room, input chan PacketEvent, cmdChan chan string)
- func PartEventHandler(room *Room, input chan PacketEvent, cmdChan chan string)
- func PingCommandHandler(room *Room, input chan PacketEvent, cmdChan chan string)
- func PingEventHandler(room *Room, input chan PacketEvent, cmdChan chan string)
- func ScritchCommandHandler(room *Room, input chan PacketEvent, cmdChan chan string)
- func SeenCommandHandler(room *Room, input chan PacketEvent, cmdChan chan string)
- func SeenRecordHandler(room *Room, input chan PacketEvent, cmdChan chan string)
- func UptimeCommandHandler(room *Room, input chan PacketEvent, cmdChan chan string)
- type AuthCommand
- type BounceEvent
- type Handler
- type Message
- type MsgLogEvent
- type NickCommand
- type NickEvent
- type NickReply
- type PacketEvent
- type PacketType
- type PingEvent
- type PingReply
- type PresenceEvent
- type Room
- type RoomConfig
- type SendCommand
- type SendEvent
- type SendReply
- type SenderReceiver
- type User
- type WSSenderReceiver
Constants ¶
const ( PingReplyType = "ping-reply" PingEventType = "ping-event" SendType = "send" SendEventType = "send-event" SendReplyType = "send-reply" NickType = "nick" NickReplyType = "nick-reply" NickEventType = "nick-event" JoinEventType = "join-event" PartEventType = "part-event" AuthType = "auth" BounceEventType = "bounce-event" )
These give named constants to the packet types.
Variables ¶
This section is empty.
Functions ¶
func DebugHandler ¶
func DebugHandler(room *Room, input chan PacketEvent, cmdChan chan string)
func JoinEventHandler ¶
func JoinEventHandler(room *Room, input chan PacketEvent, cmdChan chan string)
func LinkTitleHandler ¶
func LinkTitleHandler(room *Room, input chan PacketEvent, cmdChan chan string)
LinkTitleHandler handles a send-event, looks for URLs, and replies with the title text of a link if a valid one is found.
func MessageLogHandler ¶
func MessageLogHandler(room *Room, input chan PacketEvent, cmdChan chan string)
func NickChangeHandler ¶
func NickChangeHandler(room *Room, input chan PacketEvent, cmdChan chan string)
func PartEventHandler ¶
func PartEventHandler(room *Room, input chan PacketEvent, cmdChan chan string)
func PingCommandHandler ¶
func PingCommandHandler(room *Room, input chan PacketEvent, cmdChan chan string)
PingCommandHandler handles a send-event, checks for a !ping, and replies.
func PingEventHandler ¶
func PingEventHandler(room *Room, input chan PacketEvent, cmdChan chan string)
PingEventHandler processes a ping-event and replies with a ping-reply.
func ScritchCommandHandler ¶
func ScritchCommandHandler(room *Room, input chan PacketEvent, cmdChan chan string)
func SeenCommandHandler ¶
func SeenCommandHandler(room *Room, input chan PacketEvent, cmdChan chan string)
SeenCommandHandler handles a send-event, checks if !seen command was given, and responds. TODO : make seen record a time when a user joins a room or changes their nick
func SeenRecordHandler ¶
func SeenRecordHandler(room *Room, input chan PacketEvent, cmdChan chan string)
SeenRecordHandler handles a send-event and records that the sender was seen.
func UptimeCommandHandler ¶
func UptimeCommandHandler(room *Room, input chan PacketEvent, cmdChan chan string)
UptimeCommandHandler handlers a send-event and if the command is given replies with the time since the bot was started.
Types ¶
type AuthCommand ¶
type BounceEvent ¶
type Handler ¶
type Handler func(room *Room, input chan PacketEvent, cmdChan chan string)
Handler describes functions that process packets.
type Message ¶
type Message struct { ID string `json:"id"` Parent string `json:"parent"` PreviousEditID string `json:"previous_edit_id,omitempty"` Time int64 `json:"time"` Sender User `json:"sender"` Content string `json:"content"` EncryptionKeyID string `json:"encryption_key_id,omitempty"` Edited int `json:"edited,omitempty"` Deleted int `json:"deleted,omitempty"` }
Message is a unit of data associated with a text message sent on the service.
func GetMessagePayload ¶
func GetMessagePayload(packet *PacketEvent) *Message
type MsgLogEvent ¶
type NickCommand ¶
type NickCommand struct {
Name string `json:"name"`
}
type NickEvent ¶
type NickEvent NickReply
func GetNickEventPayload ¶
func GetNickEventPayload(packet *PacketEvent) *NickEvent
type PacketEvent ¶
type PacketEvent struct { ID string `json:"id"` Type PacketType `json:"type"` Data json.RawMessage `json:"data,omitempty"` Error string `json:"error,omitempty"` }
PacketEvent is the skeleton of a packet, its payload is composed of another type or types.
func MakePacket ¶
func MakePacket(ID string, msgType PacketType, payload interface{}) (*PacketEvent, error)
func (*PacketEvent) Payload ¶
func (p *PacketEvent) Payload() (interface{}, error)
Payload unmarshals the packet payload into the proper Event type and returns it.
type PingEvent ¶
PingEvent encodes the server's information on when this ping occurred and when the next will.
type PresenceEvent ¶
func GetPresenceEventPayload ¶
func GetPresenceEventPayload(packet *PacketEvent) *PresenceEvent
type Room ¶
Room represents a connection to a euphoria room and associated data.
func NewRoom ¶
func NewRoom(roomCfg *RoomConfig, room string, sr SenderReceiver, logger *logrus.Logger) (*Room, error)
NewRoom creates a new room with the given configurations.
func (*Room) Run ¶
func (r *Room) Run()
Run provides a method for setup and the main loop that the bot will run with handlers.
func (*Room) SendAuth ¶
func (r *Room) SendAuth()
Auth sends an authentication packet with the given password.
type RoomConfig ¶
type RoomConfig struct { DBPath string ErrorLogPath string Join bool MsgLog bool MsgPrefix string Nick string Password string }
RoomConfig stores configuration options specific to a Room.
type SendCommand ¶
type SenderReceiver ¶
type SenderReceiver interface {
// contains filtered or unexported methods
}
type User ¶
type User struct { ID string `json:"id"` Name string `json:"name"` ServerID string `json:"server_id"` ServerEra string `json:"server_era"` }
User encodes the information about a user in the room. Name may be duplicated within a room
type WSSenderReceiver ¶
type WSSenderReceiver struct { Room string // contains filtered or unexported fields }
func NewWSSenderReceiver ¶
func NewWSSenderReceiver(room string, logger *logrus.Logger) *WSSenderReceiver