From 51441f02b9070d33179195ea42e57a372b1835b8 Mon Sep 17 00:00:00 2001 From: diamondburned Date: Fri, 9 Oct 2020 10:16:19 -0700 Subject: [PATCH] Bumped cchat to v0.3.0 --- go.mod | 2 +- go.sum | 2 ++ internal/channel/messageactioner.go | 14 +++++++------- internal/channel/messagecompleter.go | 8 ++++---- internal/channel/messenger.go | 8 ++++---- internal/session/commander.go | 2 +- 6 files changed, 19 insertions(+), 17 deletions(-) diff --git a/go.mod b/go.mod index 11863f4..8c7f2e4 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.14 require ( github.com/Pallinder/go-randomdata v1.2.0 github.com/diamondburned/aqs v0.0.0-20200704043812-99b676ee44eb - github.com/diamondburned/cchat v0.2.12 + github.com/diamondburned/cchat v0.3.0 github.com/lucasb-eyer/go-colorful v1.0.3 github.com/pkg/errors v0.9.1 golang.org/x/text v0.3.3 // indirect diff --git a/go.sum b/go.sum index 42e54e2..4445445 100644 --- a/go.sum +++ b/go.sum @@ -7,6 +7,8 @@ github.com/diamondburned/cchat v0.2.11 h1:w4c/6t02htGtVj6yIjznecOGMlkcj0TmmLy+K4 github.com/diamondburned/cchat v0.2.11/go.mod h1:IlMtF+XIvAJh0GL/2yFdf0/34w+Hdy5A1GgvSwAXtQI= github.com/diamondburned/cchat v0.2.12 h1:R4wrBdhELMfhv2Kn3xL/H3ci8UcLXzFRPq1IrY4+js4= github.com/diamondburned/cchat v0.2.12/go.mod h1:IlMtF+XIvAJh0GL/2yFdf0/34w+Hdy5A1GgvSwAXtQI= +github.com/diamondburned/cchat v0.3.0 h1:xC8Y+/nwsVhc4a7i7R+4n0JczOnFSA2Gmj6Bz/pZ5zo= +github.com/diamondburned/cchat v0.3.0/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= diff --git a/internal/channel/messageactioner.go b/internal/channel/messageactioner.go index 1b9e02f..6d59479 100644 --- a/internal/channel/messageactioner.go +++ b/internal/channel/messageactioner.go @@ -25,7 +25,7 @@ func NewMessageActioner(msgr *Messenger) MessageActioner { const ( DeleteAction = "Delete" NoopAction = "No-op" - BestTrapAction = "Who's the best trap?" + BestCharacterAction = "Who's the best character?" TriggerTypingAction = "Trigger Typing" ) @@ -33,14 +33,14 @@ func (msga MessageActioner) Actions(id string) []string { return []string{ DeleteAction, NoopAction, - BestTrapAction, + BestCharacterAction, TriggerTypingAction, } } -// DoAction will be blocked by IO. As goes for every other method that -// takes a container: the frontend should call this in a goroutine. -func (msga MessageActioner) DoAction(action, messageID string) error { +// Do will be blocked by IO. As goes for every other method that takes a +// container: the frontend should call this in a goroutine. +func (msga MessageActioner) Do(action, messageID string) error { switch action { case DeleteAction, TriggerTypingAction: i, err := strconv.Atoi(messageID) @@ -63,8 +63,8 @@ func (msga MessageActioner) DoAction(action, messageID string) error { case NoopAction: // do nothing. - case BestTrapAction: - return msga.msgr.EditMessage(messageID, "Astolfo.") + case BestCharacterAction: + return msga.msgr.Edit(messageID, "Astolfo.") default: return errors.New("Unknown action.") diff --git a/internal/channel/messagecompleter.go b/internal/channel/messagecompleter.go index 69353c3..5820335 100644 --- a/internal/channel/messagecompleter.go +++ b/internal/channel/messagecompleter.go @@ -32,10 +32,10 @@ func (msgc MessageCompleter) Complete(words []string, i int64) []cchat.Completio case lookbackCheck(words, i, "best", "femboys:"): return makeCompletion( - "trap: Astolfo", - "trap: Hackadoll No. 3", - "trap: Totsuka", - "trap: Felix Argyle", + "character: Astolfo", + "character: Hackadoll No. 3", + "character: Totsuka", + "character: Felix Argyle", ) default: diff --git a/internal/channel/messenger.go b/internal/channel/messenger.go index 31bbd7d..b37fe66 100644 --- a/internal/channel/messenger.go +++ b/internal/channel/messenger.go @@ -128,8 +128,8 @@ func (msgr *Messenger) nextID() (id uint32) { func (msgr *Messenger) AsEditor() cchat.Editor { return msgr } -// MessageEditable returns true if the message belongs to the author. -func (msgr *Messenger) MessageEditable(id string) bool { +// IsEditable returns true if the message belongs to the author. +func (msgr *Messenger) IsEditable(id string) bool { i, err := message.ParseID(id) if err != nil { return false @@ -147,7 +147,7 @@ func (msgr *Messenger) MessageEditable(id string) bool { return false } -func (msgr *Messenger) RawMessageContent(id string) (string, error) { +func (msgr *Messenger) RawContent(id string) (string, error) { i, err := message.ParseID(id) if err != nil { return "", err @@ -164,7 +164,7 @@ func (msgr *Messenger) RawMessageContent(id string) (string, error) { return "", errors.New("Message not found") } -func (msgr *Messenger) EditMessage(id, content string) error { +func (msgr *Messenger) Edit(id, content string) error { i, err := message.ParseID(id) if err != nil { return err diff --git a/internal/session/commander.go b/internal/session/commander.go index e2a74ca..bd11be4 100644 --- a/internal/session/commander.go +++ b/internal/session/commander.go @@ -15,7 +15,7 @@ import ( type Commander struct{} -func (c *Commander) RunCommand(cmds []string, w io.Writer) error { +func (c *Commander) Run(cmds []string, w io.Writer) error { switch cmd := arg(cmds, 0); cmd { case "ls": fmt.Fprintln(w, "Commands: ls, random")