Remove mock data

This commit is contained in:
Astra 2026-01-28 15:57:23 +00:00
parent 6f70daebca
commit 5be952483f
2 changed files with 7 additions and 52 deletions

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
config.yaml

58
main.go
View file

@ -43,53 +43,7 @@ func main() {
updateConfig.Timeout = 60
updatesChannel := b.API.GetUpdatesChan(updateConfig)
var updatesChannelMock chan api.Update = make(chan api.Update, 1)
mockUpdates := []api.Update{
{
ChatJoinRequest: &api.ChatJoinRequest{
Chat: api.Chat{
ID: -1001895847484,
Type: "supergroup",
Title: "Example Group",
},
From: api.User{
ID: 55258520,
FirstName: "Astra",
LastName: "Doe",
UserName: "asstra",
},
Date: int(time.Now().Unix()),
UserChatID: 55258520,
},
},
{
Message: &api.Message{
MessageID: 1,
From: &api.User{
ID: 55258520,
FirstName: "Astra",
LastName: "Doe",
UserName: "asstra",
},
Chat: api.Chat{
ID: 55258520,
Type: "private",
},
Date: int(time.Now().Unix()),
Text: "I would like to join because *I* <b>test</b> love this group!",
},
},
}
go func() {
for _, update := range mockUpdates {
updatesChannelMock <- update
time.Sleep(2 * time.Second) // delay between updates
}
close(updatesChannelMock)
}()
for update := range updatesChannel { //Mock {
for update := range updatesChannel {
if update.ChatJoinRequest != nil {
b.handleJoinRequest(update.ChatJoinRequest)
continue
@ -131,12 +85,12 @@ func (bot *Bot) handleJoinRequestResponse(user *ExtendedChatJoinRequest, update
ack := api.NewMessage(update.From.ID, "Thank you! Your request has been sent to the admins for review.")
bot.API.Send(ack)
} else {
if user.Date+(60*60*5) < int(time.Now().Unix()) {
// if user.Date+(60*60*5) < int(time.Now().Unix()) {
} else {
m := api.NewMessage(update.From.ID, "Your request is already pending approval.")
bot.API.Send(m)
}
// } else {
m := api.NewMessage(update.From.ID, "Your request is already pending approval.")
bot.API.Send(m)
// }
}
}