Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: published brainery time #16

Merged
merged 1 commit into from
Jun 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ ENV GOOS=linux GOARCH=amd64 CGO_ENABLED=0
RUN go install -v ./...

FROM alpine:3.15.0
RUN apk --no-cache add ca-certificates
RUN apk add --no-cache \
ca-certificates \
tzdata

RUN ln -fs /usr/share/zoneinfo/Asia/Ho_Chi_Minh /etc/localtime
WORKDIR /

Expand Down
5 changes: 4 additions & 1 deletion pkg/discord/command/brainery/brainery_post.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ func (e *Brainery) Post(message *model.DiscordMessage) error {
rawFormattedContent := formatString(message.RawContent)
now := time.Now()

loc, _ := time.LoadLocation("Asia/Ho_Chi_Minh")
publishedAt := now.In(loc)

extractURL := extractPattern(rawFormattedContent, urlRegexPattern)
extractDiscordID := extractPattern(rawFormattedContent, discordIDRegexPattern)
extractTags := extractPattern(rawFormattedContent, tagRegexPattern)
Expand Down Expand Up @@ -68,7 +71,7 @@ func (e *Brainery) Post(message *model.DiscordMessage) error {
DiscordID: extractDiscordID[0],
Description: desc,
Reward: reward,
PublishedAt: &now,
PublishedAt: &publishedAt,
Tags: extractTags,
Github: gh,
}
Expand Down
7 changes: 2 additions & 5 deletions pkg/discord/view/brainery/brainery.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package brainery
import (
"fmt"
"strings"
"time"

"github.com/bwmarrin/discordgo"
"github.com/shopspring/decimal"
Expand Down Expand Up @@ -76,11 +77,7 @@ func (v *Brainery) Post(original *model.DiscordMessage, content *model.Brainery,
URL: content.URL,
Description: content.Description,
Fields: messageEmbed,

Footer: &discordgo.MessageEmbedFooter{
Text: "Added at " + content.PublishedAt.Format("January 2, 2006 3:04 PM") + " 🎉🎉🎉",
},
Timestamp: "custom",
Timestamp: content.PublishedAt.Format(time.RFC3339),
Thumbnail: &discordgo.MessageEmbedThumbnail{
URL: avatar,
},
Expand Down