Ejemplo n.º 1
0
# TwitterAPIを利用するインスタンス取得
twitter = TwitterAPI()
api = twitter.get_api()

if (len(sys.argv) != 2):
    print "start bot"
    text = []
    sleepMin = 2
    # つぶやきのテキスト取得
    postData = open('resource/postData.txt', 'r')
    for line in postData:
        text.append(line)
    # 一定時間ごとにつぶやき
    temp = text
    random = Random()
    id = 0
    while(True):
        if(temp.count < 2):
            temp = text
        time.sleep(sleepMin * 60)
        # テキストデータの中からつぶやき
        post = random.choice(temp)
        twitter.update_status(post)
        temp.remove(post)
        # リプライを取得してつぶやき
        twitter.reply_newest()
else:
    print "from command line"
    twitter.reply_newest()