mirror of
https://git.klmp200.net/ALFRED/ALFRED.git
synced 2025-01-18 10:36:44 +01:00
Apero time
This commit is contained in:
parent
b781ae9f53
commit
0d142365d1
@ -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
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…
Reference in New Issue
Block a user