Skip to content

Commit

Permalink
send in one message 5 repos
Browse files Browse the repository at this point in the history
  • Loading branch information
Arturomtz8 committed Sep 12, 2023
1 parent 77e2cf9 commit 1bce1b8
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions telegram.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const (
telegramApiBaseUrl string = "https://api.telegram.org/bot"
telegramApiSendMessage string = "/sendMessage"
telegramTokenEnv string = "GITHUB_BOT_TOKEN"
defaulRepoLen int = 10
defaulRepoLen int = 5
)

var lenSearchCommand int = len(searchCommand)
Expand Down Expand Up @@ -160,16 +160,25 @@ func formatReposContentAndSend(repos *github.TrendingSearchResult, chatId int) (
}
fmt.Println("template created and proceeding to send repos to chat")
fmt.Println("Total repos that will be sent", repoLen)
for i := 0; i < repoLen; i++ {

repo := reposContent[i]
if _, err := sendTextToTelegramChat(chatId, repo); err != nil {
// No need to break loop, just continue to the next one.
fmt.Printf("error occurred publishing event %v", err)
continue
}
text := strings.Join(reposContent, "\n-------------\n")
_, err := sendTextToTelegramChat(chatId, text)
if err != nil {
fmt.Printf("error occurred publishing event %v", err)
return "", err

}
// No need to break loop, just continue to the next one.
// for i := 0; i < repoLen; i++ {

// repo := reposContent[i]
// if _, err := sendTextToTelegramChat(chatId, repo); err != nil {
// // No need to break loop, just continue to the next one.
// fmt.Printf("error occurred publishing event %v", err)
// continue
// }

// }
return "all repos sent to chat", nil
}

Expand Down

0 comments on commit 1bce1b8

Please sign in to comment.