1
0
Fork 0
mirror of https://github.com/diamondburned/cchat-discord.git synced 2024-12-22 20:36:45 +00:00

bumped cchat; added replier; minor fixes

This commit is contained in:
diamondburned 2021-01-01 14:35:35 -08:00
parent d8599a5287
commit ef4cb53185
6 changed files with 25 additions and 8 deletions

2
go.mod
View file

@ -4,7 +4,7 @@ go 1.14
require (
github.com/diamondburned/arikawa/v2 v2.0.0-20210101083335-169b36126239
github.com/diamondburned/cchat v0.3.15
github.com/diamondburned/cchat v0.3.17
github.com/diamondburned/ningen/v2 v2.0.0-20210101084041-d9a5058b63b5
github.com/dustin/go-humanize v1.0.0
github.com/go-test/deep v1.0.7

4
go.sum
View file

@ -132,6 +132,10 @@ github.com/diamondburned/cchat v0.3.14 h1:nDr9DJ1EW3kab4gieE+DLhpvHRws+umWpw5XrO
github.com/diamondburned/cchat v0.3.14/go.mod h1:IlMtF+XIvAJh0GL/2yFdf0/34w+Hdy5A1GgvSwAXtQI=
github.com/diamondburned/cchat v0.3.15 h1:BJf8ZiRtDWTGMtQ3QqjNU0H+784WSrkJEpFGkKY5gEw=
github.com/diamondburned/cchat v0.3.15/go.mod h1:IlMtF+XIvAJh0GL/2yFdf0/34w+Hdy5A1GgvSwAXtQI=
github.com/diamondburned/cchat v0.3.16 h1:vRF8BeypyQ6yr0wK/odGStrmrbB+1WkNcjIwP+SMZeo=
github.com/diamondburned/cchat v0.3.16/go.mod h1:IlMtF+XIvAJh0GL/2yFdf0/34w+Hdy5A1GgvSwAXtQI=
github.com/diamondburned/cchat v0.3.17 h1:pGwas8Y0SBU7yg4EQ/MvrbqZhrnRhPBYm1AiRsL147s=
github.com/diamondburned/cchat v0.3.17/go.mod h1:IlMtF+XIvAJh0GL/2yFdf0/34w+Hdy5A1GgvSwAXtQI=
github.com/diamondburned/ningen v0.1.1-0.20200621014632-6babb812b249 h1:yP7kJ+xCGpDz6XbcfACJcju4SH1XDPwlrvbofz3lP8I=
github.com/diamondburned/ningen v0.1.1-0.20200621014632-6babb812b249/go.mod h1:xW9hpBZsGi8KpAh10TyP+YQlYBo+Xc+2w4TR6N0951A=
github.com/diamondburned/ningen v0.1.1-0.20200708085949-b64e350f3b8c h1:3h/kyk6HplYZF3zLi106itjYJWjbuMK/twijeGLEy2M=

View file

@ -38,6 +38,8 @@ func (nn Nicknamer) Nickname(ctx context.Context, labeler cchat.LabelContainer)
return func() {}, nil
}
nn.tryNicknameLabel(ctx, labeler)
return funcutil.JoinCancels(
nn.State.AddHandler(func(chunks *gateway.GuildMembersChunkEvent) {
if chunks.GuildID != nn.GuildID {
@ -66,11 +68,9 @@ func (nn Nicknamer) tryNicknameLabel(ctx context.Context, labeler cchat.LabelCon
state := nn.State.WithContext(ctx)
m, err := state.Cabinet.Member(nn.GuildID, nn.userID)
if err != nil {
return
if err == nil {
nn.setMember(labeler, *m)
}
nn.setMember(labeler, *m)
}
func (nn Nicknamer) setMember(labeler cchat.LabelContainer, m discord.Member) {

View file

@ -12,13 +12,24 @@ import (
func WrapMessage(s *state.Instance, msg cchat.SendableMessage) api.SendMessageData {
var send = api.SendMessageData{Content: msg.Content()}
if attacher := msg.AsAttachments(); attacher != nil {
if attacher := msg.AsAttacher(); attacher != nil {
send.Files = addAttachments(attacher.Attachments())
}
if noncer := msg.AsNoncer(); noncer != nil {
send.Nonce = s.Nonces.Generate(noncer.Nonce())
}
if replier := msg.AsReplier(); replier != nil {
id, err := discord.ParseSnowflake(replier.ReplyingTo())
if err == nil {
send.Reference = &discord.MessageReference{
MessageID: discord.MessageID(id),
}
}
}
return send
}

View file

@ -1,6 +1,7 @@
package message
import (
"strings"
"time"
"github.com/diamondburned/arikawa/v2/discord"
@ -171,7 +172,7 @@ func NewMessage(m discord.Message, s *state.Instance, author Author) Message {
refmsg = refmsg[:120] + "..."
}
content.Content = refmsg + "\n"
content.Content = strings.ReplaceAll(refmsg, "\n", " ") + "\n"
content.Segments = []text.Segment{
reference.NewMessageSegment(0, len(refmsg), ref.ID),
}

View file

@ -2,6 +2,7 @@ package session
import (
"context"
"log"
"github.com/diamondburned/arikawa/v2/gateway"
"github.com/diamondburned/arikawa/v2/session"
@ -84,7 +85,7 @@ func (s *Session) Servers(container cchat.ServersContainer) error {
// Set the entire container again once reconnected.
s.state.AddHandler(func(*ningen.Connected) {
s.servers(container)
log.Println("[Discord] ningen.Connected received, error:", s.servers(container))
})
return s.servers(container)