LoginSignup
0

More than 5 years have passed since last update.

Twitter エタフォBotをGo言語で作ってみた

Posted at

エタフォ、速攻いいねする奴です

anacondaってライブラリ使います

go get github.com/ChimerCoder/anacondaしておいてください

api制限とやらがあるらしいのでsleep入れてますtime.Sleep()の中の秒数はお好みでどうぞ

汚いソースですが↓

エタフォ.go
package main

import (
    "github.com/ChimeraCoder/anaconda"
    "net/url"
    "fmt"
    "os"
    "time"
)



const (
    ck  = "コンシューマーキー"
    cs  = "コンシューマーシークレット"
    at  = "アクセストークン"
    ats = "アクセストークンシークレット"
)

func favo(){
    anaconda.SetConsumerKey(ck)
    anaconda.SetConsumerSecret(cs)
    cl := anaconda.NewTwitterApi(at,ats)
    v := url.Values{}
    v.Set("screen_name",os.Args[1])
    v.Set("count","5")
    v.Set("include_rts", "0")
    tls,_ := cl.GetUserTimeline(v)
    for _,tl := range tls{
        cl.Favorite(tl.Id)
        cl.ReTweet(tl.Id)
        fmt.Println(tl.Id)
    }

}


func main(){
    for{
        favo()
        time.Sleep(10 *time.Second)
    }
}

使い方
go build エタフォ.go
エタフォ @スクリーンネーム

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0