mirror of
https://git.klmp200.net/ALFRED/ALFRED.git
synced 2025-01-18 10:36:44 +01:00
Merge branch 'features'
This commit is contained in:
commit
22060613ad
@ -2,7 +2,7 @@
|
|||||||
* @Author: Bartuccio Antoine
|
* @Author: Bartuccio Antoine
|
||||||
* @Date: 2018-07-23 15:24:22
|
* @Date: 2018-07-23 15:24:22
|
||||||
* @Last Modified by: klmp200
|
* @Last Modified by: klmp200
|
||||||
* @Last Modified time: 2018-07-25 19:27:21
|
* @Last Modified time: 2018-07-26 18:59:19
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package main
|
package main
|
||||||
@ -27,6 +27,7 @@ func main() {
|
|||||||
"/gender": commands.Gender,
|
"/gender": commands.Gender,
|
||||||
"/roll": commands.Dice,
|
"/roll": commands.Dice,
|
||||||
"/trump": commands.LastTrumpTweet,
|
"/trump": commands.LastTrumpTweet,
|
||||||
|
"/trends": commands.TwitterTrends,
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := settings.LoadSettings("settings.json", "settings_custom.json"); err != nil {
|
if err := settings.LoadSettings("settings.json", "settings_custom.json"); err != nil {
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
* @Author: Bartuccio Antoine
|
* @Author: Bartuccio Antoine
|
||||||
* @Date: 2018-07-25 18:51:38
|
* @Date: 2018-07-25 18:51:38
|
||||||
* @Last Modified by: klmp200
|
* @Last Modified by: klmp200
|
||||||
* @Last Modified time: 2018-07-25 22:51:50
|
* @Last Modified time: 2018-07-26 22:21:29
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package commands
|
package commands
|
||||||
@ -39,16 +39,20 @@ func testOrInitTwitter() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func twitterCommunicationError(m *tb.Message) {
|
||||||
|
shared.Bot.Send(m.Chat, "Désolé, les serveurs de twitter sont injoignables.")
|
||||||
|
}
|
||||||
|
|
||||||
func LastTrumpTweet(m *tb.Message) {
|
func LastTrumpTweet(m *tb.Message) {
|
||||||
testOrInitTwitter()
|
testOrInitTwitter()
|
||||||
user, _, err := client.Users.Show(&twitter.UserShowParams{ScreenName: "realDonaldTrump"})
|
user, _, err := client.Users.Show(&twitter.UserShowParams{ScreenName: "realDonaldTrump"})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
shared.Bot.Send(m.Chat, "Désolé, les serveurs de twitter sont injoignables.")
|
twitterCommunicationError(m)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
timeline, _, err := client.Timelines.UserTimeline(&twitter.UserTimelineParams{ScreenName: "realDonaldTrump"})
|
timeline, _, err := client.Timelines.UserTimeline(&twitter.UserTimelineParams{ScreenName: "realDonaldTrump"})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
shared.Bot.Send(m.Chat, "Désolé, les serveurs de twitter sont injoignables.")
|
twitterCommunicationError(m)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
response := []string{
|
response := []string{
|
||||||
@ -64,3 +68,17 @@ func LastTrumpTweet(m *tb.Message) {
|
|||||||
}
|
}
|
||||||
shared.Bot.Send(m.Chat, strings.Join(response, " "))
|
shared.Bot.Send(m.Chat, strings.Join(response, " "))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TwitterTrends(m *tb.Message) {
|
||||||
|
testOrInitTwitter()
|
||||||
|
trends, _, err := client.Trends.Place(int64(615702), nil)
|
||||||
|
if err != nil {
|
||||||
|
twitterCommunicationError(m)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
message := "Voici les dernières tendances en France"
|
||||||
|
for _, trend := range trends[0].Trends {
|
||||||
|
message += "\n" + trend.Name
|
||||||
|
}
|
||||||
|
shared.Bot.Send(m.Chat, message)
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user