Skip to content
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
3 changes: 2 additions & 1 deletion base/multi.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package base
import (
"context"
"database/sql"
"errors"
"fmt"
"sync"
"time"
Expand Down Expand Up @@ -77,7 +78,7 @@ func (m *multi) heartbeat() {
`, m.timeoutSeconds), m.name)
var id string
if err := row.Scan(&id); err != nil {
if err != sql.ErrNoRows {
if !errors.Is(err, sql.ErrNoRows) {
m.Errorf("failed to scan id: %s", err)
return
}
Expand Down
6 changes: 4 additions & 2 deletions gcalbot/gcalbot/reminderscheduler/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,8 @@ func (r *ReminderScheduler) AddSubscription(account *gcalbot.Account, subscripti
account.KeybaseUsername, account.AccountNickname, subscription.CalendarID, subscription.KeybaseConvID,
func(msg *ReminderMessage, _ func()) {
r.minuteReminders.AddReminderMessageToMinute(subscription.DurationBefore, msg)
})
},
)

// do a background sync when a new subscription is added
go r.syncEvents(account, &subscription)
Expand All @@ -241,5 +242,6 @@ func (r *ReminderScheduler) RemoveSubscription(account *gcalbot.Account, subscri
r.eventReminders.RemoveReminderMessageFromEvent(msg)
removeReminderMessageFromSubscription()
}
})
},
)
}
4 changes: 3 additions & 1 deletion gcalbot/gcalbot/schedulescheduler/send.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package schedulescheduler

import (
"context"
"errors"
"fmt"
"math"
"strings"
Expand Down Expand Up @@ -132,7 +133,8 @@ func (s *ScheduleScheduler) SendDailyScheduleMessage(sendMinute time.Time, subsc
for index, calendarID := range subscription.CalendarIDs {
cal, err := srv.Calendars.Get(calendarID).Fields("summary").Do()
if err != nil {
if gerr, ok := err.(*googleapi.Error); ok && gerr.Code == 404 {
var gerr *googleapi.Error
if errors.As(err, &gerr) && gerr.Code == 404 {
// Calendar was deleted or user lost access; use ID as display name
s.Debug("calendar no longer accessible (404): %s", calendarID)
} else {
Expand Down
6 changes: 4 additions & 2 deletions gcalbot/gcalbot/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,14 @@ func (h *HTTPSrv) handleEventUpdateWebhook(w http.ResponseWriter, r *http.Reques
}

reminderSubscriptions, err := h.db.GetReminderSubscriptionsByAccountAndCalendar(
ctx, account, channel.CalendarID, SubscriptionTypeReminder)
ctx, account, channel.CalendarID, SubscriptionTypeReminder,
)
if err != nil {
return
}
inviteSubscriptions, err := h.db.GetReminderSubscriptionsByAccountAndCalendar(
ctx, account, channel.CalendarID, SubscriptionTypeInvite)
ctx, account, channel.CalendarID, SubscriptionTypeInvite,
)
if err != nil {
return
}
Expand Down
5 changes: 3 additions & 2 deletions githubbot/githubbot/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package githubbot

import (
"context"
"errors"
"fmt"
"net/http"
"strings"
Expand Down Expand Up @@ -126,7 +127,7 @@ func (h *Handler) handleSubscribe(ctx context.Context, cmd string, msg chat1.Msg
if !alreadyExists {
if create {
if created, err := h.handleNewSubscription(ctx, repo, msg, client); err != nil {
if _, ok := err.(base.OAuthRequiredError); ok {
if errors.As(err, new(base.OAuthRequiredError)) {
return nil
}
return err
Expand All @@ -153,7 +154,7 @@ func (h *Handler) handleSubscribe(ctx context.Context, cmd string, msg chat1.Msg
}
created, err := h.handleNewSubscription(ctx, repo, msg, client)
if err != nil {
if _, ok := err.(base.OAuthRequiredError); ok {
if errors.As(err, new(base.OAuthRequiredError)) {
return nil
}
return err
Expand Down
3 changes: 2 additions & 1 deletion githubbot/githubbot/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,8 @@ func (h *HTTPSrv) formatMessage(ctx context.Context, convID chat1.ConvIDStr, eve
branch,
len(event.Commits),
commitMsgs,
event.GetCompare()), branch
event.GetCompare(),
), branch

case *github.CheckRunEvent:
var author username
Expand Down
3 changes: 2 additions & 1 deletion gitlabbot/gitlabbot/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ func (h *HTTPSrv) handleWebhook(_ http.ResponseWriter, r *http.Request) {
branch,
len(event.Commits),
commitMsgs,
lastCommitDiffURL)
lastCommitDiffURL,
)
repo = event.Project.PathWithNamespace
case *gitlab.PipelineEvent:
repo = event.Project.PathWithNamespace
Expand Down
2 changes: 1 addition & 1 deletion triviabot/triviabot/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ func (s *session) getNextQuestion() error {
return nil
}
if err := getQuestion(token); err != nil {
if err == errTokenExpired {
if errors.Is(err, errTokenExpired) {
s.Debug("getNextQuestion: token expired, trying again")
if token, err = s.getToken(true); err != nil {
s.Errorf("getNextQuestion: failed to get token: %s", err)
Expand Down
Loading