diff --git a/python/whatsapp.py b/python/whatsapp.py index fbacc865..bfc69e4c 100644 --- a/python/whatsapp.py +++ b/python/whatsapp.py @@ -21,12 +21,14 @@ # # whatsapp protocol for WeeChat. -# (this script requires WeeChat 0.3.0 (or newer) and the yowsup library) +# (this script requires WeeChat 2.9 (or newer) and the yowsup library) # # For help, see /help whatsapp # Happy chat, enjoy :) # # History: +# 2022-07-17, Marcel Robohm : +# version 0.2: adapt to new yowsup version # 2015-12-30, Jochen Sprickerhof : # version 0.1: Reworked for Whatsapp # 2013-09-30, Nils Görs : @@ -90,7 +92,7 @@ SCRIPT_NAME = "whatsapp" SCRIPT_AUTHOR = "Jochen Sprickerhof " -SCRIPT_VERSION = "0.1" +SCRIPT_VERSION = "0.2" SCRIPT_LICENSE = "GPL3" SCRIPT_DESC = "Whatsapp protocol for WeeChat" SCRIPT_COMMAND = SCRIPT_NAME @@ -103,17 +105,16 @@ import weechat except: print("This script must be run under WeeChat.") - print("Get WeeChat now at: http://www.weechat.org/") + print("Get WeeChat now at: https://weechat.org/") import_ok = False try: from yowsup.common import YowConstants from yowsup.layers import YowLayerEvent - from yowsup.layers.auth import AuthError from yowsup.layers.interface import YowInterfaceLayer, ProtocolEntityCallback from yowsup.layers.network import YowNetworkLayer - from yowsup.layers.protocol_contacts.protocolentities.iq_statuses_get import GetStatusesIqProtocolEntity - from yowsup.layers.protocol_contacts.protocolentities.iq_statuses_result import ResultStatusesIqProtocolEntity + from yowsup.layers.protocol_profiles.protocolentities.iq_statuses_get import GetStatusesIqProtocolEntity + from yowsup.layers.protocol_profiles.protocolentities.iq_statuses_result import ResultStatusesIqProtocolEntity from yowsup.layers.protocol_iq import YowIqProtocolLayer from yowsup.layers.protocol_iq.protocolentities.iq import IqProtocolEntity from yowsup.layers.protocol_iq.protocolentities.iq_ping import PingIqProtocolEntity @@ -631,15 +632,7 @@ def getDownloadableMediaMessageBody(self, message): def recv(self): """ Receive something from whatsapp server. """ - try: - self.getStack().getLayer(0).handle_read() - except AuthError as e: - weechat.prnt('', '%s: Error from server: %s' %(SCRIPT_NAME, e)) - self.disconnect() - if weechat.config_boolean(self.options['autoreconnect']): - autoreconnect_delay = 30 - weechat.command('', '/wait %s /%s connect %s' % - (autoreconnect_delay, SCRIPT_COMMAND, self.name)) + self.getStack().getLayer(0).handle_read() def recv_message(self, buddy, message): """ Receive a message from buddy. """ @@ -1550,16 +1543,16 @@ def whatsapp_completion_servers(data, completion_item, buffer, completion): """ Completion with whatsapp server names. """ global whatsapp_servers for server in whatsapp_servers: - weechat.hook_completion_list_add(completion, server.name, - 0, weechat.WEECHAT_LIST_POS_SORT) + weechat.completion_list_add(completion, server.name, + 0, weechat.WEECHAT_LIST_POS_SORT) return weechat.WEECHAT_RC_OK def whatsapp_completion_jid_aliases(data, completion_item, buffer, completion): """ Completion with whatsapp alias names. """ global whatsapp_jid_aliases for alias, jid in sorted(whatsapp_jid_aliases.items()): - weechat.hook_completion_list_add(completion, alias, - 0, weechat.WEECHAT_LIST_POS_SORT) + weechat.completion_list_add(completion, alias, + 0, weechat.WEECHAT_LIST_POS_SORT) return weechat.WEECHAT_RC_OK # ==================================[ fd ]====================================