dilame / instagram-private-api

NodeJS Instagram private API SDK. Written in TypeScript.
MIT License
5.93k stars 1.14k forks source link

Send a DM to an already existing group chat. #48

Closed UnbanTwin closed 7 years ago

UnbanTwin commented 7 years ago

I am sorry to open a new issue, however your documentation on this part of the API is limited. Would it be possible to give me an example? Sorry to cause you hassle.

huttarichard commented 7 years ago

https://github.com/huttarichard/instagram-private-api/blob/master/client/v1/thread.js#L232

Client.V1.Thread.configureText(session, userId, "text you would love to send").then((t) => console.log(t))

huttarichard commented 7 years ago

sorry did not read title

huttarichard commented 7 years ago

Client.Feed.Inbox how to work with feeds checkout readme... this will provide you list of threads, every thread has .configureText or . configureMediaShare hastag etc ... for more checkout source

UnbanTwin commented 7 years ago

Thanks! Do you mind if I keep this issue open, just in case I have any other problems to do with this?

huttarichard commented 7 years ago

sure

UnbanTwin commented 7 years ago

How far off am I? I have currently got the following code: ` var feed = new Client.Feed.Inbox(session);

Promise.map(_.range(0, 20), function() {
    return feed.get();
})
.then(function(results) {
    // result should be Media[][]
    var media = _.flatten(results);
    var urls = _.map(media, function(medium) {
        return _.last(medium.configureText)
    });
    console.log(urls);
})`

However it justs returns an array of undefined

UnbanTwin commented 7 years ago

I realise all that will do is list the DMs I am still can't work out how to send one (to an existing group)

huttarichard commented 7 years ago

do you have an valid session?

huttarichard commented 7 years ago
var feed = new Client.Feed.Inbox(session, 100);
feed.all().then(function(threads) {
    if (threads.length > 0)
        throw new Error("..... no messeges in inbox ....")
    return threads[0].configureText("text to someone")
})
.then(function(){
    console.log("text sended!")
})
UnbanTwin commented 7 years ago

Sorry, I feel kinda stupid for asking all this questions, so thanks again for taking time to help me. From there how do I declare what group im sending it too, is there like group IDs or something

huttarichard commented 7 years ago

you need to iterate over inbox, find conversation you want to reply and then you broadcast. threads coming from inbox is an array [Thread] of classes which is holding all info about thread, if you are looking for group conversation, you can inspect thread.params.title or what ever is in thread.params (you will find title property and others). Once you get right thread you can just use thread.broadcast<Text, Hashtag, Profile, Medium> and send what ever you want... Just take a look on source of thread class, it is not that complicated.

UnbanTwin commented 7 years ago

With your example: Client.Session.create(device, storage, 'user', 'Passoword') .then(function(session) { var feed = new Client.Feed.Inbox(session, 100); feed.all().then(function(threads) { if (threads.length > 0) throw new Error("..... no messeges in inbox ...."); return threads[0].configureText("text to someone"); }) .then(function(){ console.log("text sent!") }); });

It throws the error, ......No messages in inbox...... Even though there is. However if I comment that out, it throws thread[0].configureText is not a function

UnbanTwin commented 7 years ago

Crap I just put the password to tes the account in that, I have edited it now, but I realise the email notifying you about the post will have it in :/

huttarichard commented 7 years ago

@wizardsambolton you just got pwned :D

huttarichard commented 7 years ago

im going to investigate what is going on hold on

UnbanTwin commented 7 years ago

Thanks!

huttarichard commented 7 years ago

@wizardsambolton I actually try this with your account, but got checkpoint since you we are using different ip. However with my account it is working... So, try npm update library should be at version 0.5.1, then try different account, must be sure there are some threads conversation in inbox. Also try Thread.approveAll().

UnbanTwin commented 7 years ago

Ok will do.

huttarichard commented 7 years ago

and if nothing helps try to run git clone on repository ... run npm test and insert credentials when it ask you..

UnbanTwin commented 7 years ago

Thanks!

UnbanTwin commented 7 years ago

Well it did not work, so I am going to try doing what you said!

UnbanTwin commented 7 years ago

Ok from that I got 1 failed test

huttarichard commented 7 years ago

put it here, but I just try it with your account and got all threads, first one s group conversation, of mar.fmf,sophia_c_sprenkel,loulee.jones,helena_cookies,tbh.lozzer,hopefoxhope, feel free to tell me if I should delete it...

huttarichard commented 7 years ago

you are doing something wrong...

UnbanTwin commented 7 years ago

Strange :/ I have no clue what im doing wrong though :/ (Also it would be nice for you to delete it, but not yet, as it may be useful to help xD)

huttarichard commented 7 years ago

no I mean, delete the names I mentioned...., your account is safe with me because you are going to change password as soon as you get what you working on ...

huttarichard commented 7 years ago

put the failiture you got from tests...

UnbanTwin commented 7 years ago

Yeah, you dont need to delete the names its fine dw.

UnbanTwin commented 7 years ago

Ok will do one sec

UnbanTwin commented 7 years ago
Unhandled rejection AssertionError: expected '340282366841710300949128132075360282508' not to be '340282366841710300949128132075360282508' (false negative fail)
    at Assertion.fail (/Users/sambolton/Documents/Github1/InstagramPCDM/test/instagram-private-api/node_modules/should/lib/assertion.js:92:17)
    at Assertion.Object.defineProperty.value (/Users/sambolton/Documents/Github1/InstagramPCDM/test/instagram-private-api/node_modules/should/lib/assertion.js:174:17)
    at /Users/sambolton/Documents/Github1/InstagramPCDM/test/instagram-private-api/tests/cases/feeds/inbox.js:73:43
    at tryCatcher (/Users/sambolton/Documents/Github1/InstagramPCDM/test/instagram-private-api/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/Users/sambolton/Documents/Github1/InstagramPCDM/test/instagram-private-api/node_modules/bluebird/js/release/promise.js:510:31)
    at Promise._settlePromise (/Users/sambolton/Documents/Github1/InstagramPCDM/test/instagram-private-api/node_modules/bluebird/js/release/promise.js:567:18)
    at Promise._settlePromise0 (/Users/sambolton/Documents/Github1/InstagramPCDM/test/instagram-private-api/node_modules/bluebird/js/release/promise.js:612:10)
    at Promise._settlePromises (/Users/sambolton/Documents/Github1/InstagramPCDM/test/instagram-private-api/node_modules/bluebird/js/release/promise.js:691:18)
    at Promise._fulfill (/Users/sambolton/Documents/Github1/InstagramPCDM/test/instagram-private-api/node_modules/bluebird/js/release/promise.js:636:18)
    at Promise._resolveCallback (/Users/sambolton/Documents/Github1/InstagramPCDM/test/instagram-private-api/node_modules/bluebird/js/release/promise.js:431:57)
    at Promise._settlePromiseFromHandler (/Users/sambolton/Documents/Github1/InstagramPCDM/test/instagram-private-api/node_modules/bluebird/js/release/promise.js:522:17)
    at Promise._settlePromise (/Users/sambolton/Documents/Github1/InstagramPCDM/test/instagram-private-api/node_modules/bluebird/js/release/promise.js:567:18)
    at Promise._settlePromise0 (/Users/sambolton/Documents/Github1/InstagramPCDM/test/instagram-private-api/node_modules/bluebird/js/release/promise.js:612:10)
    at Promise._settlePromises (/Users/sambolton/Documents/Github1/InstagramPCDM/test/instagram-private-api/node_modules/bluebird/js/release/promise.js:691:18)
    at Promise._fulfill (/Users/sambolton/Documents/Github1/InstagramPCDM/test/instagram-private-api/node_modules/bluebird/js/release/promise.js:636:18)
    at Promise._settlePromise (/Users/sambolton/Documents/Github1/InstagramPCDM/test/instagram-private-api/node_modules/bluebird/js/release/promise.js:580:21)
    at Promise._settlePromise0 (/Users/sambolton/Documents/Github1/InstagramPCDM/test/instagram-private-api/node_modules/bluebird/js/release/promise.js:612:10)
    at Promise._settlePromises (/Users/sambolton/Documents/Github1/InstagramPCDM/test/instagram-private-api/node_modules/bluebird/js/release/promise.js:691:18)
    at Promise._fulfill (/Users/sambolton/Documents/Github1/InstagramPCDM/test/instagram-private-api/node_modules/bluebird/js/release/promise.js:636:18)
    at Promise._settlePromise (/Users/sambolton/Documents/Github1/InstagramPCDM/test/instagram-private-api/node_modules/bluebird/js/release/promise.js:580:21)
    at Promise._settlePromise0 (/Users/sambolton/Documents/Github1/InstagramPCDM/test/instagram-private-api/node_modules/bluebird/js/release/promise.js:612:10)
    at Promise._settlePromises (/Users/sambolton/Documents/Github1/InstagramPCDM/test/instagram-private-api/node_modules/bluebird/js/release/promise.js:691:18)
    at Promise._fulfill (/Users/sambolton/Documents/Github1/InstagramPCDM/test/instagram-private-api/node_modules/bluebird/js/release/promise.js:636:18)
    at Promise._settlePromise (/Users/sambolton/Documents/Github1/InstagramPCDM/test/instagram-private-api/node_modules/bluebird/js/release/promise.js:580:21)
    at Promise._settlePromise0 (/Users/sambolton/Documents/Github1/InstagramPCDM/test/instagram-private-api/node_modules/bluebird/js/release/promise.js:612:10)
    at Promise._settlePromises (/Users/sambolton/Documents/Github1/InstagramPCDM/test/instagram-private-api/node_modules/bluebird/js/release/promise.js:691:18)
    at Promise._fulfill (/Users/sambolton/Documents/Github1/InstagramPCDM/test/instagram-private-api/node_modules/bluebird/js/release/promise.js:636:18)
    at Promise._settlePromise (/Users/sambolton/Documents/Github1/InstagramPCDM/test/instagram-private-api/node_modules/bluebird/js/release/promise.js:580:21)
    at Promise._settlePromise0 (/Users/sambolton/Documents/Github1/InstagramPCDM/test/instagram-private-api/node_modules/bluebird/js/release/promise.js:612:10)
    at Promise._settlePromises (/Users/sambolton/Documents/Github1/InstagramPCDM/test/instagram-private-api/node_modules/bluebird/js/release/promise.js:691:18)
    at Promise._fulfill (/Users/sambolton/Documents/Github1/InstagramPCDM/test/instagram-private-api/node_modules/bluebird/js/release/promise.js:636:18)
    at Promise._resolveCallback (/Users/sambolton/Documents/Github1/InstagramPCDM/test/instagram-private-api/node_modules/bluebird/js/release/promise.js:431:57)
    at Promise._settlePromiseFromHandler (/Users/sambolton/Documents/Github1/InstagramPCDM/test/instagram-private-api/node_modules/bluebird/js/release/promise.js:522:17)
    at Promise._settlePromise (/Users/sambolton/Documents/Github1/InstagramPCDM/test/instagram-private-api/node_modules/bluebird/js/release/promise.js:567:18)
    at Promise._settlePromise0 (/Users/sambolton/Documents/Github1/InstagramPCDM/test/instagram-private-api/node_modules/bluebird/js/release/promise.js:612:10)
    at Promise._settlePromises (/Users/sambolton/Documents/Github1/InstagramPCDM/test/instagram-private-api/node_modules/bluebird/js/release/promise.js:691:18)
    at Promise._fulfill (/Users/sambolton/Documents/Github1/InstagramPCDM/test/instagram-private-api/node_modules/bluebird/js/release/promise.js:636:18)
    at Promise._resolveCallback (/Users/sambolton/Documents/Github1/InstagramPCDM/test/instagram-private-api/node_modules/bluebird/js/release/promise.js:431:57)
    at Promise._settlePromiseFromHandler (/Users/sambolton/Documents/Github1/InstagramPCDM/test/instagram-private-api/node_modules/bluebird/js/release/promise.js:522:17)
    at Promise._settlePromise (/Users/sambolton/Documents/Github1/InstagramPCDM/test/instagram-private-api/node_modules/bluebird/js/release/promise.js:567:18)
    at Promise._settlePromise0 (/Users/sambolton/Documents/Github1/InstagramPCDM/test/instagram-private-api/node_modules/bluebird/js/release/promise.js:612:10)
    at Promise._settlePromises (/Users/sambolton/Documents/Github1/InstagramPCDM/test/instagram-private-api/node_modules/bluebird/js/release/promise.js:691:18)
    at Promise._fulfill (/Users/sambolton/Documents/Github1/InstagramPCDM/test/instagram-private-api/node_modules/bluebird/js/release/promise.js:636:18)
    at Promise._resolveCallback (/Users/sambolton/Documents/Github1/InstagramPCDM/test/instagram-private-api/node_modules/bluebird/js/release/promise.js:431:57)
    at Promise._settlePromiseFromHandler (/Users/sambolton/Documents/Github1/InstagramPCDM/test/instagram-private-api/node_modules/bluebird/js/release/promise.js:522:17)
    at Promise._settlePromise (/Users/sambolton/Documents/Github1/InstagramPCDM/test/instagram-private-api/node_modules/bluebird/js/release/promise.js:567:18)
    at Promise._settlePromise0 (/Users/sambolton/Documents/Github1/InstagramPCDM/test/instagram-private-api/node_modules/bluebird/js/release/promise.js:612:10)
    at Promise._settlePromises (/Users/sambolton/Documents/Github1/InstagramPCDM/test/instagram-private-api/node_modules/bluebird/js/release/promise.js:691:18)
    at Promise._fulfill (/Users/sambolton/Documents/Github1/InstagramPCDM/test/instagram-private-api/node_modules/bluebird/js/release/promise.js:636:18)
    at PromiseArray._resolve (/Users/sambolton/Documents/Github1/InstagramPCDM/test/instagram-private-api/node_modules/bluebird/js/release/promise_array.js:125:19)
    at PromiseArray._promiseFulfilled (/Users/sambolton/Documents/Github1/InstagramPCDM/test/instagram-private-api/node_modules/bluebird/js/release/promise_array.js:143:14)
    at Promise._settlePromise (/Users/sambolton/Documents/Github1/InstagramPCDM/test/instagram-private-api/node_modules/bluebird/js/release/promise.js:572:26)
    at Promise._settlePromise0 (/Users/sambolton/Documents/Github1/InstagramPCDM/test/instagram-private-api/node_modules/bluebird/js/release/promise.js:612:10)
    at Promise._settlePromises (/Users/sambolton/Documents/Github1/InstagramPCDM/test/instagram-private-api/node_modules/bluebird/js/release/promise.js:691:18)
    at Async._drainQueue (/Users/sambolton/Documents/Github1/InstagramPCDM/test/instagram-private-api/node_modules/bluebird/js/release/async.js:138:16)
    at Async._drainQueues (/Users/sambolton/Documents/Github1/InstagramPCDM/test/instagram-private-api/node_modules/bluebird/js/release/async.js:148:10)
    at Immediate.Async.drainQueues [as _onImmediate] (/Users/sambolton/Documents/Github1/InstagramPCDM/test/instagram-private-api/node_modules/bluebird/js/release/async.js:17:14)
    at processImmediate [as _immediateCallback] (timers.js:383:17)

        1) should not be problem to get threads
huttarichard commented 7 years ago

Ok test is failing because you have only 4 conversations in inbox... which leads to failiture ... should be repaired, but it is not an bug in library...

huttarichard commented 7 years ago

run suite again but put console.log in it, you will find what is going on, how to respond to thread...

UnbanTwin commented 7 years ago

Sory feel like im being stupid, but put console.log where?

UnbanTwin commented 7 years ago

@huttarichard

huttarichard commented 7 years ago

tests directory, there is describe block with Inbox class specs so start over there...

UnbanTwin commented 7 years ago

I am so sorry to keep bothering you :/ however I added cnsole.log to the top of the describe block, however when I ran it I got tons of errors, so I removed it, and ran it again, and I am still getting the errors

huttarichard commented 7 years ago

I know that starting with programming can be hard, but if you do it by yourself, it is much easier then. Learn, inspect try more, this library is great source of learning. Good luck.

huttarichard commented 7 years ago

and google a lot man, for example you can start with promises and then continue to mocha