Skip to content

Latest commit

 

History

History
176 lines (160 loc) · 11.3 KB

ReadMe.Chinglish.md

File metadata and controls

176 lines (160 loc) · 11.3 KB
中文 | Chinglish

Warning: It could caused your wechat account forbidden to login web edition anymore if you use WeChatBotEngine, hence you'll unable to run WeChatBotEngine properly anymore!

About

WeChatBotEngine is a bot engine/framework based on HTTP protocol of WeChat Web Edition. WeChatBotEngine deals the communication with WeChat server itself, developers can develop bot based on that, so developers can build new bots to expand the power of WeChatBotEngine。

text QR code

Official bots shipped with the engine

WeChatBotEngine project ships with several official bots, to demonstrate how to build a bot or you can just to run it. Those bots are:

Bots shipped with WeChatBotEngine

Legend:

  • 📌 - Recommeded
  • ✳ - Useful

Common Bots

📌 WebSoup: Fetch HTML/XML/JSON from web, extract information from it.
HTML/XML: Use CSS Selector to extract information from fetched HTML/XML resource, send it to WeChat friend; JSON: Use JavaScript to extract data from JSON data, send it to WeChat friend.
📌 Relay: A bot which relay messages from outside to a WeChat friend in your contacts (Incomig only, no outgoing)
Receive message in JSON format from outside via Socket (TCP/IP), and send it to a friend (person or room) in your WeChat contacts according the target given in the message. Other applications can send message to WeChat via this relay bot, hence expanded the power of WeChatBotEngine, such as:
  • When download task of Transmission completed, a script will run (configurable in Transmission),the script send message to WeChat via this relay bot, hence Download-Completed-Notification function is implemented.
  • Using crontab to implement a Hourly-Time-Announcement function. (Of course you can write a bot to do it)
  • Fetch information from a web page periodically, and send it to WeChat, to implement Scheduled-Information/Message-Push function.
  • Using crontab to 'sign in' to some public accounts to get membership points.
  • You must have good ideas, please write it here ...
  • ...
📌 ShellCommand: A bot execute shell command
Accept command line from text message, run it, return the result of command. Example: /cmd ls -l /bin/
📌 ActiveDirectoryAddressBook: Use Active Directory (or Samba 4.x in Linux) as address book for company
Address book using Active Directory as backend: According room name or nickname of friend, search the keyword (name or account or email address or telephone number) from the Active Directories bounded to this name for contact information. Example: Send /adab KEYWORD in My Company 1 room will search for the contact information which contains KEYWORD from the active directories bounded to My Company 1 name.
SimpleAddressBook: A simple address book bot for WeChat chat room
This is a simple address book bot which relied on MySQL database for WeChat chat room. It will query the database according the room nickname and return the contact information of the specified contact name. Example: send /sab Alice in chat room My Company 1 will return contact information of Alice of My Company 1 address book.
MakeFriend: A MakeFriend agent bot
In chat room, use /addme command to send a request of MakeFriend to the command issuer.

When a request of MakeFriend message is received, automatically accept the request according a keyword/password.
Manager: A remote manager bot
This is just a reimplementation of some console commands, to let you manage bot engine if you are not in front of your computer. Currently, the following commands are implemented: /LoadBot, /UnloadBot, /ListBots (everyone can use this command), /LogLevel (View or Set log level), /Topic (Change room name like change topic in IRC channel), /Invite (Invite a contact to a chat room), /Kick (Kick a member from chat room, Kick operation works only if you're the administrator of that room)。
BaiduImageSearch: Baidu image search
When an image message posted, send the image to baidu image search, return the guess information and possible image sources.
BaiduVoice: Baidu Automatic Speech Recognition (ASR)
When an audio or short video message is posted, send the audio to baidu ASR api, and return the text result. -- Because you can only use text keywords to search chat history, so it's very useful.
BaiduTranslate: Baidu translate
Provide translation service via Baidu translate API.
GoogleImageSearch: Google Image Search
When an image message posted, send the image to Google image search, return the guess information and possible image sources.
Emoji: Emoji bot
Get emoji characters from database according keywords. Due to different OS implemented their own support of different Unicode standard version, some emoji characters may not be displayed well.
MissileLaunched: Send a 'missile launched' message when someone shared a geographic position (just for fun)
When someone send a geographic position message, read the longtitude and latitude value, and append a random customable joke.
Repeater: A bot which repeat sender's message
Repeat the message sent by sender. This bot is only for demonstration or test purpose, running for long term is not recommended.
SayHi: A bot which say Hi and Goodbye
Send a Hi and Goodbye message when logged in or logged out. The Hi message and Goodbye message is configurable.

Industrial Bots

HCICloudCSR: HCICloud customer service representative chat bot
Using the HTTP protocol from HCICloud CSR, fetch the answer from CSR bot, then reply to user.
iConTek: iConTek NLP (Natual Language Processing) customer service chat bot
Using the HTTP protocol of iConTek, fetch the answer from iConTek NLP engine, then reply to user.

load/unload bots dynamically

/listbots
2016-12-16 17:43:27.714 [信息] net_maclife_wechat_http_BotEngine ListBots: 简易通讯录 (net_maclife_wechat_http_Bot_SimpleAddressBook)
2016-12-16 17:43:27.715 [信息] net_maclife_wechat_http_BotEngine ListBots: 百度翻译 (net_maclife_wechat_http_Bot_BaiduTranslate)
2016-12-16 17:43:27.716 [信息] net_maclife_wechat_http_BotEngine ListBots: Google 图片搜索 (net_maclife_wechat_http_Bot_GoogleImageSearch)
2016-12-16 17:43:27.717 [信息] net_maclife_wechat_http_BotEngine ListBots: 消息中继 (net_maclife_wechat_http_Bot_Relay)

/unloadbot  net_maclife_wechat_http_Bot_GoogleImageSearch
2016-12-16 17:43:41.517 [信息] net_maclife_wechat_http_BotEngine UnloadBot: Google 图片搜索 机器人已被卸载

/loadbot net_maclife_wechat_http_Bot_BaiduImageSearch
2016-12-16 17:44:03.795 [信息] net_maclife_wechat_http_BotEngine LoadBot: 百度识图 机器人已创建并加载

How to create your own bot

Very easy, just extends/inherit net_maclife_wechat_http_Bot class, implements any (or zero) interface you wantted. Currently, the following interfaces/events are planned:

  • OnLoggedIn
  • OnLoggedOut
  • OnShutdown
  • OnMessagePackageReceived Triggered when a message package received. This is the entrance of all the following On***MessageReceived event. If you want to analyze or modify the message by yourself, you can do it here.
  • OnTextMessageReceived Triggered when a Text message received.
  • OnImageMessageReceived Triggered when an Image message received.
  • OnVoiceMessageReceived Triggered when a Voice message received.
  • OnVideoMessageReceived Triggered when a Video message received.
  • OnEmotionMessageReceived Triggered when an Emotion message received.
  • OnSystemMessageReceived Triggered when a System message received.
  • OnMessageIsRevokedMessageReceived Triggered when a MessageIsRevoked message received.
  • OnRequestToMakeFriendMessageReceived Triggered when a RequestToMakeFriend message received.
  • OnContactChanged Triggered when a contact was changed.
  • OnContactDeleted Triggered when a contact was deleted.
  • OnRoomMemberChanged Triggered when a room member changed.

Why your class name named like this: net_maclife_wechat_http_Bot

I don't like the layout of how Java organize the sources files and classes files -- directories in directories, so I replace all . (dot) in canonical/full class names to _ (underline). This will avoid the Java style layout, it's simple & effective, you don't need to go deep in directories to get a file.