mimamch / wa-multi-session

Multiple Session Whatsapp Socket Javascript Library
https://www.npmjs.com/package/wa-multi-session
MIT License
114 stars 37 forks source link

[FEATURE]: listener for labels association events created #12

Open MateoMax-hub opened 11 months ago

MateoMax-hub commented 11 months ago

FEATURE: event for labels.association are now assigned to a a new listener "ON_LABEL_ASSOCIATION" and used on the function "onLabelAssociation", the function will receive a callback to execute each time the events get triggered (adding o removing a label on a chat), in the parameters of the callback you will receive an obj like this:

{
  'labels.association': {
    type: 'add',
    association: {
      type: 'label_jid',
      chatId: '(number-of-the-chat-here)@s.whatsapp.net',
      labelId: '3'
    }
  }
}

type can be add or remove depending if you are adding or removing a label, and labelId is an id for the label selected to do this event, i'm planning on making a function to get the labels an maybe i can at that point integrate it with this so you can get the labelId and it's name too

MateoMax-hub commented 11 months ago

this works for me, @mimamch if you need me to make any changes on this pr, request them freely i will look into it, and if you don't want this change on your project it's fine too i can use it from my forked repository. I'm also planning on a function to get the labels created

MateoMax-hub commented 11 months ago

i added a listener for labels.edit too