-
Notifications
You must be signed in to change notification settings - Fork 224
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
whatsapp.py 0.2: adapt to new yowsup version
- Loading branch information
1 parent
c46d70a
commit 1a0c26d
Showing
1 changed file
with
12 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 <[email protected]>: | ||
# version 0.2: adapt to new yowsup version | ||
# 2015-12-30, Jochen Sprickerhof <[email protected]>: | ||
# version 0.1: Reworked for Whatsapp | ||
# 2013-09-30, Nils Görs <freenode.nils_2>: | ||
|
@@ -90,7 +92,7 @@ | |
|
||
SCRIPT_NAME = "whatsapp" | ||
SCRIPT_AUTHOR = "Jochen Sprickerhof <[email protected]>" | ||
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 ]==================================== | ||
|