Compare commits
No commits in common. "master" and "v0.0.1" have entirely different histories.
@ -48,7 +48,7 @@ func main() {
|
||||
u := tgbotapi.NewUpdate(0)
|
||||
u.Timeout = 60
|
||||
|
||||
// bot user update chan
|
||||
// bot user update channel
|
||||
updtChan := bot.GetUpdatesChan(u)
|
||||
// subs chann
|
||||
changeChan := make(chan *nats.Msg, 64)
|
||||
@ -72,7 +72,6 @@ func main() {
|
||||
signal.Notify(sign, syscall.SIGINT, syscall.SIGTERM)
|
||||
defer close(sign)
|
||||
app := api.NewApi(bot)
|
||||
// check for bot in db
|
||||
for {
|
||||
select {
|
||||
case update := <-updtChan:
|
||||
|
||||
@ -141,12 +141,3 @@ func (a Adapter) GetAllBotsUsers(botname string) ([]*domain.User, error) {
|
||||
}
|
||||
return list, nil
|
||||
}
|
||||
|
||||
func (a Adapter) CreateBot(botname string) (error){
|
||||
_, err := a.user.CreateBot(context.Background(), &tgbuser.TGBBotNameRequest{BotName: botname})
|
||||
if err != nil {
|
||||
a.log.Error("creating bot", "error", err)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -38,10 +38,6 @@ func (a *api) Run(update *tgbotapi.Update, dolar ports.DolarService, user ports.
|
||||
a.log.Info("bot not restricted adding user to DB")
|
||||
user.Create(update.SentFrom())
|
||||
a.log.Info("Adding query permision to user over bot")
|
||||
err = user.CreateBot(a.bot.Self.UserName)
|
||||
if err != nil {
|
||||
a.log.Error("creating bot", "error", err)
|
||||
}
|
||||
user.AddBot(update.SentFrom().ID, a.bot.Self.UserName)
|
||||
}
|
||||
a.log.Error("getting user", "error", err)
|
||||
@ -54,11 +50,6 @@ func (a *api) Run(update *tgbotapi.Update, dolar ports.DolarService, user ports.
|
||||
if !slices.Contains(bots, a.bot.Self.UserName) {
|
||||
a.log.Info("bot not found in db for user", "bot", a.bot.Self.UserName)
|
||||
a.log.Info("adding bots", "user", update.SentFrom().UserName, "bot", a.bot.Self.UserName)
|
||||
err = user.CreateBot(a.bot.Self.UserName)
|
||||
if err != nil {
|
||||
a.log.Error("creating bot", "error", err)
|
||||
}
|
||||
|
||||
_, err := user.AddBot(update.SentFrom().ID, a.bot.Self.UserName)
|
||||
if err != nil {
|
||||
a.log.Error("adding bots", "user", update.SentFrom().UserName, "bot", a.bot.Self.UserName, "error", err)
|
||||
|
||||
@ -14,5 +14,4 @@ type UserService interface {
|
||||
GetBots(int64) ([]string, error)
|
||||
DeleteBot(int64, string) (bool, error)
|
||||
GetAllBotsUsers(string) ([]*domain.User, error)
|
||||
CreateBot(string)(error)
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user