7

无需每日扫码的IRC版微信和QQ:wechatircd、webqqircd

 3 years ago
source link: http://maskray.me/blog/2016-07-06-wechatircd-webqqircd-without-scanning-qrcode-daily
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

无需每日扫码的IRC版微信和QQ:wechatircd、webqqircd

之前ftiasch提到webqqircd运行在服务器上,似乎可以持续运行无需每日扫码。最近听bigeagle推荐了x2go。于是实验了一下headless wechatircd & webqqircd。PhantomJS不可用,存储图片麻烦,会抛出SIGFPE异常,自带webkit旧不支持ES6。故弃用,尝试Firefox。

服务器上安装x2goserver,Arch Linux配置较为容易:

sudo pacman -S --needed firefox socat
sudo pacman -S --needed x2goserver
sudo x2godbadmin --createdb
sudo systemctl enable --now x2goserver


yaourt -S wechatircd-git webqqircd-git
sudo systemctl enable --now wechatircd
sudo systemctl enable --now webqqircd

wechatircd、webqqircd的IRC server默认监听127.0.0.1,本地无法直接连接,也没有作身份认证。可以考虑用socat、iptables等方法限制只有自己能访问。

  • 本地安装x2goclient,New session,Session type选Single application,Command:为firefox。连接后稍等片刻(网速)会看到本地出现firefox窗口,该进程运行在服务器上。
  • 安装https://addons.mozilla.org/en-US/firefox/addon/redirector/扩展
  • 地址栏找到该扩展的图标,点击配置
  • 根据https://github.com/MaskRay/wechatircdhttps://github.com/MaskRay/webqqircd上的说明重定向qq.com域名上的js到127.0.0.1下wechatircd、webqqircd的修改版本,注意设置Applies to: Main window (address bar), Scripts
  • 访问两个js连接,Firefox提示Your connection is not secure,添加例外
  • 直接关闭x2goclient,效果似乎和suspend等效,进程仍在服务器上运行
Firefox Redirector配置
Firefox Redirector配置

微信网页版只要synccheck不间断(约30秒一次),不会断开连接要求重新扫码二维码。QQ网页版类似。

QQ网页版不能显示图片。
微信网页版能显示图片、视频、音频、文件、位置等,wechatircd会把它们转成qq.com域名的链接。本地浏览器没有cookies无法访问这些链接,我写了一个脚本把服务器Firefox的cookies(sqlite3)同步到本地,把qq.com相关域名的cookies导入到Chrome(也是sqlite3):https://gist.github.com/MaskRay/fae75a66f707d774b2335f61701221e8

wechatircd.jpg

某些客户端可以预览图片。

使用微信是无奈,警惕它打造的局域网。这种方式可以用来做普通帐号的微信机器人。

systemd service文件wechatircd.service:

[Unit]
Description=IRC server capable of controlling Web WeChat
Documentation=https://github.com/MaskRay/wechatircd
After=network.target
[Service]
ExecStart=/usr/bin/wechatircd --join new --http-key /etc/wechatircd/key.pem --http-cert /etc/wechatircd/cert.pem --http-root /usr/share/wechatircd --password a --logger-mask '/home/ray/irclogs/wechatircd/$channel/%%Y-%%m-%%d.log' --ignore 不想自动加入的群组名子串 另一个不想自动加入的群组名子串
[Install]
WantedBy=multi-user.target

Share Comments


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK