利用python微信庫itchat實現微信自動回複功能

來源:互聯網
上載者:User
最近發現了一個特別好玩的Python 庫itchat,可以實現自動回複等多種功能,下面這篇文章主要給大家介紹了利用python庫itchat實現自動回複功能的相關資料,需要的朋友可以參考學習,下面來一起看看吧。

前言

在論壇上看到了用Python登入並實現自動簽到,才瞭解到一個新的Python庫: itchat

利用Python 庫itchat,可以實現自動回複等多種功能,好玩到根本停不下來啊,尤其是調戲調戲不懂電腦的,特別有成就感,哈哈!!

代碼如下:

#coding=utf8import requestsimport itchatKEY = '8edce3ce905a4c1dbb965e6b35c3834d'def get_response(msg): apiUrl = 'http://www.tuling123.com/openapi/api' data = {  'key' : KEY,  'info' : msg,  'userid' : 'wechat-robot', } try:  r = requests.post(apiUrl, data=data).json()  return r.get('text') except:  return@itchat.msg_register(itchat.content.TEXT)def tuling_reply(msg): defaultReply = 'I received: ' + msg['Text'] reply = get_response(msg['Text']) return reply or defaultReplyitchat.auto_login(hotReload=True)itchat.run()

安裝一下 itchat即可跑上面程式,實現與圖靈機器人的互動。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.