3mora2 / WPP_Whatsapp

WPP_Whatsapp aim of exporting functions from WhatsApp Web to the python, which can be used to support the creation of any interaction, such as customer service, media sending, intelligence recognition based on phrases artificial and many other things, use your imagination
MIT License
57 stars 9 forks source link

Profile Already Open Exception while using the same session name second time #12

Closed HaniaArif closed 10 months ago

HaniaArif commented 10 months ago

Code Used:

  from WPP_Whatsapp import Create

  # start client with your session name
  your_session_name = "test"
  creator = Create(session=your_session_name)
  client = creator.start()
  # Now scan Whatsapp Qrcode in browser

  # check state of login
  if creator.state != 'CONNECTED':
      raise Exception(creator.state)

  phone_number = "+201016708170"  # or "+201016708170"
  message = "hello from wpp"

  # Simple message
  result = client.sendText(phone_number, message)
  creator.close()

Error:

================== RESTART: C:\Users\mz\Downloads\whatsapp.py ================== Exception in thread Thread-1 (thread_worker): Traceback (most recent call last): File "C:\Users\mz\AppData\Local\Programs\Python\Python310\lib\threading.py", line 1009, in _bootstrap_inner self.run() File "C:\Users\mz\AppData\Local\Programs\Python\Python310\lib\threading.py", line 946, in run self._target(*self._args, **self._kwargs) File "C:\Users\mz\AppData\Local\Programs\Python\Python310\lib\site-packages\WPP_Whatsapp\PlaywrightSafeThread\browser\threadsafe_browser.py", line 326, in thread_worker self.loop.run_until_complete(self.start_playwright()) File "C:\Users\mz\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 641, in run_until_complete return future.result() File "C:\Users\mz\AppData\Local\Programs\Python\Python310\lib\site-packages\WPP_Whatsapp\PlaywrightSafeThread\browser\threadsafe_browser.py", line 258, in start_playwright self.check_profile(self._browser_persistent_option.get("user_data_dir")) File "C:\Users\mz\AppData\Local\Programs\Python\Python310\lib\site-packages\WPP_Whatsapp\PlaywrightSafeThread\browser\threadsafe_browser.py", line 299, in check_profile raise Exception("Profile Already Open") Exception: Profile Already Open

Solutions already tried from examples folder:

  from WPP_Whatsapp import Create

  # start client with your session name
  your_session_name = "test"
  creator = Create(session=your_session_name, close_already_profile=True)
  client = creator.start()
  # Now scan Whatsapp Qrcode in browser

  # check state of login
  if creator.state != 'CONNECTED':
      raise Exception(creator.state)

  phone_number = "+201016708170"  # or "+201016708170"
  message = "hello from wpp"

  # Simple message
  result = client.sendText(phone_number, message)
  creator.close()

Status:

Additional parameter in Create() did not work

3mora2 commented 10 months ago

update now pip install WPP_Whatsapp -U

HaniaArif commented 10 months ago

@3mora2 now the code is not giving Profile Already Open Exception but it is not sending the message. it stops after creator.start()

HaniaArif commented 10 months ago

Profile Already Open issue resolved