安装python版本和库:
- python>=2.7,<=3.7
- consonance==0.1.3-1
- python-axolotl==0.2.2
- protobuf>=3.6.0
- pyopenssl==19.0.0
- pysocks==1.7.1
- six==1.10
- yowsup==3.2.3
1 注册
请求注册码
yowsup-cli registration –requestcode sms –phone 86xxx######## –cc 86 –mcc 460 –mnc 01
输出内容:
status: b'ok'
login: b'86xxxxxxxxxxx'
type: b'existing'
edge_routing_info: b'xxxxxx=='
使用注册码完成注册
yowsup-cli registration -R ****** --config-phone 86xxx######## --config-id xxxxxxxxxxxxxxxxxxxxxxx=
输出内容:
{
"__version__": 1,
"cc": "86",
"client_static_keypair": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx==",
"edge_routing_info": "xxxxxx==",
"expid": "xxxxxxxxxxxxxxxxxxxxxxxxxx==",
"fdid": "xxxx-xxxx-xxxx-xxxx-xxxxxxx",
"id": "xxxxxxxxxxxxxxxxxxxxxxxx",
"login": "86xxx*******",
"mcc": "460",
"mnc": "005",
"phone": "86xxx*******",
"pushname": "Yowsup",
"server_static_public": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx=",
"sim_mcc": "000",
"sim_mnc": "000"
}
status: b'ok'
login: b'86xxx*******'
type: b'existing'
edge_routing_info: b'xxxxxx=='
2.配置
配置文件路径(windows)
C:\Users\用户\AppData\Local\yowsup\yowsup\86xxxxx(你的注册号码)
yowsup在哪里存储配置文件数据?
- Win XP (not roaming): C:\Documents and Settings\Application Data\yowsup\yowsup<profile_name>\
- Win XP (roaming): C:\Documents and Settings\Local Settings\Application Data\yowsup\yowsup<profile_name>\
- Win 7 (not roaming): C:\Users\AppData\Local\yowsup\yowsup<profile_name>\
- Win 7 (roaming): C:\Users\AppData\Roaming\yowsup\yowsup<profile_name>\
- Linux: ~/.config/yowsup/<profile_name>/
- MAC OS: ~/Library/Preferences/yowsup/<profile_name>/
里面有一个叫axolotl.db的数据库存放一些密钥对之类的东西,另外此路径下可以手动创建一个配置文件config.json用于你的号码配置,你可以使用它而不用在命令中配置一些属性。
3.发送消息
yowsup-cli demos --config-pushname yowsup --config-client_static_keypair xxxxxxxxxxxxxxxxxxx== --config-phone 86xxx****(本端号码) -s 86xxx****(对端号码) Hello,World
或
yowsup-cli demos --config-pushname yowsup -c C:\Users\用户\AppData\Local\yowsup\yowsup\86xxxxx(你的注册号码) -s 86xxx****(对端号码) Hello,World
输出内容:
-------------ClientConfig----------
ClientConfig(
username=86xxx*****,
passive=True,
useragent=UserAgentConfig(
platform=1,
app_version=AppVersionConfig(
primary=2,
secondary=20,
tertiary=200
),
mcc=460,
mnc=005,
os_version=8.0.0,
manufacturer=samsung,
device=star2lte,
phone_id=xxxx-xxxx-xxxx-xxxx-xxxxxxxxx,
locale_lang=zh,
locale_country=CN
),
pushname=yowsup,
short_connect=True
)
一堆内容
------------data----------
一堆内容
------------data2----------
一堆内容
----------server_hello1----------
一堆内容
----------server_hello2----------
一堆内容
------------data----------
一堆内容
------------data2----------
一堆内容
-----payload_buffer-------
-----ret-------
一堆内容
--------recv:ciphertext
一堆内容
--------recv:plaintext
一堆内容
=========getProtocolTreeNode=======
一堆内容
---------processPlaintextNodeAndSend----------
一堆内容
--------messageData:%s b'\n\x04baby'
--------ciphertext:%s <axolotl.protocol.prekeywhispermessage.PreKeyWhisperMessage object at 0x000002A4CFB2E5F8>
--------send:plaintext:%s
一堆内容
--------send:ciphertext:%s
一堆内容
------------data----------
一堆内容
--------recv:ciphertext
一堆内容
--------recv:plaintext
一堆内容
=========getProtocolTreeNode=======
一堆内容
------------data2----------
一堆内容
------------data----------
一堆内容
--------recv:ciphertext
一堆内容
--------recv:plaintext
一堆内容
=========getProtocolTreeNode=======
一堆内容
------------data2----------
一堆内容
------------data----------
一堆内容
--------recv:ciphertext
一堆内容
--------recv:plaintext
一堆内容
=========getProtocolTreeNode=======
一堆内容
------------data2----------
一堆内容
------------data----------
一堆内容
--------recv:ciphertext
一堆内容
--------recv:plaintext
一堆内容
=========getProtocolTreeNode=======
一堆内容
Yowsdown
4.发送图片
TODO
5.同步联系人
yowsup-cli demos --config-pushname yowsup -c C:\Users\用户\AppData\Local\yowsup\yowsup\86xxxxx(你的注册号码) --sync +86A(正确且存在的号码),+86B(正确且存在的号码),+86152,+123,+86111
输出内容:
前面一堆内容
=========getProtocolTreeNode=======
一堆内容
Iq:
ID: 1
Type: result
from: 86xxxxxxx@s.whatsapp.net
Wait: xxxx
Version: xxxxxx
In Numbers: +86A,+86B
Out Numbers: +86152,+86111
Invalid Numbers: +123
Yowsdown
Process finished with exit code 0
In Numbers: 为注册了whatsapp的号码
Out Numbers: 为未注册whatsapp的号码
Invalid Numbers: 无效号码
6.命令行模式
此模式下的方法最全,基本上yowsup能实现的操作都在这下面了
首先进入命令行模式:
yowsup-cli demos -c 配置文件路径 -y
进入命令模式后可以用/help查看可用的命令:
/help
命令层 | 命令 | 参数 | 描述 |
---|---|---|---|
/L | Quick login | ||
/account | delete | Delete your account | |
/audio | send | <number> <path> | Send audio file |
/contact | picturePreview | <jid> | Get profile picture preview for contact |
/contact | lastseen | <jid> | Get lastseen for contact |
/contact | picture | <jid> | Get profile picture for contact |
/contacts | sync | <contacts> | Sync contacts, contacts should be comma separated phone numbers, with no spaces |
/disconnect | Disconnect | ||
/group | demote | <group_jid> <jids> | Remove admin of a group. Jids are a comma separated list |
/group | info | <group_jid> | Get group info |
/group | invite | <group_jid> <jids> | Invite to group. Jids are a comma separated list |
/group | kick | <group_jid> <jids> | Kick from group. Jids are a comma separated list |
/group | leave | <group_jid> | Leave a group you belong to |
/group | picture | <group_jid> <path> | Set group picture |
/group | promote | <group_jid> <jids> | Promote admin of a group. Jids are a comma separated list |
/group | setSubject | <group_jid> <subject> | Change group subject |
/groups | create | <subject> [jids] | Create a new group with the specified subject and participants. Jids are a comma separated list but optional. |
/groups | list | List all groups you belong to | |
/help | Print this message | ||
/ib | clean | <dirtyType> | Send clean dirty |
/image | send | <number> <path> [caption] | Send an image with optional caption |
/keys | get | <jids> | Get shared keys |
/message | broadcast | <numbers> <content> | Broadcast message. numbers should comma separated phone numbers |
/message | send | <number> <content> | Send message to a friend |
/ping | Ping server | ||
/presence | available | Set presence as available | |
/presence | name | <name> | Set presence name |
/presence | subscribe | <contact> | Subscribe to contact's presence updates |
/presence | unavailable | Set presence as unavailable | |
/presence | unsubscribe | <contact> | Unsubscribe from contact's presence updates |
/profile | getPrivacy | Get profile privacy | |
/profile | setPicture | <path> | Set profile picture |
/profile | setPrivacy | [value] [names] | Profile privacy. value=all|contacts|none names=profile|status|last. Names are comma separated, defaults to all. |
/profile | setStatus | <text> | Set status text |
/seq | Send init seq | ||
/state | paused | <jid> | Send paused state |
/state | typing | <jid> | Send typing state |
/statuses | get | <contacts> | Request contacts statuses |
/video | send | <number> <path> [caption] | Send a video with optional caption |