Compare commits

..

No commits in common. "master" and "v0.0.1" have entirely different histories.

4 changed files with 1 additions and 21 deletions

View File

@ -48,7 +48,7 @@ func main() {
u := tgbotapi.NewUpdate(0) u := tgbotapi.NewUpdate(0)
u.Timeout = 60 u.Timeout = 60
// bot user update chan // bot user update channel
updtChan := bot.GetUpdatesChan(u) updtChan := bot.GetUpdatesChan(u)
// subs chann // subs chann
changeChan := make(chan *nats.Msg, 64) changeChan := make(chan *nats.Msg, 64)
@ -72,7 +72,6 @@ func main() {
signal.Notify(sign, syscall.SIGINT, syscall.SIGTERM) signal.Notify(sign, syscall.SIGINT, syscall.SIGTERM)
defer close(sign) defer close(sign)
app := api.NewApi(bot) app := api.NewApi(bot)
// check for bot in db
for { for {
select { select {
case update := <-updtChan: case update := <-updtChan:

View File

@ -141,12 +141,3 @@ func (a Adapter) GetAllBotsUsers(botname string) ([]*domain.User, error) {
} }
return list, nil 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
}

View File

@ -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") a.log.Info("bot not restricted adding user to DB")
user.Create(update.SentFrom()) user.Create(update.SentFrom())
a.log.Info("Adding query permision to user over bot") 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) user.AddBot(update.SentFrom().ID, a.bot.Self.UserName)
} }
a.log.Error("getting user", "error", err) 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) { 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("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) 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) _, err := user.AddBot(update.SentFrom().ID, a.bot.Self.UserName)
if err != nil { if err != nil {
a.log.Error("adding bots", "user", update.SentFrom().UserName, "bot", a.bot.Self.UserName, "error", err) a.log.Error("adding bots", "user", update.SentFrom().UserName, "bot", a.bot.Self.UserName, "error", err)

View File

@ -14,5 +14,4 @@ type UserService interface {
GetBots(int64) ([]string, error) GetBots(int64) ([]string, error)
DeleteBot(int64, string) (bool, error) DeleteBot(int64, string) (bool, error)
GetAllBotsUsers(string) ([]*domain.User, error) GetAllBotsUsers(string) ([]*domain.User, error)
CreateBot(string)(error)
} }