Skip to content

Commit

Permalink
Obsolete vars declarations while updating info
Browse files Browse the repository at this point in the history
  • Loading branch information
Abdulelah Alfuntukh committed Mar 12, 2017
1 parent 723253d commit dc6b97d
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ func head(ud tgbotapi.Update, tokens []string) {
time.Sleep(time.Second * interval)
buf.Reset()

torrents, err := Client.GetTorrents()
torrents, err = Client.GetTorrents()
if err != nil {
continue // try again if some error heppened
}
Expand Down Expand Up @@ -563,7 +563,7 @@ func tailf(ud tgbotapi.Update, tokens []string) {
time.Sleep(time.Second * interval)
buf.Reset()

torrents, err := Client.GetTorrents()
torrents, err = Client.GetTorrents()
if err != nil {
continue // try again if some error heppened
}
Expand Down Expand Up @@ -1084,11 +1084,10 @@ func info(ud tgbotapi.Update, tokens []string) {
msgID := send(info, ud.Message.Chat.ID, true)

// this go-routine will make the info live for 'duration * interval'
// takes trackers so we don't have to regex them over and over.
go func(trackers string, torrentID, msgID int) {
go func(torrentID, msgID int) {
for i := 0; i < duration; i++ {
time.Sleep(time.Second * interval)
torrent, err := Client.GetTorrent(torrentID)
torrent, err = Client.GetTorrent(torrentID)
if err != nil {
continue // skip this iteration if there's an error retrieving the torrent's info
}
Expand Down Expand Up @@ -1117,7 +1116,7 @@ func info(ud tgbotapi.Update, tokens []string) {
editConf := tgbotapi.NewEditMessageText(ud.Message.Chat.ID, msgID, info)
editConf.ParseMode = tgbotapi.ModeMarkdown
Bot.Send(editConf)
}(trackers, torrentID, msgID)
}(torrentID, msgID)
}
}

Expand Down

0 comments on commit dc6b97d

Please sign in to comment.