Skip to content

Commit

Permalink
feat: enhancing messages
Browse files Browse the repository at this point in the history
  • Loading branch information
kehiy committed Dec 19, 2023
1 parent 3fd74f1 commit 0e3ce84
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ check:
golangci-lint run --build-tags "${BUILD_TAG}" --timeout=20m0s

### building
build-discord-bot:
discord-bot:
go build -o build/main cmd/app.go

15 changes: 8 additions & 7 deletions discord/discord.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,15 +119,16 @@ func (b *Bot) messageHandler(s *discordgo.Session, m *discordgo.MessageCreate) {
lastBlockTime := b.cm.GetLastBlockTime()
lastBlockTimeFormatted := time.Unix(int64(lastBlockTime), 0)

if (uint32(currentTime.Unix()) - lastBlockTime) > 15 {
msg := p.Sprintf("Network is **unhealthy❌**\nLast block time⛓️: %v\nCurrent time🕧: %v\nDifference is more than 15 seconds.",
lastBlockTimeFormatted.Format("02/01/2006, 15:04:05"), currentTime.Format("02/01/2006, 15:04:05"))
timeDiff := (uint32(currentTime.Unix()) - lastBlockTime)
if timeDiff> 15 {

Check failure on line 123 in discord/discord.go

View workflow job for this annotation

GitHub Actions / lint

File is not `gci`-ed with --skip-generated -s standard -s default (gci)
msg := p.Sprintf("Network is **unhealthy❌**\nLast block time⛓️: %v\nCurrent time🕧: %v\nTime Difference: %v\nDifference is more than 15 seconds.",
lastBlockTimeFormatted.Format("02/01/2006, 15:04:05"), currentTime.Format("02/01/2006, 15:04:05"), timeDiff)
_, _ = s.ChannelMessageSendReply(m.ChannelID, msg, m.Reference())
return
}

msg := p.Sprintf("Network is **healthy✅**\nLast block time⛓️: %v\nCurrent time🕧: %v\nDifference is less than 15 seconds.",
lastBlockTimeFormatted.Format("02/01/2006, 15:04:05"), currentTime.Format("02/01/2006, 15:04:05"))
msg := p.Sprintf("Network is **healthy✅**\nLast block time⛓️: %v\nCurrent time🕧: %v\nTime Difference: %v\nDifference is less than 15 seconds.",
lastBlockTimeFormatted.Format("02/01/2006, 15:04:05"), currentTime.Format("02/01/2006, 15:04:05"), timeDiff)
_, _ = s.ChannelMessageSendReply(m.ChannelID, msg, m.Reference())
return
}
Expand Down Expand Up @@ -182,7 +183,7 @@ func (b *Bot) messageHandler(s *discordgo.Session, m *discordgo.MessageCreate) {
referrals := b.referralStore.GetAllReferrals()
for _, r := range referrals {
if r.DiscordID == m.Author.ID {
msg := fmt.Sprintf("Your referral information:\nPoints: %v (%v tPACs)\nCode: ```%v```\n", r.Points, (r.Points * 10), r.ReferralCode)
msg := fmt.Sprintf("Your referral information👥:\nPoints: %v (%v tPACs)\nCode: ```%v```\n", r.Points, (r.Points * 10), r.ReferralCode)
_, _ = s.ChannelMessageSendReply(m.ChannelID, msg, m.Reference())
return
}
Expand Down Expand Up @@ -242,7 +243,7 @@ func (b *Bot) messageHandler(s *discordgo.Session, m *discordgo.MessageCreate) {
// check available balance
balance := b.faucetWallet.GetBalance()
if balance.Available < b.cfg.FaucetAmount {
_, _ = s.ChannelMessageSendReply(m.ChannelID, "Insufficient faucet balance. Try again later.", m.Reference())
_, _ = s.ChannelMessageSendReply(m.ChannelID, "Insufficient faucet balance. Try again later please😔.", m.Reference())
return
}

Expand Down

0 comments on commit 0e3ce84

Please sign in to comment.