2018-07-28 13:17:54 +02:00
|
|
|
/*
|
|
|
|
* @Author: Bartuccio Antoine
|
|
|
|
* @Date: 2018-07-27 19:53:09
|
2019-01-04 10:55:51 +01:00
|
|
|
* @Last Modified by: Bartuccio Antoine
|
|
|
|
* @Last Modified time: 2019-01-04 10:36:16
|
2018-07-28 13:17:54 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
package commands
|
|
|
|
|
|
|
|
import (
|
2019-01-04 10:55:51 +01:00
|
|
|
"net/http"
|
|
|
|
|
|
|
|
"git.klmp200.net/ALFRED/ALFRED/shared"
|
|
|
|
|
2018-07-28 13:17:54 +02:00
|
|
|
"github.com/PuerkitoBio/goquery"
|
|
|
|
tb "gopkg.in/tucnak/telebot.v2"
|
|
|
|
)
|
|
|
|
|
2019-01-04 10:55:51 +01:00
|
|
|
// AperoTime checks if it's time to drink on an external website
|
2018-07-28 13:17:54 +02:00
|
|
|
func AperoTime(m *tb.Message) {
|
|
|
|
response, err := http.Get("http://estcequecestbientotlapero.fr")
|
|
|
|
if err != nil {
|
|
|
|
shared.Bot.Send(m.Chat, "Impossible de savoir si c'est bel et bien l'heure de l'apéro")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
defer response.Body.Close()
|
|
|
|
doc, err := goquery.NewDocumentFromReader(response.Body)
|
|
|
|
if err != nil {
|
|
|
|
shared.Bot.Send(m.Chat, "La réponse qui m'a été fournit est incohérente.")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
shared.Bot.Send(m.Chat, doc.Find("h2").First().Text())
|
|
|
|
}
|