mirror of
https://github.com/diamondburned/cchat-mock.git
synced 2024-11-30 09:02:54 +00:00
Added mock message completiong
This commit is contained in:
parent
66db865abc
commit
a3e768c864
19
channel.go
19
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 {
|
||||
|
|
2
go.mod
2
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
|
||||
)
|
||||
|
|
2
go.sum
2
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=
|
||||
|
|
Loading…
Reference in a new issue