wechit
1.0.0
- 微信终端微信终端版
您终端中的替代微信客户端。无需离开命令行即可进行社交。发送和接收消息、文件和图像(作为 ASCII 艺术)。添加您自己的脚本来自动批量发送和广播消息,或者只是编写一个 AI 来为您进行社交。
微信通过 Selenium 在后台控制隐藏的 Google Chrome 实例。它按下按钮并从微信网页版获取数据并将其输入到您的终端。然后,您的输入会自动发回以进行进一步的交互。图像可用于支持 ANSI 颜色的终端,并使用自定义 ASCII-art 引擎进行渲染。
pip install selenium
pip install pillow
主要在 macOS 10.13、ChromeDriver 2.41.578706、Python 3.6.5 和 Python 2.7.15 上进行测试,但也应该适用于其他操作系统和设置。其他浏览器驱动程序(例如 Safari、Firefox 等)可以用来代替 ChromeDriver,但未经测试并且需要修改源代码。
cd
放入其中。wechit/
文件夹中。python wechit.py
启动客户端。colormap.json
中存储的预生成表来决定使用哪些字符和颜色组合。该表在某种程度上特定于终端所使用的字体。微信打包的表格是根据Monaco
字体生成的。如果您想生成调整为另一种字体的新表,可以运行python term_colormeter.py path/to/my/font.ttf
来执行此操作。 除了作为命令行应用程序运行wechit.py
之外,您还可以将其作为 python 模块导入并编写自己的脚本来自动发送消息。例如,使用此脚本通过向您最喜欢的亦敌亦敌的人发送相同的消息 100 次来骚扰他们。
import time
import wechit
recipent = "Bob"
message = "I love you"
print ( "initializing..." )
# initialize driver
driver = wechit . init_driver ()
# wait for page to load
time . sleep ( 1 )
# fetch the qr code
im = wechit . get_qr_code ( driver )
# display qr code
print ( wechit . print_qr_code ( im ))
# wait for chat window to load
wechit . wait_for_chat_window ( driver )
print ( "logged in as " " + wechit . get_username ( driver ) + " " ! loading chats..." )
# start conversation with recipent
ret_name = wechit . goto_conversation ( driver , recipent )
print ( "ok. now you're chatting with someone called " %s " ." % ( wechit . render_unicode ( wechit . no_emoji ( ret_name ))))
# send the messages
for i in range ( 100 ):
print ( "sending message:" , message )
wechit . send_message ( driver , message )
print ( "sent!" )
更多示例可以在./examples
文件夹中找到。例如尝试python examples/broadcast.py