- WEChat 端末微信终端末版
ターミナル内の代替 WeChat クライアント。コマンド ラインを離れることなく交流できます。メッセージ、ファイル、画像 (ASCII アートとして) を送受信します。独自のスクリプトを追加してメッセージのバッチ送信とブロードキャストを自動化することも、ソーシャル機能を提供する AI を作成することもできます。
WeChit は、Selenium を介してバックグラウンドで非表示の Google Chrome インスタンスを制御します。ボタンを押して WeChat for Web からデータを取得し、端末にフィードします。入力はその後の対話のために自動的に送り返されます。画像は ANSI カラーをサポートする端末で利用でき、カスタム ASCII アート エンジンを使用してレンダリングされます。
pip install selenium
pip install pillow
主に macOS 10.13、ChromeDriver 2.41.578706、Python 3.6.5、Python 2.7.15 でテストされていますが、他の OS やセットアップでも動作するはずです。 ChromeDriver の代わりに他のブラウザ ドライバ (Safari、Firefox など) を使用することもできますが、テストされていないため、ソースを変更する必要があります。
cd
ます。wechit/
フォルダーに配置します。python wechit.py
を実行してクライアントを起動します。colormap.json
に保存されている事前に生成されたテーブルを参照して、使用する文字と色の組み合わせを決定します。このテーブルは、端末で使用されているフォントに多少特有のものです。 Wechit にパッケージされている表は、 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
を試してください。