Allow players to leave for up to 15 minutes after saying 'brb'
This commit is contained in:
parent
bc331bd240
commit
5e4b4e6d97
1 changed files with 7 additions and 0 deletions
|
@ -11,6 +11,7 @@ import (
|
|||
"math/big"
|
||||
"net"
|
||||
"os"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
"text/tabwriter"
|
||||
|
@ -27,6 +28,8 @@ var Game = &bgammon.GameState{
|
|||
Game: bgammon.NewGame(false),
|
||||
}
|
||||
|
||||
var nonAlpha = regexp.MustCompile(`[^a-zA-Z]+`)
|
||||
|
||||
type Client struct {
|
||||
Address string
|
||||
Username string
|
||||
|
@ -346,6 +349,10 @@ func (c *Client) HandleEvents() {
|
|||
log.Printf("*** %s", ev.Message)
|
||||
case *bgammon.EventSay:
|
||||
log.Printf("<%s> %s", ev.Player, ev.Message)
|
||||
if nonAlpha.ReplaceAllString(strings.ToLower(ev.Message), "") == "brb" {
|
||||
c.lastActivity = time.Now().Add(10 * time.Minute)
|
||||
c.Out <- []byte("say I will wait 15 minutes for your return.")
|
||||
}
|
||||
case *bgammon.EventList:
|
||||
case *bgammon.EventJoined:
|
||||
if ev.PlayerNumber == 1 {
|
||||
|
|
Loading…
Reference in a new issue