green-api / whatsapp-api-client-python

This library helps you easily create a Python application with WhatsApp API.
https://green-api.com/en
Other
137 stars 35 forks source link

Question | Custom Session For Whatsapp Client #57

Closed taaaal closed 3 months ago

taaaal commented 3 months ago

Hi, I'm building a main client that handles client X and WhatsApp client at the same time. I would like them to mount on the same session but I saw the session parameter doesn't exist as a kwarg in GreenAPI.__init__. But, is that possible? And if so, using the following code, for example?

class MyClient:
    def __init__(self):
        self._client_x = SomeClient()
        self._session = self._client_x.session
        self._whatsapp_client = GreenAPI(..., ...)
        setattr(self._whataspp_client, 'session', self._session)
Smol2022 commented 3 months ago

Hello, we don't plan to add session to class parameters yet. IDInstance and Token are accepted. Specify as follows

self._whatsapp_client.session = self._session

taaaal commented 3 months ago

I see, thanks a lot!