Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewMafiaServer ¶
func NewMafiaServer[T any](s Server[T], driverName string, dbUrl string, initDb bool) mafiaServer[T]
NewMafiaServer creates new instance of server for mafia game. s is a server that will be used internally. driverName and dbUrl specify connection to database/sql.DB. initDb specifies if "CREATE TABLE IF NOT EXISTS" should be called for tables needed internally.
Types ¶
type Server ¶
type Server[T any] interface { GetUpdatesChan() <-chan T // channel of updates from user UpdateToMessage(T) *UserMessage // transforms update to standard format SendMessage(ServerMessage) // sends message to user GetDefaultNick(int64) string // gets default user's nickname }
Server represents any endpoint user can chat with. Type T is an update from user format which is suitable for sending in chan
type ServerMessage ¶
type ServerMessage struct { User int64 // receiver of message Text string // text Options []string // options for user; if Options isn't nil and have 0 len, means previous options should be hidden }
ServerMessage represents message sent from server to user
type UserMessage ¶
type UserMessage struct { User int64 // user sent Text string // text Command bool // if message is a command }
UserMessage represents message sent from user to server
Click to show internal directories.
Click to hide internal directories.