hoehermann / purple-gowhatsapp

Pidgin/libpurple plugin for WhatsApp Web.
GNU General Public License v3.0
276 stars 34 forks source link

Feature-Request: Store group name in database #197

Closed Juliaria08 closed 2 months ago

Juliaria08 commented 2 months ago

At least with the version I've got, b209b57340e1d287241ec79260b8bef012f19adf, the sqlite3 database doesn't contain group name, and this would be good to store to make scripts that rely on this data (for example to view the latest files from ~/.purple/autoaccept/ based on the group name.

I guess it's not needed as it really doesn't serve any purpose for whatsmeow (because even if it stores it, it'll maybe be different to what WhatsApp gives in whatsmeow's GroupInfo struct (and we probablyh shouldn't update back to WhatsApp uness we want to allow renaming groups in the WhatsApp sense)

Juliaria08 commented 2 months ago

Yes, I know this wouldn't be needed in practice as you get URLs, but I sometimes want to see all images, and this makes it easier than me having to check the logs, (I know I'm possibly losing context)

hoehermann commented 2 months ago

Thank you for the suggestion. Good news: Provided you added the chats to your buddy list (manually or using the plug-ins feature), there already is a "database" : It is purple's blist.xml. An entry looks like this:

<chat proto='prpl-hehoe-whatsmeow' account='49REDACTED@s.whatsapp.net'>
    <alias>Test Group</alias>
    <component name='name'>REDACTED@g.us</component>
</chat>

You can extract the mapping using any XML processor. Use xmlstarlet for example:

 xmlstarlet sel -t -c "purple/blist/group/chat[alias='Test Group']/component/text()" blist.xml

The auto-accept plug-in can store the incoming files in directories (one per group/buddy). In combination, that should get you there.

Juliaria08 commented 2 months ago

Thank you for the suggestion. Good news: Provided you added the chats to your buddy list (manually or using the plug-ins feature), there already is a "database" : It is purple's blist.xml. An entry looks like this:

<chat proto='prpl-hehoe-whatsmeow' account='49REDACTED@s.whatsapp.net'>
    <alias>Test Group</alias>
    <component name='name'>REDACTED@g.us</component>
</chat>

You can extract the mapping using any XML processor. Use xmlstarlet for example:

 xmlstarlet sel -t -c "purple/blist/group/chat[alias='Test Group']/component/text()" blist.xml

The auto-accept plug-in can store the incoming files in directories (one per group/buddy). In combination, that should get you there.

Thanks. I'm unsure whether I added them, and also how I'd get the list of aliases but I should be able to check that later when I decide to finish that part of the script.

hoehermann commented 2 months ago

how I'd get the list of aliases

The aliases are contained in the list of contacts. They are queried after connecting and with the ?contacts pseudo-command. I should make them into proper commands one day.

In Pidgin, there is a function for querying details about a contact, but I did not see one for querying the details of a chat. Both exist in the back-end, but I did not wire them up.