<commit_before>/// <reference path="./Setting.ts" />
var util = require("util");
var twitter = require("twitter");

var twit = new twitter({
    consumer_key: Setting.API_KEY,
    consumer_secret: Setting.API_SECRET,
    access_token_key: Setting.ACCESS_TOKEN,
    access_token_secret: Setting.ACCESS_TOKEN_SECRET
});

function isError(data:any):boolean{
    var str:string = Object.prototype.toString.call(data);
    var name:string = str.replace(/^\[object /,"");
    name = name.replace(/\]$/,"");

    if(name === "Error") {
        return true;
    } else {
        return false;
    }
}

var testTweetId:string = '515004471521185792';
var targetTweetId:string = testTweetId;

// RT対象ツイートをチェック
twit.get('/statuses/show/'+targetTweetId+'.json',{include_my_retweet: true}, function(targetData:any){
    if(isError(targetData)) {
        return;
    }
    console.log(targetData);

    if(targetData.current_user_retweet.id_str) {
        // RT済みならばRTを取得
        var RetweetedId:string = targetData.current_user_retweet.id_str;
        twit.get('/statuses/show/'+RetweetedId+'.json',{}, function(retweetedData:any){
            console.log('Retweeted');
            console.log(retweetedData);

            // RT時間取得
            var RetweetTime:Date = new Date(retweetedData.created_at);
            // インターバル設定
            var interval:number = 5 /* min */ * 60 * 1000;

            // RTからの経過時間取得
            var now:Date = new Date();
            var elapsed:number = now.getTime() - RetweetTime.getTime();

            // インターバルを過ぎているならばRTを削除
            if(elapsed > interval) {
                twit.post('/statuses/destroy'+RetweetedId+'.json', {}, function(destroiedData){
                });
            }
        });
    } else {
        // RT
        twit.post('/statuses/retweet/'+targetTweetId+'.json', {}, function (data:any) {
            if(isError(data)) {
                return;
            }
            console.log(data);
        });
    }<commit_msg>Fix typo<commit_after>/// <reference path="./Setting.ts" />
var util = require("util");
var twitter = require("twitter");

var twit = new twitter({
    consumer_key: Setting.API_KEY,
    consumer_secret: Setting.API_SECRET,
    access_token_key: Setting.ACCESS_TOKEN,
    access_token_secret: Setting.ACCESS_TOKEN_SECRET
});

function isError(data:any):boolean{
    var str:string = Object.prototype.toString.call(data);
    var name:string = str.replace(/^\[object /,"");
    name = name.replace(/\]$/,"");

    if(name === "Error") {
        return true;
    } else {
        return false;
    }
}

var testTweetId:string = '515004471521185792';
var targetTweetId:string = testTweetId;

// RT対象ツイートをチェック
twit.get('/statuses/show/'+targetTweetId+'.json',{include_my_retweet: true}, function(targetData:any){
    if(isError(targetData)) {
        return;
    }
    console.log(targetData);

    if(targetData.current_user_retweet.id_str) {
        // RT済みならばRTを取得
        var RetweetedId:string = targetData.current_user_retweet.id_str;
        twit.get('/statuses/show/'+RetweetedId+'.json',{}, function(retweetedData:any){
            console.log('Retweeted');
            console.log(retweetedData);

            // RT時間取得
            var RetweetTime:Date = new Date(retweetedData.created_at);
            // インターバル設定
            var interval:number = 5 /* min */ * 60 * 1000;

            // RTからの経過時間取得
            var now:Date = new Date();
            var elapsed:number = now.getTime() - RetweetTime.getTime();

            // インターバルを過ぎているならばRTを削除
            if(elapsed > interval) {
                twit.post('/statuses/destroy/'+RetweetedId+'.json', {}, function(destroiedData){
                    console.log(destroiedData);
                });
            }
        });
    } else {
        // RT
        twit.post('/statuses/retweet/'+targetTweetId+'.json', {}, function (data:any) {
            if(isError(data)) {
                return;
            }
            console.log(data);
        });
    }
{'fraction_non_alphanumeric': 0.1456140350877193, 'fraction_numerical': 0.012531328320802004, 'mean_word_length': 2.290189612530915, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1909847', 'n_tokens_mistral': 1390, 'n_tokens_neox': 1321, 'n_words': 190}