1727浏览
查看: 1727|回复: 5

[项目] 懒癌福利——懒得开微信

[复制链接]
关于我掌控板看微信的项目————他死了好久
现在,我又来了
——————————————————————
宅在沙发上太舒服了
然而手机响了o((>ω< ))o
w(゚Д゚)w又要爬起来->走过去->开机->走回来->爬下来
多麻烦
因为作者(我)很懒
掌控板没有配备二维码功能
登入要在电脑
——————————————————————
代码:
(python电脑)
import itchat
import paho.mqtt.client as mqtt
@itchat.msg_register(TEXT, isFriendChat=True, isGroupChat=True, isMpChat=True)
def simple_reply(msg):
  client.publish("chat",msg['FromUserName'],2)
  client.publish("chat",msg['Text'],2)
@itchat.msg_register([PICTURE, RECORDING, ATTACHMENT, VIDEO])
def download_files(msg):
client.publish("chat","get "+msg['Type']+" "+msg['FileName'],2)
itchat.auto_login()
itchat.run()
MQTTHOST = "ip"
mqttClient = mqtt.Client()
def onMqtt():
    mqttClient.connect(MQTTHOST, 1883, 2)
   client.username_pw_set(username, password
=
passwd)

    mqttClient.loop_start()
onMQtt()
client.publish("chat","hello",2)
(MIND-)
/*!
* MindPlus
* mpython
*
*/
#include <MPython.h>
#include <DFRobot_Iot.h>
// 函数声明
void obloqMqttEventT0(String& message);
// 静态常量
const String topics[5] = {"(chat端口)","","","",""};
const MsgHandleCb msgHandles[5] = {obloqMqttEventT0,NULL,NULL,NULL,NULL};
// 创建对象
DFRobot_Iot myIot;

// 主程序开始
void setup() {
myIot.setMqttCallback(msgHandles);
mPython.begin();
}
void loop() {
myIot.init("iot.dfrobot.com.cn","","","",topics,1883);
myIot.connect();
}

// 事件回调函数
void obloqMqttEventT0(String& message) {
display.setCursorXY(0, 0);
display.print(message);
while (!(buttonA.isPressed())) {yield();}
display.fillScreen(0);
}


欢迎检查
我没有检查过
python装itchat文件和 paho-mqtt


DFrJ5KYVQaH  中级技匠

发表于 2020-2-12 11:16:38

不知你说了什么
回复

使用道具 举报

kylinpoet  初级技神

发表于 2020-2-18 01:03:29

多谢分享,学习了。
回复

使用道具 举报

且歌且行  中级技师

发表于 2020-2-19 17:19:19


楼主懒得回答他在说什么~
回复

使用道具 举报

gada888  版主

发表于 2020-2-23 12:09:11

不是太懂
回复

使用道具 举报

小刚郭  初级技师
 楼主|

发表于 2020-3-26 20:15:18


我太难了
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

为本项目制作心愿单
购买心愿单
心愿单 编辑
[[wsData.name]]

硬件清单

  • [[d.name]]
btnicon
我也要做!
点击进入购买页面
上海智位机器人股份有限公司 沪ICP备09038501号-4

© 2013-2024 Comsenz Inc. Powered by Discuz! X3.4 Licensed

mail