pythonの気軽な微信(wechat)ロボット
pythonの環境はpython 3で、環境を構築するのはここで言わないで、前の文章の中で
まずpythonの微信ライブラリをインストールします
#ソース終了
次の手動デバッグでは、スレッドをブロックする必要があります.
pythonで友達にメッセージを送信します.
2つの微信の共通の友人を表示します.
自分が最近送った履歴メッセージを表示:
その他の機能は皆さんが自分で研究する必要があります.wxpy説明ドキュメント:
wxpyドキュメントの説明
まずpythonの微信ライブラリをインストールします
pip install -U wxpy
:
#!/usr/bin/env python3
# coding: utf-8
# @Author : Aiker
from wxpy import *
#
bot = Bot ()
# (API key : http://tuling123.com)
tuling = Tuling (api_key='cc7e7f95db3545ad8e4867xxxxxx')
# xiaoi = XiaoI('2OEuYx5PBm5i','3JfIuWWkcBVj5bx75sYl')#xiaoI
boring_group = bot.groups().search('Anker')[0]
boring_group1 = bot.groups().search('BP')[0]
boring_group2 = bot.groups().search('Aiker')[0]
# boring_group1 = bot.groups().search("Anker Shenzhen",'Anker!',' ')[0]
# boring_group2 = bot.groups().search('Anker!')[0]
my_friend = bot.friends ().search("Aiker")[0]
jt = bot.friends ().search('jtt')[0]
mygroup=bot.groups()
print(mygroup)#
#
@bot.register ([boring_group,boring_group1,boring_group2,jt])
def ignore(msg):
print(boring_group)
#
return
#
@bot.register (msg_types=TEXT)
def auto_reply_all(msg):
tuling.do_reply (msg)
print (msg)
#
@bot.register ([boring_group, boring_group1, boring_group2])
def just_print(msg):
print (msg)
# f = open('wilow.txt', 'wb')
# f.writelines(msg)
# @
@bot.register((msg_types=TEXT))#
def auto_reply(msg):
if isinstance(msg.chat,Group) and not msg.is_at: # @ , @
return #
else:
tuling.do_reply (msg) #
print(msg) #
print(tuling.do_reply (msg)) #
# return ' :{}({})'.format(msg.text,msg.type) # : :
# @bot.register()
# def just_print(msg):
# print(msg)
# ,embed , bot.join()
# bot.join ()#
embed() # , Python
#ソース終了
次の手動デバッグでは、スレッドをブロックする必要があります.
pythonで友達にメッセージを送信します.
In [26]: jt = bot.friends ().search(' TT')[0]
In [28]: jt.send(' ')
Out[28]: ↪ TT : (Text)
In [29]: jt.send(' ...')
Out[29]: ↪ TT : ... (Text)
2つの微信の共通の友人を表示します.
自分が最近送った履歴メッセージを表示:
その他の機能は皆さんが自分で研究する必要があります.wxpy説明ドキュメント:
wxpyドキュメントの説明