-
Notifications
You must be signed in to change notification settings - Fork 0
/
foxinfobot.go
58 lines (50 loc) · 1.35 KB
/
foxinfobot.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package main
import (
"flag"
"fmt"
"os"
"github.com/ChimeraCoder/anaconda"
)
// SetAPI : setting client
func SetAPI() *anaconda.TwitterApi {
var consumerKey = os.Getenv("CONSUMER_KEY")
var consumerKeySecret = os.Getenv("CONSUMER_KEY_SECRET")
var accessToken = os.Getenv("ACCESS_TOKEN")
var accessTokenSecret = os.Getenv("ACCESS_TOKEN_SECRET")
ret := anaconda.NewTwitterApiWithCredentials(accessToken, accessTokenSecret, consumerKey, consumerKeySecret)
return ret
}
// PrintHelp : if arg has no value, show help message
func PrintHelp() {
fmt.Println("---------------------")
fmt.Println("foxinfobot.go Usage")
fmt.Println("---------------------")
fmt.Println("img : post image tweet (using randomfox api)")
fmt.Println("text : post text tweet about fox")
fmt.Println("weather : change twitter screen name (depends on current weather at Tokyo)")
fmt.Println("foxstatus : tweet todays twitter usage")
fmt.Println("---------------------")
return
}
func main() {
flag.Parse()
f := flag.Arg(0)
// authentication
api := SetAPI()
if f == "img" {
// post img tweet
PostImgTweet(api)
} else if f == "text" {
// post text tweet
PostTextTweet(api)
} else if f == "weather" {
WeatherFox(api)
} else if f == "weatherforecast" {
WeatherForecast(api)
} else if f == "foxstatus" {
FoxStatus(api)
} else {
PrintHelp()
}
fmt.Println("end")
}