ttezel / twit

Twitter API Client for node (REST & Streaming API)
4.31k stars 568 forks source link

Stream stops working #373

Open ghost opened 7 years ago

ghost commented 7 years ago

Hi, i have a stream running on direct_messages

It all works fine, except after a while stops working

i dont know if the stream api also has rate limits like GET?

i am connecting once, but it stops working after i have sent about 20 messages

Is this a rate limit?

or a connection drop?

Thanks

sky96line commented 7 years ago

Yes there is.

I don't know the number but you should check twiter bot documentation and rules.

Thnx.


From: Kieran Harris notifications@github.com Sent: Wednesday, August 2, 2017 4:25:37 PM To: ttezel/twit Cc: Subscribed Subject: [ttezel/twit] Stream stops working (#373)

Hi, i have a stream running on direct_messages

It all works fine, except after a while stops working

i dont know if the stream api also has rate limits like GET?

i am connecting once, but it stops working after i have sent about 20 messages

Is this a rate limit?

or a connection drop?

Thanks

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/ttezel/twit/issues/373, or mute the threadhttps://github.com/notifications/unsubscribe-auth/Acng32s8ihptuP9T0MoKYQ_3vMypUXPpks5sUFWogaJpZM4Oq7Q5.

ghost commented 7 years ago

Thanks i realized it happens not over time, but if you send too many messages too quickly.

I couldn't find any streaming limits but i will just set a interval

Thanks

Brisingeros commented 7 years ago

Hi, and sorry if my explanation is not very accurate. This is my code:

///////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////// var stream = T.stream('user');

stream.on('direct_message', createTweet);//////////////////////

//Lo que hace el bot

var sendPez = "pezpez";

function createTweet(eventMsg){ ////////////////////// console.log("Working");

var funct = true;
var txt = eventMsg.direct_message.text;

for(var i = 0; i <6 && funct; i++){
    funct = txt[i] == sendPez[i];
}

if(funct){
    var tw = "🐟🐟 ";

    for(var j = 7; j < txt.length; j++){
        tw = tw + txt[j];
    }

    console.log("Message is a order");
    tweetIt(tw);
} else {
    console.log("It'a a message");
}

}; ///////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////

My problem here is that stream doesn't detect any DMs. I'm a begginer, so it's possibly my fault, but I don't get where is the error.

Thanks in advance!!