diff --git a/channel.go b/channel.go index a61a358..212044b 100644 --- a/channel.go +++ b/channel.go @@ -4,6 +4,7 @@ import ( "errors" "math/rand" "strconv" + "strings" "sync/atomic" "time" @@ -21,8 +22,10 @@ type Channel struct { } var ( - _ cchat.Server = (*Channel)(nil) - _ cchat.ServerMessage = (*Channel)(nil) + _ cchat.Server = (*Channel)(nil) + _ cchat.ServerMessage = (*Channel)(nil) + _ cchat.ServerMessageSender = (*Channel)(nil) + _ cchat.ServerMessageSendCompleter = (*Channel)(nil) ) func (ch *Channel) ID() string { @@ -75,6 +78,18 @@ func (ch *Channel) SendMessage(msg cchat.SendableMessage) error { return nil } +func (ch *Channel) CompleteMessage(words []string, i int) []string { + switch { + case strings.HasPrefix("complete", words[i]): + words[i] = "complete" + case strings.HasPrefix("me", words[i]) && i > 0 && words[i-1] == "complete": + words[i] = "me" + default: + return nil + } + return words +} + func generateChannels(s *Service, amount int) []cchat.Server { var channels = make([]cchat.Server, amount) for i := range channels { diff --git a/go.mod b/go.mod index f22271a..2c94056 100644 --- a/go.mod +++ b/go.mod @@ -4,5 +4,5 @@ go 1.14 require ( github.com/Pallinder/go-randomdata v1.2.0 - github.com/diamondburned/cchat v0.0.4 + github.com/diamondburned/cchat v0.0.5 ) diff --git a/go.sum b/go.sum index a49ba50..f56b7f3 100644 --- a/go.sum +++ b/go.sum @@ -8,3 +8,5 @@ github.com/diamondburned/cchat v0.0.3 h1:XpuRcs+RhdFOGfsD3uCporEhVo8HQ5s95Qlj+4U github.com/diamondburned/cchat v0.0.3/go.mod h1:2MdhWABRer4WhwcuLR0b2VY5S22Y1zDTpFqriAFrC08= github.com/diamondburned/cchat v0.0.4 h1:RSuAX3T4PsPOPBDNZMTt6Mr+g1UZQ3A7vSBf9QPS7uQ= github.com/diamondburned/cchat v0.0.4/go.mod h1:2MdhWABRer4WhwcuLR0b2VY5S22Y1zDTpFqriAFrC08= +github.com/diamondburned/cchat v0.0.5 h1:g0+569jnFqx4euNsqjurqjAY+xxG5n8kmGnDRwA8qFs= +github.com/diamondburned/cchat v0.0.5/go.mod h1:2MdhWABRer4WhwcuLR0b2VY5S22Y1zDTpFqriAFrC08=