-
Notifications
You must be signed in to change notification settings - Fork 0
/
bot.py
30 lines (25 loc) · 768 Bytes
/
bot.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/env python3.6
# coding: utf-8
from wxpy import *
import img
import logging
import msg_handler
import serial_port
logging.basicConfig(filename='wechat_bot.log',level=logging.INFO)
logger = logging.getLogger(__name__)
bot = Bot(console_qr=True)
bot.enable_puid()
master = bot.friends().search(sex=MALE)[0]
handlers = [msg_handler.TakePicutreHandler(),msg_handler.TemperatureHandler() ,msg_handler.LightHandler(), msg_handler.TulingHandler()]
@bot.register(msg_types=TEXT, except_self=False)
def auto_reply_all(msg):
logger.info('received text message : %s',msg)
#msg.chat.send('Hello!')
#msg.reply('World!')
#tuling.do_reply(msg)
for handler in handlers:
if handler.match(msg):
handler.handle(msg)
break
serial_port.start(master)
bot.join()