Apero time
the build was successful Details

This commit is contained in:
Antoine Bartuccio 2018-07-28 13:17:54 +02:00
parent b781ae9f53
commit 0d142365d1
Signed by: klmp200
GPG Key ID: E7245548C53F904B
2 changed files with 41 additions and 1 deletions

View File

@ -2,7 +2,7 @@
* @Author: Bartuccio Antoine
* @Date: 2018-07-23 15:24:22
* @Last Modified by: klmp200
* @Last Modified time: 2018-07-27 16:13:32
* @Last Modified time: 2018-07-27 19:59:42
*/
package main
@ -29,6 +29,7 @@ func main() {
"/trump": commands.LastTrumpTweet,
"/trends": commands.TwitterTrends,
"/chaos": commands.TwitterSJW,
"/apero": commands.AperoTime,
}
if err := settings.LoadSettings("settings.json", "settings_custom.json"); err != nil {

39
commands/apero.go Normal file
View 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)
}