Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to interact with group chats? #81

Open
AidanLovelace opened this issue Jan 16, 2018 · 5 comments
Open

How to interact with group chats? #81

AidanLovelace opened this issue Jan 16, 2018 · 5 comments
Labels

Comments

@AidanLovelace
Copy link
Contributor

AidanLovelace commented Jan 16, 2018

Is there a way to interact with group chats? (Not the old p2p. The new ones. Like that random one I created 2 days ago.)

@demurgos
Copy link
Member

demurgos commented Jan 16, 2018

You can send messages to group chats just as you send messages to simple contacts.
Instead of using the contact id, use the group chat id (a string starting with 19:).

You can get events from group chats and respond to them but the API to list the group chats you are participating in is missing at the moment.

const onMessage = (resource: resources.TextResource): void => {
  const conversationId: string = resource.conversation;
  // This is the id of the simple contact or group chat
  console.log(conversationId);
  // There was a recent update to help to handle resources by id:
  // import * as mri from "skype-http/mri"
  // if (mri.parse(conversationId).type === mri.MriType.GroupConversation) {
  //  console.log("This is a group conversation");
  // }
  api.sendMessage({textContent: "Hello, World!"}, conversationId).catch(console.error);
};

api.on("Text", onMessage);
api.on("RichText", onMessage);

@demurgos
Copy link
Member

I haven't looked into it but if you find the API endpoint to list the currently existing group chats, it would be a nice addition.

@demurgos demurgos changed the title Is there a way to interact with group chats? (Not the old p2p. The new ones. Like that random one I created 2 days ago.) How to interact with group chats? Jan 16, 2018
@demurgos
Copy link
Member

demurgos commented Jan 16, 2018

https://client-s.gateway.messenger.live.com/v1/users/ME/conversations?startTime=1514877701928&pageSize=100&view=msnp24Equivalent&targetType=Passport|Skype|Lync|Thread|PSTN

The method above lists the available conversations: PMs and group chats. I'll try to add support for this as soon as possible.
You can then use sendMessage with the id of the conversation to send messages to group chats.

@demurgos
Copy link
Member

Huh, well. It turns out that the method to get the conversations already exists 😄 :

async getConversations(): Promise<Conversation[]> {

Still, I'll update the types to match the contacts API.

@demurgos
Copy link
Member

Updating the conversation types also requires me to update the message types. It will improve the health of the lib a lot but requires more time.
I started work on my repo. I'll probably finish it next week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants