Skip to content

Commit fc64de6

Browse files
committed
Log runNow and Discord connection messages.
1 parent 7e4682f commit fc64de6

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

discord.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,12 @@ func (d *DiscordChatAdapter) Listen() error {
3737
err := d.session.Open()
3838
switch err {
3939
case discordgo.ErrWSAlreadyOpen:
40-
return nil
40+
return WarnWrap(err, "Discord already connected")
4141
case nil:
4242
// wait for Discord ready event before returning.
4343
d.wg.Add(1)
4444
d.wg.Wait()
45-
return nil
45+
return NewInfo("connected to Discord")
4646
default:
4747
return ErrorWrap(err, "failed to open Discord session")
4848
}

hnoss.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ func (h *Hnoss) Start(ctx context.Context) {
9999
next, runNow, wasAdvanced = h.next(now, h.config.Offset, h.config.Interval)
100100

101101
if runNow {
102+
h.logger.Print(NewInfo("scheduled run missed, running now"))
102103
h.run(now, false, "")
103104
}
104105
stopTimer(timer)
@@ -139,8 +140,15 @@ func stopTimer(timer *time.Timer) {
139140
func (h *Hnoss) run(t time.Time, cached bool, chanID string) {
140141
var err error
141142
// Call Listen again each run to make sure we're connected.
142-
if err = h.chatAdapter.Listen(); err != nil {
143-
h.logger.Print(err)
143+
if err := h.chatAdapter.Listen(); err != nil {
144+
var w *Warn
145+
if !errors.As(err, &w) {
146+
h.logger.Print(err)
147+
var e *Error
148+
if errors.As(err, &e) {
149+
return
150+
}
151+
}
144152
}
145153
cur := h.ip
146154
ip, err := h.getIP(t, cached)

0 commit comments

Comments
 (0)