Remove mock data
This commit is contained in:
parent
6f70daebca
commit
5be952483f
2 changed files with 7 additions and 52 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
config.yaml
|
||||||
54
main.go
54
main.go
|
|
@ -43,53 +43,7 @@ func main() {
|
||||||
updateConfig.Timeout = 60
|
updateConfig.Timeout = 60
|
||||||
updatesChannel := b.API.GetUpdatesChan(updateConfig)
|
updatesChannel := b.API.GetUpdatesChan(updateConfig)
|
||||||
|
|
||||||
var updatesChannelMock chan api.Update = make(chan api.Update, 1)
|
for update := range updatesChannel {
|
||||||
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 {
|
|
||||||
if update.ChatJoinRequest != nil {
|
if update.ChatJoinRequest != nil {
|
||||||
b.handleJoinRequest(update.ChatJoinRequest)
|
b.handleJoinRequest(update.ChatJoinRequest)
|
||||||
continue
|
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.")
|
ack := api.NewMessage(update.From.ID, "Thank you! Your request has been sent to the admins for review.")
|
||||||
bot.API.Send(ack)
|
bot.API.Send(ack)
|
||||||
} else {
|
} else {
|
||||||
if user.Date+(60*60*5) < int(time.Now().Unix()) {
|
// if user.Date+(60*60*5) < int(time.Now().Unix()) {
|
||||||
|
|
||||||
} else {
|
// } else {
|
||||||
m := api.NewMessage(update.From.ID, "Your request is already pending approval.")
|
m := api.NewMessage(update.From.ID, "Your request is already pending approval.")
|
||||||
bot.API.Send(m)
|
bot.API.Send(m)
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue