Home

Awesome

jeeves

Build Status

A smart WeChat bot.

中文文档

Getting Started

Requirements

JDK 8

How to run

mvn spring-boot:run

You should see the following logs.

alt text

After scanning and confirming login

alt text

Login process

alt text

Example

com.cherry.jeeves.MessageHandlerImpl is provided as an example of jeeves. You can modify the code in MessageHandlerImpl yourself or create another Spring Bean of MessageHandler to meet your requirements.

The default behaviors that are set in MessageHandlerImpl are:

Usages

Events

A bean that implements MessageHandler will be notified on all the following events.

Text message

void onReceivingPrivateTextMessage(Message message);
ParametersMeaning
messagereceived message

Image message

void onReceivingPrivateTextMessage(Message message, String thumbImageUrl, String fullImageUrl);
ParametersMeaning
messagereceived message
thumbImageUrlurl of image in small size
fullImageUrlurl of image in full size

ChatRoom text message

void onReceivingChatRoomTextMessage(Message message);
ParametersMeaning
messagereceived message

ChatRoom image message

void onReceivingChatRoomImageMessage(Message message, String thumbImageUrl, String fullImageUrl);
ParametersMeaning
messagereceived message
thumbImageUrlurl of image in small size
fullImageUrlurl of image in full size

Received a friend invitation

boolean onReceivingFriendInvitation(RecommendInfo info);
ParametersMeaning
RecommendInfofriend invitation infomation
Returns
true if to accept the invitation ( type:boolean )

Callback after accepting a friend invitation

boolean postAcceptFriendInvitation(Message message);
ParametersMeaning
messagefriend invitation message

New chatrooms found

void onNewChatRoomsFound(Set<Contact> chatRooms);
ParametersMeaning
chatRoomsa list of new chatrooms

Chatrooms deleted

void onChatRoomsDeleted(Set<Contact> chatRooms);
ParametersMeaning
chatRoomsa list of chatrooms that are deleted

Members changed in a chatroom

void onChatRoomMembersChanged(Contact chatRoom, Set<ChatRoomMember> membersJoined, Set<ChatRoomMember> membersLeft);
ParametersMeaning
chatRoomthe chatroom where members changed happened
membersJoineda list of members that joined the chatroom
membersLefta list of members that left the chatroom

New friends found

void onNewFriendsFound(Set<Contact> contacts);
ParametersMeaning
contactsa list of new friends

Friends deleted

void onFriendsDeleted(Set<Contact> contacts);
ParametersMeaning
contactsa list of friends that are deleted

New media platforms found

void onNewMediaPlatformsFound(Set<Contact> mps);
ParametersMeaning
mpsa list of new media platforms

Media platforms deleted

void onMediaPlatformsDeleted(Set<Contact> mps);
ParametersMeaning
mpsa list of media platforms that are deleted

Red packet received

void onRedPacketReceived(Contact contact);
ParametersMeaning
contactwhere the red packet is recevied

API

WechatHttpService has provided a bundle of apis that you can use to interact with the server.

Get all the contacts

Set<Contact> getContact()
Returns
all the contacts, including friends, chatrooms and media platforms ( type: Set<Contact> )

Get all the members in given chatrooms

Set<Contact> batchGetContact(Set<String> list)
ParametersMeaning
listthe list of usernames of chatrooms
Returns
chatrooms populated with all the members ( type: Set<Contact> )

Send plain text

void sendText(String userName, String content)
ParametersMeaning
userNamethe username of the contact that you send message to
contentthe content of the message

Set alias to given contact

void setAlias(String userName, String newAlias)
ParametersMeaning
userNamethe username of the contact that you set alias to
newAliasthe alias

logout

void logout()

Create a chatroom

void createChatRoom(String[] userNames, String topic)
ParametersMeaning
userNamesthe usernames of the contacts who are invited to the chatroom
topicthe topic(or nickname)

Invite a contact to a certain chatroom

void addChatRoomMember(String chatRoomUserName, String userName)
ParametersMeaning
chatRoomUserNamechatroom username
userNamecontact username

Delete a contact from a certain chatroom (if you're the owner!)

void deleteChatRoomMember(String chatRoomUserName, String userName)
ParametersMeaning
chatRoomUserNamechatroom username
userNamemember username

Download images in the conversation

Note that it's better not to download image directly. This method has included cookies in the request.

byte[] downloadImage(String url)
ParametersMeaning
urlthe url of the image
Returns
the data of the image ( type: byte[] )

FAQ

Q: What protocols is jeeves running on?

A: Jeeves is running on WeChat web protocols.

Q: How is jeeves different from other WeChat bots?

A: Jeeves is aimed to disguise itself as a normal web WeChat app. So we value details. Jeeves not only submits requests which are essential to login process, but also submits those are used for cross-platform status synchronization, status report and so on. The more details jeeves imitate, the safer your account is. Jeeves provides the following imitations.

Q: What can I do using jeeves?

A: Jeeves is a perfect tool if you'd like to store all the messages locally. As a mischief, you can send the messages that others have recalled back to chatroom. Use your imagination!

Q: What can't jeeves do?

A: Jeeves is still in masterelopment. Some complicated features such as sending an image is still in the todo list. Find all the available events and apis in the Usages.

Q: Can jeeves prevent itself from disconnecting from server?

A: Jeeves can't guarantee it. We're still working on it. Usually jeeves can stay for hours, up to 2 days. To stay connected as long as possible, DON'T have any unusual behaviors that real humans don't have. For example, sending 100 messages in one second.

Q: Why is my account blocked on web WeChat?

A: It depends on lots of factors. Tencent has statistics of all the behaviors and data of your account. Some unusual behaviors would put your account in risk. For example, sending messages to a person doesn't exist or you're not allowed to chat with. Additionally, Tencent has a list of the limits on all kinds of actions that an account can take. If your account exceeds the boundary, it could be blocked. For example, too many times of login in a short time.

Known Issues

Warning

Using any WeChat bots, including jeeves, could cause your account be blocked. It's at your own risk.

Credits

Jeeves project is inspired by ItChat and WeixinBot.

Bugs and Feedback

For bugs, questions and discussions please use the Github Issues.

License

MIT