chat

package
v0.0.0-...-937b28e Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2022 License: GPL-3.0 Imports: 8 Imported by: 9

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SendNotification

func SendNotification(message string, room int)

Types

type ChatMessage

type ChatMessage struct {
	// Message ID
	ID        uint          `json:"id"`
	CreatedAt time.Time     `json:"timestamp"`
	Player    player.Player `json:"-"`
	PlayerID  uint          `json:"-"`                               // ID of the player who sent the message
	Room      int           `json:"room"`                            // room to which the message was sent
	Message   string        `json:"message" sql:"type:varchar(150)"` // the actual Message
	Deleted   bool          `json:"deleted"`                         // true if the message has been deleted by a moderator
	Bot       bool          `json:"bot"`                             // true if the message was sent by the notification "bot"
	InGame    bool          `json:"ingame"`                          // true if the message is in-game
}

ChatMessage Represents a chat mesasge sent by a particular player

func GetPlayerMessages

func GetPlayerMessages(p *player.Player) ([]*ChatMessage, error)

Return all messages sent by player to room

func GetRoomMessages

func GetRoomMessages(room int) ([]*ChatMessage, error)

Return a list of ChatMessages spoken in room

func GetScrollback

func GetScrollback(room int) ([]*ChatMessage, error)

Get a list of last 20 messages sent to room, used by frontend for displaying the chat history/scrollback

func NewBotMessage

func NewBotMessage(message string, room int) *ChatMessage

func NewChatMessage

func NewChatMessage(message string, room int, player *player.Player) *ChatMessage

Return a new ChatMessage sent from specficied player

func NewInGameChatMessage

func NewInGameChatMessage(lobbyID uint, player *player.Player, message string) *ChatMessage

func (*ChatMessage) MarshalJSON

func (m *ChatMessage) MarshalJSON() ([]byte, error)

func (*ChatMessage) Save

func (m *ChatMessage) Save()

func (*ChatMessage) Send

func (m *ChatMessage) Send()

Jump to

Keyboard shortcuts

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