fix new all command
This commit is contained in:
		
							parent
							
								
									3e0bfc433b
								
							
						
					
					
						commit
						292888ce9c
					
				
							
								
								
									
										10
									
								
								db/db.go
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								db/db.go
									
									
									
									
									
								
							@ -10,6 +10,10 @@ import (
 | 
				
			|||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type chatDTO struct {
 | 
					type chatDTO struct {
 | 
				
			||||||
 | 
						ChatID int64 `bson:"chat_id"`
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type chatInfoDTO struct {
 | 
				
			||||||
	ChatID int64    `bson:"chat_id"`
 | 
						ChatID int64    `bson:"chat_id"`
 | 
				
			||||||
	Users  []string `bson:"users"`
 | 
						Users  []string `bson:"users"`
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -77,9 +81,9 @@ func GetUsers(chatID int64) ([]string, error) {
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	collection := client.Database(cfg.DBName).Collection(cfg.ChatsCollectionName)
 | 
						collection := client.Database(cfg.DBName).Collection(cfg.ChatsCollectionName)
 | 
				
			||||||
	chatDTO := &chatDTO{}
 | 
						chatInfoDTO := &chatInfoDTO{}
 | 
				
			||||||
	if err := collection.FindOne(ctx, bson.M{"chat_id": chatID}).Decode(chatDTO); err != nil {
 | 
						if err := collection.FindOne(ctx, bson.M{"chat_id": chatID}).Decode(chatInfoDTO); err != nil {
 | 
				
			||||||
		return nil, err
 | 
							return nil, err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return chatDTO.Users, err
 | 
						return chatInfoDTO.Users, err
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										2
									
								
								main.go
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								main.go
									
									
									
									
									
								
							@ -89,7 +89,7 @@ func run() {
 | 
				
			|||||||
		command := commands.Command(strings.Replace(text, opts.Name, "", 1))
 | 
							command := commands.Command(strings.Replace(text, opts.Name, "", 1))
 | 
				
			||||||
		switch command {
 | 
							switch command {
 | 
				
			||||||
		case commands.Start:
 | 
							case commands.Start:
 | 
				
			||||||
			_, _ = bot.Send(tgbot.NewMessage(chatID, fmt.Sprintf("Здравствуйте, я Волтер (v1.2.0), ваш дворецкий (%d).", chatID)))
 | 
								_, _ = bot.Send(tgbot.NewMessage(chatID, fmt.Sprintf("Здравствуйте, я Волтер (v1.2.1), ваш дворецкий (%d).", chatID)))
 | 
				
			||||||
			_ = db.AddChat(chatID)
 | 
								_ = db.AddChat(chatID)
 | 
				
			||||||
		case commands.Help:
 | 
							case commands.Help:
 | 
				
			||||||
			_, _ = bot.Send(tgbot.NewMessage(chatID, "Вот что я умею:\n\n1) Позвать всех"))
 | 
								_, _ = bot.Send(tgbot.NewMessage(chatID, "Вот что я умею:\n\n1) Позвать всех"))
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user