mirror of
https://git.klmp200.net/ALFRED/ALFRED.git
synced 2025-05-24 12:51:16 +02:00
Apero time
This commit is contained in:
parent
b781ae9f53
commit
0d142365d1
2 changed files with 41 additions and 1 deletions
39
commands/apero.go
Normal file
39
commands/apero.go
Normal file
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* @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)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue