mirror of
https://git.klmp200.net/ALFRED/ALFRED.git
synced 2025-01-18 18:46:44 +01:00
40 lines
1.0 KiB
Go
40 lines
1.0 KiB
Go
/*
|
|
* @Author: Bartuccio Antoine
|
|
* @Date: 2018-07-27 19:53:09
|
|
* @Last Modified by: klmp200
|
|
* @Last Modified time: 2018-07-28 13:17:05
|
|
*/
|
|
|
|
package commands
|
|
|
|
import (
|
|
"../shared"
|
|
"github.com/PuerkitoBio/goquery"
|
|
tb "gopkg.in/tucnak/telebot.v2"
|
|
"net/http"
|
|
)
|
|
|
|
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())
|
|
// doc.Find("h2").Each(func(i int, s *goquery.Selection) {
|
|
// log.Println(s.Text())
|
|
// })
|
|
// node, err := html.Parse(response.Body)
|
|
// if err != nil {
|
|
// shared.Bot.Send(m.Chat, "La réponse qui m'a été fournit est incohérente.")
|
|
// return
|
|
// }
|
|
// log.Println(node.NextSibling)
|
|
}
|