1
0
Fork 0
mirror of https://github.com/diamondburned/cchat-mock.git synced 2024-12-25 04:37:15 +00:00

Revert "bumped cchat, removed nonces"

This reverts commit 5b60b5ff2a.
This commit is contained in:
diamondburned 2020-12-17 14:28:44 -08:00
parent 5b60b5ff2a
commit a2b02ef6c2
4 changed files with 19 additions and 4 deletions

2
go.mod
View file

@ -5,7 +5,7 @@ go 1.14
require (
github.com/Pallinder/go-randomdata v1.2.0
github.com/diamondburned/aqs v0.0.0-20201115033607-76f603ff676a
github.com/diamondburned/cchat v0.3.12
github.com/diamondburned/cchat v0.3.11
github.com/lucasb-eyer/go-colorful v1.0.3
github.com/pkg/errors v0.9.1
golang.org/x/text v0.3.3 // indirect

2
go.sum
View file

@ -23,8 +23,6 @@ github.com/diamondburned/cchat v0.3.9 h1:qsYUz68aBApoMz7zo1snrIz3U/ljPJ+YyRhZcpQ
github.com/diamondburned/cchat v0.3.9/go.mod h1:IlMtF+XIvAJh0GL/2yFdf0/34w+Hdy5A1GgvSwAXtQI=
github.com/diamondburned/cchat v0.3.11 h1:C1f9Tp7Kz3t+T1SlepL1RS7b/kACAKWAIZXAgJEpCHg=
github.com/diamondburned/cchat v0.3.11/go.mod h1:IlMtF+XIvAJh0GL/2yFdf0/34w+Hdy5A1GgvSwAXtQI=
github.com/diamondburned/cchat v0.3.12 h1:mew54lsDrwrJs4U2FtdbNFl/wAZcueIgZCsImHQzVL4=
github.com/diamondburned/cchat v0.3.12/go.mod h1:IlMtF+XIvAJh0GL/2yFdf0/34w+Hdy5A1GgvSwAXtQI=
github.com/go-test/deep v1.0.7/go.mod h1:QV8Hv/iy04NyLBxAdO9njL0iVPN1S4d/A3NVv1V36o8=
github.com/k0kubun/colorstring v0.0.0-20150214042306-9440f1994b88/go.mod h1:3w7q1U84EfirKl04SVQ/s7nPm1ZPhiXd34z40TNz36k=
github.com/k0kubun/pp v3.0.1+incompatible/go.mod h1:GWse8YhT0p8pT4ir3ZgBbfZild3tgzSScAn6HmfYukg=

View file

@ -1,6 +1,8 @@
package channel
import (
"time"
"github.com/diamondburned/cchat"
"github.com/diamondburned/cchat-mock/internal/internet"
"github.com/pkg/errors"
@ -28,7 +30,13 @@ func (msgs MessageSender) Send(msg cchat.SendableMessage) error {
return errors.Wrap(err, "Failed to send message")
}
go func() {
// Make no guarantee that a message may arrive immediately when the
// function exits.
<-time.After(time.Second)
msgs.ch <- msg
}()
return nil
}

View file

@ -15,12 +15,14 @@ type Message struct {
Header
author Author
content string
nonce string
}
var (
_ cchat.MessageCreate = (*Message)(nil)
_ cchat.MessageUpdate = (*Message)(nil)
_ cchat.MessageDelete = (*Message)(nil)
_ cchat.Noncer = (*Message)(nil)
)
func NewEmpty(id uint32, author Author) Message {
@ -48,6 +50,9 @@ func Echo(sendable cchat.SendableMessage, id uint32, author Author) Message {
author: author,
content: sendable.Content(),
}
if noncer := sendable.AsNoncer(); noncer != nil {
echo.nonce = noncer.Nonce()
}
return echo
}
@ -80,6 +85,10 @@ func (m Message) Content() text.Rich {
return text.Rich{Content: m.content}
}
func (m Message) Nonce() string {
return m.nonce
}
// Mentioned is true when the message content contains the author's name.
func (m Message) Mentioned() bool {
// hack