Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
samarets committed Oct 12, 2022
1 parent 6cd3d75 commit cbe74fe
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion internal/bot/bot.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func (b *bot) InitUpdates() {
case getSupports:
b.GetSupports(update)
case event:
b.Event(update)
b.Event(b.adminID)
}

continue
Expand Down
5 changes: 4 additions & 1 deletion internal/bot/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -413,8 +413,11 @@ func (b *bot) GetSupports(update tgbotapi.Update) {
}
}

func (b *bot) Event(update tgbotapi.Update) {
func (b *bot) Event(adminID int64) {
groupID := b.db.groupDB().get()
if groupID == 0 {
groupID = adminID
}

msg := tgbotapi.NewMessage(
groupID,
Expand Down
3 changes: 3 additions & 0 deletions internal/bot/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ func (db *queueDB) getFirst() (*tgbotapi.User, error) {
return nil, err
}
}
if fromQueue.ID == 0 {
return nil, nil
}

return &fromQueue, nil
}
Expand Down
5 changes: 4 additions & 1 deletion internal/db/badger.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,10 @@ func (d *DB) GetFirstWherePrefix(prefix []byte, v interface{}) error {
return err
}

return json.Unmarshal(data, v)
if data != nil {
return json.Unmarshal(data, v)
}
return nil
}

func (d *DB) Drop(prefix []byte) error {
Expand Down

0 comments on commit cbe74fe

Please sign in to comment.