tuhinpal / WhatsBot

Modular Userbot for Whatsapp. Supports MultiDevice authentication on non persistent server.
https://tuhinpal.github.io/WhatsBot/
Apache License 2.0
322 stars 403 forks source link

Autopmpermit Bug Fixes + minor adjustments #52

Closed AnshumanMahato closed 2 years ago

AnshumanMahato commented 2 years ago

Following bugs were found and resolved -

  1. Autopermit executing in unintended cases. - The auto permit was intended to be invoked when the client user directly texts a chat which is not permitted yet. This was working fine for the intended case. But it was also being called in some unintended situations.

    • It was responding to the other user's messages as well.
    • it was responding to the wait messages sent by the bot when a non permitted user texts the client.
    • it was also responding to the grey "you blocked this contact" notification.
  2. The !block command was blocking the client itself instead of the chat.

Fixes

  1. Auto pm permit was missing certain conditions which were added. All notification messages sent by admin commands now have a WhatsBot_Notification heading so that they can be recognised by auto pm permit.
    if (
        msg.fromMe &&
        msg.type !== "notification_template" &&
        otherChat.isUser &&
        !(await pmpermit.isPermitted(otherChat.number)) &&
        !otherChat.isMe &&
        !msg.body.startsWith("!") &&
        !msg.body.startsWith("*WhatsBot_Notification")
      ) {

    2.!block was reverted to its previous implementation.

Minor adjustments

The block action taken after 3 warnings now has a timeout of 3 seconds to ensure that the notification is successfully sent to the contact.

AnshumanMahato commented 2 years ago

@cachecleanerjeet requested changes were made.