Originally created by: supreme-gg-gg
Originally owned by: I3run0
Is your feature request related to a problem? Please describe.
On real web and mobile client you send status like online, typing, etc. This can be easily done now because we already are using the exact same realtime protocol.
Optionally, also receive, parse, and handle live status from the chat. See below for more info.
Describe the solution you'd like
Optionally, handle events indicating if the other participant(s) is/are online / read / typing etc and update the UI to show them. Create types for these events.
Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.
Additional context
Sample code available in instagram_mqtt repo see here for example
Along these lines:
await ig.realtime.direct?.indicateActivity({threadId: threadId, isActive: true,});
await ig.realtime.direct?.indicateActivity({threadId: threadId, isActive: false,});
await ig.realtime.direct?.markAsSeen({threadId: threadId, itemId: args[1],});
For parsing activity indicators received, you will need to dig a bit into the raw response from the MQTT client yourself, for example, these messages (message, direct, and realtime events) seem relevant. Would appreciate if you comment your investigation result here and tag me if you choose to work on this optional feature as well. You can get these results by running the linked sample code above and trying to receive messages on the logged in client.
messageWrapper {
event: 'patch',
message_type: 1,
seq_id: 7563,
tq_seq_id: 2668,
mi_trace_id: -3098480666398099500,
mutation_token: '7383277393301353020',
client_context: '7383277393301353020',
realtime: true,
delta_type: 'deltaReadReceipt',
message: {
path: '/direct_v2/threads/340282366841710301281161041946425021802/participants/23684901355/has_seen',
op: 'replace',
thread_id: '340282366841710301281161041946425021802',
item_id: '32471997368711323054250727382712320',
client_context: '7383277393301353020',
timestamp: 1760310505223000,
created_at: 1760310504605020,
shh_seen_state: {},
disappearing_messages_seen_state: {}
}
}
realtimeSub {
data: {
message: {
topic: 'direct',
payload: '{"event":"patch","data":[{"op":"add","path":"/direct_v2/threads/340282366841710301281161041946425021802/activity_indicator_id/d33ab33c-75a1-4f2a-9e1c-71498fd67695","value":"{\\"timestamp\\":1760310530166604,\\"sender_id\\":23684901355,\\"ttl\\":22000,\\"activity_status\\":1,\\"attribution\\":null}"}]}',
json: [Object]
}
},
topic: {
id: '149',
path: '/ig_realtime_sub',
parser: GraphqlParser {},
noParse: true
}
}
direct {
op: 'add',
path: '/direct_v2/threads/340282366841710301281161041946425021802/activity_indicator_id/d33ab33c-75a1-4f2a-9e1c-71498fd67695',
value: {
timestamp: 1760310530166604,
sender_id: 23684901355,
ttl: 22000,
activity_status: 1,
attribution: null
}
}
This can be easily done but we hope to leave some low hanging fruits for contributors 😄
Originally posted by: I3run0
Hi, I am a noob. But I liked the project. I will try it
Originally posted by: supreme-gg-gg
Sure, let us know if you need help! Right now we send online status by default (so if you try with your other account you can see it shown as online), but we don't have a config for this and we also don't support mark as seen or typing I believe. Requires a bit of experimentation first, would appreciate if you update us on what needs to be added and a rough plan before PR.
Originally posted by: I3run0
Hi @supreme-gg-gg , I am facing the following issue when I am trying to log in instagram-ts following the current CONTRIBUTING guide:
Originally posted by: supreme-gg-gg
Are you using 2FA? I just noticed this issue a bit earlier will try to fix it asap, can you send over the logs in
.instagram-cli/logsif it's there?Originally posted by: I3run0
I don't have 2FA. Following is the log of the last session:
Originally posted by: supreme-gg-gg
This API error message is usually when you entered the wrong password. The previous error with react happens since we had a typo in code (will fix that asap), but it is not relevant to the login API error, it only crashes when the CLI tries to display the login error message which is in the logs. Can you try again make sure you have the correct password? I faced this issue before but I realised I made a typo in password lol
Originally posted by: I3run0
Nice, Everthing works well now. I was just using the wrong password, lol. Thank you @supreme-gg-gg
Originally posted by: I3run0
Hi,
I’m trying to retrieve the status of another instagram user in a thread (e.g., typing, online).
For the “typing” event, I noticed that we can parse the “direct” event to receive something like the following, and interpret events in “direct” with the op: add operation as typing:
However, I haven’t been able to figure out how to determine when the other user is online or offline. Do you have any tips or suggestions for that?
Originally posted by: endernoke
Great find!
Have you tried subscribing to
appPresenceand see if any related event is received?Originally posted by: I3run0
I tried listening to the following event types, but during testing, I wasn’t able to see any related logs.
Originally posted by: supreme-gg-gg
I don't think the three types you're trying to subscribe exist, check the
RealtimeClientEventsclass:I wasn't able to find a direct way to get user live status as well, @endernoke do you know any method otherwise we can just implement typing status + read / unread messages. But i think this is probably broadcasted by Instagram, it's just that both the direct and realtimSub events don't forward it. You can look into raw
MqttMessageif you want perhaps, but it might get complicatedWoudl also be nice if you can figure out a way to detect if a thread is not read and set the
unreadfield properly, currently inclient.getThreadswe usethread.has_newerbut it doesn't seem to be reliable. Perhapslast_seen_atvslast_activity_atcomparision will suffice, you can give it a try! You can find these attributes on theDirectInboxFeedResponseThreadsItemclass used by that method.Originally posted by: endernoke
FYI the python client uses an undocumented field in the direct thread data, it should be present in the typescript API as well since they are the same endpoint but might require some monkey patching
https://github.com/supreme-gg-gg/instagram-cli/issues/22#issuecomment-2659926909_
https://github.com/supreme-gg-gg/instagram-cli/blob/2d303ed58a1c86d1c377bedb3d982a9564292464/instagram/api/direct_messages.py#L224C1-L230C1
Ticket changed by: endernoke