[docs]REGISTRATION_INSTRUCTIONS=("Continue and scan the resulting QR codes on your main device, or alternatively, ""use the 'pair-phone' command to complete registration. More information at ""https://slidge.im/slidge-whatsapp/user.html")
[docs]WELCOME_MESSAGE=("Thank you for registering! Please scan the following QR code on your main device ""or use the 'pair-phone' command to complete registration, or type 'help' to list ""other available commands.")
self.whatsapp.Name="Slidge on "+str(global_config.JID)self.whatsapp.LogLevel=getLevelName(getLogger().level)assertconfig.DB_PATHisnotNonePath(config.DB_PATH.parent).mkdir(exist_ok=True)self.whatsapp.DBPath=str(config.DB_PATH)(global_config.HOME_DIR/"tmp").mkdir(exist_ok=True)self.whatsapp.TempDir=str(global_config.HOME_DIR/"tmp")self.whatsapp.Init()
[docs]asyncdefvalidate(self,user_jid,registration_form):""" Validate registration form. A no-op for WhatsApp, as actual registration takes place after in-band registration commands complete; see :meth:`.Session.login` for more. """pass
[docs]asyncdefunregister(self,user:GatewayUser):""" Logout from the active WhatsApp session. This will also force a remote log-out, and thus require pairing on next login. For simply disconnecting the active session, look at the :meth:`.Session.disconnect` function. """session:"Session"=self.get_session_from_user(user)# type:ignoresession.whatsapp.Logout()try:device_id=session.user.legacy_module_data["device_id"]self.whatsapp.CleanupSession(whatsapp.LinkedDevice(ID=device_id))exceptKeyError:passexceptRuntimeErroraserr:log.error("Failed to clean up WhatsApp session: %s",err)