Remove mock data
This commit is contained in:
parent
6f70daebca
commit
5be952483f
2 changed files with 7 additions and 52 deletions
58
main.go
58
main.go
|
|
@ -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)
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue