add db
This commit is contained in:
@@ -2,6 +2,7 @@ package bot_all
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/samber/lo"
|
||||
@@ -27,21 +28,21 @@ func NewBotAll(
|
||||
}
|
||||
|
||||
func (bot *botAll) Process(ctx context.Context, msg *messenger.Message) error {
|
||||
if err := bot.storage.UpsertUser(ctx, storage.User{ChatID: msg.ChatID, UserID: msg.UserID}); err != nil {
|
||||
if err := bot.storage.UpsertUser(ctx, &storage.User{ChatID: msg.ChatID, UserID: msg.UserID}); err != nil {
|
||||
return err
|
||||
}
|
||||
if !strings.Contains(msg.Text, "@all") {
|
||||
if !strings.Contains(msg.Text, "@all") && !strings.Contains(msg.Text, "@все") && strings.ToLower(msg.Text) != "ау" {
|
||||
return nil
|
||||
}
|
||||
users, err := bot.storage.GetAllUsersByChatID(ctx, msg.ChatID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
usernames := lo.FilterMap(users, func(item storage.User, _ int) (string, bool) {
|
||||
usernames := lo.FilterMap(users, func(item *storage.User, _ int) (string, bool) {
|
||||
if item.UserID == msg.UserID {
|
||||
return "", false
|
||||
}
|
||||
return item.UserID, true
|
||||
return fmt.Sprintf("@%s", item.UserID), true
|
||||
})
|
||||
if len(usernames) > 0 {
|
||||
bot.messenger.SendMessage(
|
||||
|
||||
Reference in New Issue
Block a user