mirror of
https://git.klmp200.net/ALFRED/ALFRED.git
synced 2025-05-24 12:51:16 +02:00
Remove relative path and follow gometalinter guide lines
This commit is contained in:
parent
94313b4819
commit
541ab556d7
17 changed files with 107 additions and 78 deletions
|
@ -1,19 +1,22 @@
|
|||
/*
|
||||
* @Author: Bartuccio Antoine
|
||||
* @Date: 2018-07-27 19:53:09
|
||||
* @Last Modified by: klmp200
|
||||
* @Last Modified time: 2018-07-28 13:17:05
|
||||
* @Last Modified by: Bartuccio Antoine
|
||||
* @Last Modified time: 2019-01-04 10:36:16
|
||||
*/
|
||||
|
||||
package commands
|
||||
|
||||
import (
|
||||
"../shared"
|
||||
"net/http"
|
||||
|
||||
"git.klmp200.net/ALFRED/ALFRED/shared"
|
||||
|
||||
"github.com/PuerkitoBio/goquery"
|
||||
tb "gopkg.in/tucnak/telebot.v2"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// AperoTime checks if it's time to drink on an external website
|
||||
func AperoTime(m *tb.Message) {
|
||||
response, err := http.Get("http://estcequecestbientotlapero.fr")
|
||||
if err != nil {
|
||||
|
@ -27,13 +30,4 @@ func AperoTime(m *tb.Message) {
|
|||
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)
|
||||
}
|
||||
|
|
|
@ -1,20 +1,23 @@
|
|||
/*
|
||||
* @Author: Bartuccio Antoine
|
||||
* @Date: 2018-07-24 20:50:04
|
||||
* @Last Modified by: klmp200
|
||||
* @Last Modified time: 2018-07-24 21:00:59
|
||||
* @Last Modified by: Bartuccio Antoine
|
||||
* @Last Modified time: 2019-01-04 10:37:39
|
||||
*/
|
||||
|
||||
package commands
|
||||
|
||||
import (
|
||||
"../shared"
|
||||
tb "gopkg.in/tucnak/telebot.v2"
|
||||
"math/rand"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"git.klmp200.net/ALFRED/ALFRED/shared"
|
||||
|
||||
tb "gopkg.in/tucnak/telebot.v2"
|
||||
)
|
||||
|
||||
// Dice rolls a dice
|
||||
func Dice(m *tb.Message) {
|
||||
split := strings.Split(m.Text, " ")
|
||||
if len(split) < 2 {
|
||||
|
|
|
@ -1,17 +1,18 @@
|
|||
/*
|
||||
* @Author: Bartuccio Antoine
|
||||
* @Date: 2018-07-24 12:11:26
|
||||
* @Last Modified by: klmp200
|
||||
* @Last Modified time: 2018-07-24 12:12:58
|
||||
* @Last Modified by: Bartuccio Antoine
|
||||
* @Last Modified time: 2019-01-04 10:38:07
|
||||
*/
|
||||
|
||||
package commands
|
||||
|
||||
import (
|
||||
"../shared"
|
||||
"git.klmp200.net/ALFRED/ALFRED/shared"
|
||||
tb "gopkg.in/tucnak/telebot.v2"
|
||||
)
|
||||
|
||||
// Framapad send a link to the ALFRED framapad
|
||||
func Framapad(m *tb.Message) {
|
||||
shared.Bot.Send(m.Chat, "Venez participer à mon développement en posant vos idées ici : https://mensuel.framapad.org/p/ALFRED2LERETOUR.")
|
||||
}
|
||||
|
|
|
@ -1,18 +1,21 @@
|
|||
/*
|
||||
* @Author: Bartuccio Antoine
|
||||
* @Date: 2018-07-24 14:55:33
|
||||
* @Last Modified by: klmp200
|
||||
* @Last Modified time: 2018-07-25 01:29:53
|
||||
* @Last Modified by: Bartuccio Antoine
|
||||
* @Last Modified time: 2019-01-04 10:38:32
|
||||
*/
|
||||
|
||||
package commands
|
||||
|
||||
import (
|
||||
"../shared"
|
||||
tb "gopkg.in/tucnak/telebot.v2"
|
||||
"strings"
|
||||
|
||||
"git.klmp200.net/ALFRED/ALFRED/shared"
|
||||
|
||||
tb "gopkg.in/tucnak/telebot.v2"
|
||||
)
|
||||
|
||||
// SetGender register your gender on ALFRED
|
||||
func SetGender(m *tb.Message) {
|
||||
if m.Sender.Username == "" {
|
||||
shared.Bot.Send(m.Chat, "Il faut avoir enregistré un username pour pouvoir utiliser cette fonction")
|
||||
|
|
|
@ -1,17 +1,19 @@
|
|||
/*
|
||||
* @Author: Bartuccio Antoine
|
||||
* @Date: 2018-07-24 12:07:34
|
||||
* @Last Modified by: klmp200
|
||||
* @Last Modified time: 2018-07-24 12:08:49
|
||||
* @Last Modified by: Bartuccio Antoine
|
||||
* @Last Modified time: 2019-01-04 10:39:07
|
||||
*/
|
||||
|
||||
package commands
|
||||
|
||||
import (
|
||||
"../shared"
|
||||
"git.klmp200.net/ALFRED/ALFRED/shared"
|
||||
|
||||
tb "gopkg.in/tucnak/telebot.v2"
|
||||
)
|
||||
|
||||
// Git sends a link to the git repo
|
||||
func Git(m *tb.Message) {
|
||||
shared.Bot.Send(m.Chat, "Mon code source est accessible librement à l'adresse https://git.klmp200.net/ALFRED/ALFRED. Venez contribuer :)")
|
||||
}
|
||||
|
|
|
@ -1,17 +1,19 @@
|
|||
/*
|
||||
* @Author: Bartuccio Antoine
|
||||
* @Date: 2018-07-24 12:05:45
|
||||
* @Last Modified by: klmp200
|
||||
* @Last Modified time: 2018-07-24 12:06:39
|
||||
* @Last Modified by: Bartuccio Antoine
|
||||
* @Last Modified time: 2019-01-04 10:39:24
|
||||
*/
|
||||
|
||||
package commands
|
||||
|
||||
import (
|
||||
"../shared"
|
||||
"git.klmp200.net/ALFRED/ALFRED/shared"
|
||||
|
||||
tb "gopkg.in/tucnak/telebot.v2"
|
||||
)
|
||||
|
||||
// Hello makes ALFRED say hello
|
||||
func Hello(m *tb.Message) {
|
||||
shared.Bot.Send(m.Chat, "Bonjour "+m.Sender.Username)
|
||||
}
|
||||
|
|
|
@ -1,17 +1,19 @@
|
|||
/*
|
||||
* @Author: Bartuccio Antoine
|
||||
* @Date: 2018-07-24 12:09:37
|
||||
* @Last Modified by: klmp200
|
||||
* @Last Modified time: 2018-07-24 12:10:26
|
||||
* @Last Modified by: Bartuccio Antoine
|
||||
* @Last Modified time: 2019-01-04 10:39:50
|
||||
*/
|
||||
|
||||
package commands
|
||||
|
||||
import (
|
||||
"../shared"
|
||||
"git.klmp200.net/ALFRED/ALFRED/shared"
|
||||
|
||||
tb "gopkg.in/tucnak/telebot.v2"
|
||||
)
|
||||
|
||||
// OnText saves chat history
|
||||
func OnText(m *tb.Message) {
|
||||
shared.History.AddMessage(m.Chat.ID, m.Text)
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* @Author: Bartuccio Antoine
|
||||
* @Date: 2018-11-14 00:15:43
|
||||
* @Last Modified by: klmp200
|
||||
* @Last Modified time: 2018-11-14 00:31:48
|
||||
* @Last Modified by: Bartuccio Antoine
|
||||
* @Last Modified time: 2019-01-04 10:40:01
|
||||
*/
|
||||
|
||||
package commands
|
||||
|
@ -13,7 +13,7 @@ import (
|
|||
"math/rand"
|
||||
"sync"
|
||||
|
||||
"../shared"
|
||||
"git.klmp200.net/ALFRED/ALFRED/shared"
|
||||
|
||||
tb "gopkg.in/tucnak/telebot.v2"
|
||||
)
|
||||
|
|
|
@ -2,13 +2,14 @@
|
|||
* @Author: Bartuccio Antoine
|
||||
* @Date: 2019-01-02 22:46:05
|
||||
* @Last Modified by: Bartuccio Antoine
|
||||
* @Last Modified time: 2019-01-03 22:00:09
|
||||
* @Last Modified time: 2019-01-04 10:40:28
|
||||
*/
|
||||
|
||||
package commands
|
||||
|
||||
import (
|
||||
"../shared"
|
||||
"git.klmp200.net/ALFRED/ALFRED/shared"
|
||||
|
||||
tb "gopkg.in/tucnak/telebot.v2"
|
||||
)
|
||||
|
||||
|
|
|
@ -1,16 +1,18 @@
|
|||
/*
|
||||
* @Author: Bartuccio Antoine
|
||||
* @Date: 2018-07-24 11:52:11
|
||||
* @Last Modified by: klmp200
|
||||
* @Last Modified time: 2018-07-24 11:58:42
|
||||
* @Last Modified by: Bartuccio Antoine
|
||||
* @Last Modified time: 2019-01-04 10:40:38
|
||||
*/
|
||||
|
||||
package commands
|
||||
|
||||
import (
|
||||
"../shared"
|
||||
tb "gopkg.in/tucnak/telebot.v2"
|
||||
"strings"
|
||||
|
||||
"git.klmp200.net/ALFRED/ALFRED/shared"
|
||||
|
||||
tb "gopkg.in/tucnak/telebot.v2"
|
||||
)
|
||||
|
||||
func Sponge(m *tb.Message) {
|
||||
|
|
|
@ -15,7 +15,8 @@ import (
|
|||
"strconv"
|
||||
"strings"
|
||||
|
||||
"../shared"
|
||||
"git.klmp200.net/ALFRED/ALFRED/shared"
|
||||
|
||||
tb "gopkg.in/tucnak/telebot.v2"
|
||||
)
|
||||
|
||||
|
|
|
@ -1,21 +1,23 @@
|
|||
/*
|
||||
* @Author: Bartuccio Antoine
|
||||
* @Date: 2018-07-25 18:51:38
|
||||
* @Last Modified by: klmp200
|
||||
* @Last Modified time: 2018-07-27 16:49:59
|
||||
* @Last Modified by: Bartuccio Antoine
|
||||
* @Last Modified time: 2019-01-04 10:47:25
|
||||
*/
|
||||
|
||||
package commands
|
||||
|
||||
import (
|
||||
"../settings"
|
||||
"../shared"
|
||||
"github.com/dghubble/go-twitter/twitter"
|
||||
"github.com/dghubble/oauth1"
|
||||
tb "gopkg.in/tucnak/telebot.v2"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"git.klmp200.net/ALFRED/ALFRED/settings"
|
||||
"git.klmp200.net/ALFRED/ALFRED/shared"
|
||||
|
||||
"github.com/dghubble/go-twitter/twitter"
|
||||
"github.com/dghubble/oauth1"
|
||||
tb "gopkg.in/tucnak/telebot.v2"
|
||||
)
|
||||
|
||||
var client *twitter.Client
|
||||
|
@ -44,6 +46,7 @@ func twitterCommunicationError(m *tb.Message) {
|
|||
shared.Bot.Send(m.Chat, "Désolé, les serveurs de twitter sont injoignables.")
|
||||
}
|
||||
|
||||
// LastTrumpTweet sends the last tweet of Donald Trump
|
||||
func LastTrumpTweet(m *tb.Message) {
|
||||
testOrInitTwitter()
|
||||
user, _, err := client.Users.Show(&twitter.UserShowParams{ScreenName: "realDonaldTrump"})
|
||||
|
@ -70,6 +73,7 @@ func LastTrumpTweet(m *tb.Message) {
|
|||
shared.Bot.Send(m.Chat, strings.Join(response, " "))
|
||||
}
|
||||
|
||||
// TwitterTrends sends the french twitter trends
|
||||
func TwitterTrends(m *tb.Message) {
|
||||
testOrInitTwitter()
|
||||
trends, _, err := client.Trends.Place(int64(615702), nil)
|
||||
|
@ -84,17 +88,24 @@ func TwitterTrends(m *tb.Message) {
|
|||
shared.Bot.Send(m.Chat, message)
|
||||
}
|
||||
|
||||
// TwitterSJW sends lasts messages with #SJW
|
||||
func TwitterSJW(m *tb.Message) {
|
||||
testOrInitTwitter()
|
||||
last_use, exists := shared.ChatData.Get(m.Chat.ID, "last chaos use")
|
||||
lastUse, exists := shared.ChatData.Get(m.Chat.ID, "last chaos use")
|
||||
if exists {
|
||||
var date time.Time
|
||||
if _, is_string := last_use.(string); is_string {
|
||||
date, _ = time.Parse(time.RFC3339, last_use.(string))
|
||||
} else {
|
||||
date = last_use.(time.Time)
|
||||
var date *time.Time
|
||||
if lastUseConverted, isString := lastUse.(string); isString {
|
||||
parsedDate, err := time.Parse(time.RFC3339, lastUseConverted)
|
||||
if err == nil {
|
||||
date = &parsedDate
|
||||
}
|
||||
}
|
||||
if time.Now().Before(date.Add(time.Hour * 24)) {
|
||||
|
||||
if lastUseConverted, isDate := lastUse.(time.Time); isDate {
|
||||
date = &lastUseConverted
|
||||
}
|
||||
|
||||
if date != nil || time.Now().Before(date.Add(time.Hour*24)) {
|
||||
shared.Bot.Send(m.Chat, "Arioch ne répondra pas à votre appel.")
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue