WeChat client framework written in Perl language, based on Mojolicious, requires Perl version 5.10+, and can provide an API interface based on HTTP protocol through plug-ins for other languages or systems to call
This project fully follows the original functions officially provided by WeChat and does not include any acts of sabotage, account theft, etc. This project is completely open source. The purpose is to promote technical exchange and learning. Any illegal use that is harmful to the country, enterprises, individuals, etc. is prohibited, otherwise there will be consequences conceited
name | priority | Current status | github author | Function description |
---|---|---|---|---|
ShowMsg | 100 | Published | sjdy521 | Print messages received and sent by the client |
IRCShell | 99 | Published | sjdy521 | Using WeChat through irc client in Linux environment |
Openwx | 98 | Published | sjdy521 | Provide WeChat message sending API interface |
Beauty | 95 | Published | sjdy521 | Identify specified keywords and send pictures of beautiful women |
Translation | 93 | Published | sjdy521 | Multi-language translation function |
KnowledgeBase | 2 | Published | sjdy521 | Customize the Q&A knowledge base through WeChat messages |
AutoVerify | 1 | Published | sjdy521 | Automatically approve when receiving a friend verification request |
PostQRcode | 0 | Published | sjdy521 | Log in QR code and send it to your email for remote scanning. |
UploadQRcode | 0 | Published | sjdy521 | Upload the QR code to the image bed to obtain the public network access URL |
XiaoiceReply | 1 | Published | sjdy521 | Use Microsoft XiaoIce to implement intelligent chat replies |
ShowQRcode | 0 | Published | sjdy521 | Call the system image viewing program to display the QR code (currently only supports win) |
SmartReply | 0 | Published | sjdy521 | Smart chat reply |
For more plug-ins, refer to the complete plug-in list
You can start an intelligent chatbot by typing a single command, so elegant for both Perl and you. Enjoy!
cpanm Mojo::Weixin && perl -MMojo::Weixin -e "Mojo::Weixin->new->load('ShowMsg')->load('SmartReply')->run()"
[16/01/19 23:10:49] [info] 客户端准备登录...
[16/01/19 23:10:50] [info] 清除残留的历史二维码图片
[16/01/19 23:10:30] [info] 二维码已下载到本地[ /tmp/mojo_weixin_qrcode.jpg ]
[16/01/19 23:11:20] [info] 等待手机微信扫描二维码...
[16/01/19 23:12:09] [info] 手机微信扫码成功,请在手机微信上点击 [登录] 按钮...
[16/01/19 23:12:10] [info] 正在进行登录...
[16/01/19 23:12:10] [info] 微信登录成功
[16/01/19 23:13:40] [info] 获取联系人信息...
[16/01/19 23:13:40] [info] 更新个人信息成功
[16/01/19 23:14:41] [info] 更新好友信息成功
[16/01/19 23:15:42] [info] 更新群组[ 红包群 ]信息成功
[16/01/19 23:15:42] [info] 更新群组[ Perl语言交流 ]信息成功
[16/01/19 23:15:42] [info] 开始接收消息...
[16/01/19 23:15:00] [群消息] 小灰|Perl语言交流 : Mojo::Weixin不错哦
[16/01/19 23:15:58] [群消息] 我->Perl语言交流 : 多谢多谢
+-------------------+ +----------------+
| Tencent | | Any IRC Client |
| Weixin Server | | wechat、irssi |
+---v-------------^-+ +-v------------^-+
| | | |
| 微信协议交互| |IRC协议交互 |
+-- --- |-- - - -- | - - - -- - - --- | --- ----- | --+
| +---v-------------^--+ +----v------------^-+ |
| | <——————————————————< | |
| | Weixin Client | Weixin - IRC | IRC Server | |
| | | 协议转换 | 监听本机6667端口 | |
| | >——————————————————> | |
| +--------------------+ +-------------------+ |
| |
| 我们程序实现的部分 |
+--- - - - - -- - -- ---- ------ ------- ------ --- ----+
It is recommended to use cpanm to install the Mojo::Weixin module online. If you use docker, please see Docker image installation and usage.
Install perl
Before installation, please confirm whether Perl is already installed on your system, because except for Windows, most other platforms may have it pre-installed by default.
And your Perl version is at least 5.10.1+, 5.14+ is recommended
The Perl official website download page contains relatively comprehensive and detailed installation instructions for Unix/Linux, Mac OS X, and Windows multiple platforms.
It is recommended that you try to choose the Binaries (binary pre-compiled) version, which can be used immediately after installation, which is more convenient.
If your perl version is lower on Linux and you want to upgrade perl, you can consider using the tool perlbrew
platform | Recommended choice | Download address |
---|---|---|
Windows | 1. StrawberryPerl 2. ActivePerl 3. Mojo-StrawberryPerl | StrawberryPerl download address Mojo-StrawberryPerl download address ActivePerl download address |
Linux | 1. Comes with the system 2. Package managers such as yum/apt 3. Official source code compilation 4. ActivePerl 5. DWIM-Perl | ActivePerl download address DWIM-Perl download address |
Mac | 1. Comes with the system 2. ActivePerl | ActivePerl download address |
Notice:
Mojo-StrawberryPerl is streamlined and packaged based on StrawberryPerl and is suitable for Windows 32-bit/64-bit systems.
Install the cpanm tool (you can ignore this step if cpanm is already installed on the system)
Method a: Install cpanm via cpan (only for root users)
$ cpan -i App::cpanminus
Method b: Install cpanm directly online
$ curl -kL http://cpanmin.us | perl - App::cpanminus
官方服务器在国外,如果无法访问,可以选择下面的命令:
$ curl http://share-10066126.cos.myqcloud.com/cpanm.pl|perl - App::cpanminus
Use cpanm to install the Mojo::Weixin module online (if the system has already installed the module, performing this step will upgrade the module)
$ cpanm Mojo::Weixin
If it keeps prompting that the download failed during the installation process, it is probably because the network access to the foreign server is poor.
In this case, you can try to manually specify the domestic mirror site as follows:
$ cpanm --mirror http://mirrors.163.com/cpan/ Mojo::Weixin
Installation failed solutions that may help
If you're unlucky and don't get a first-time installation via cpanm, here's some information that might be helpful
During the installation of Mojo::Weixin, cpan or cpanm will help us automatically install many other dependent modules
Among the many dependent modules, the one that is often prone to installation problems is IO::Socket::SSL.
IO::Socket::SSL mainly provides https support. The installation process may involve the compilation of SSL related libraries.
For Linux users, compilation and installation are usually used. If the system lacks the necessary environment for compilation and installation, compilation will fail.
For Windows users, since there is no good compilation and installation environment, it is recommended to use some Perl running environments that have been packaged more comprehensively.
For example, the latest versions of the more popular strawberryperl or activeperl include the core dependency module of Mojo::Weixin by default.
RedHat/Centos:
$ yum install -y openssl-devel
Ubuntu:
$ sudo apt-get install libssl-dev
After fixing the compilation and running environment, go back to step 2 and install Mojo::Weixin.
Please try to install and use it under root. For installation and use under non-root, please refer to FAQ.
If you still have problems, you can try executing the following script on Linux to check dependent modules
$ curl -ks "https://raw.githubusercontent.com/sjdy521/Mojo-Weixin/master/script/check_dependencies.pl"|perl -
I am very familiar with Perl and am a professional Perler
This project is a pure Perl module that has been released to cpan. Please read the usage documentation of Mojo::Weixin
module carefully.
In addition, you can check out more code examples in the demo directory
I am not familiar with Perl and am a developer of other languages. I am only interested in the message sending/receiving interface provided.
You can directly save the following code into a source code file (must use UTF8 encoding) and use the perl interpreter to run it
#!/usr/bin/env perl
use Mojo::Weixin;
my ($host,$port,$post_api);
$host = "0.0.0.0"; #发送消息接口监听地址,没有特殊需要请不要修改
$port = 3000; #发送消息接口监听端口,修改为自己希望监听的端口
#$post_api = 'http://xxxx'; #接收到的消息上报接口,如果不需要接收消息上报,可以删除或注释此行
my $client = Mojo::Weixin->new(log_level=>"info",http_debug=>0);
$client->load("ShowMsg");
$client->load("Openwx",data=>{listen=>[{host=>$host,port=>$port}], post_api=>$post_api});
$client->run();
Save the above code as a xxxx.pl file, and then use perl to run it. The WeChat login will be completed and an http server listening to the specified address port will be generated on the local machine.
$ perl xxxx.pl
Example of interface call for sending friend messages
http://127.0.0.1:3000/openwx/send_friend_message?id=xxxx&content=hello
* About to connect() to 127.0.0.1 port 3000 (#0)
* Trying 127.0.0.1...
* Connected to 127.0.0.1 (127.0.0.1) port 3000 (#0)
> GET /openwx/send_friend_message?id=xxxxx&content=hello HTTP/1.1
> User-Agent: curl/7.29.0
> Host: 127.0.0.1:3000
> Accept: */*
>
< HTTP/1.1 200 OK
< Content-Type: application/json;charset=UTF-8
< Date: Sun, 13 Dec 2015 04:54:38 GMT
< Content-Length: 52
< Server: Mojolicious (Perl)
<
* Connection #0 to host 127.0.0.1 left intact
{"status":"发送成功","id":23910327,"code":0}
For more interface parameter descriptions, please refer to the Openwx plug-in API documentation.
I'm a geek, I just want to be able to play WeChat chat through IRC on the command line
Please read the steps to use the IRCShell plug-in
JavaScript
Python
Java
You can sponsor by scanning the Alipay payment QR code. Thank you for your support and encouragement.
Special thanks to those friends who have sponsored
Copyright (C) 2014 by sjdy521
This library is free software; you can redistribute it and/or modify it under MIT License and Anti 996 License