一、前言
弄了个小机器人,用来接待来宿舍里打印的人。目前可以实现自助打印等功能。
二、截图
三、源码
https://github.com/glzjin/wechat_print_bot
四、说明
要求
- python3
- clouconvert(https://cloudconvert.com/)的 api
- 一台支持 EpsonConnect(https://www.epsonconnect.com/)或者 Google cloud print (暂时没做- -)的打印机
部署
git clone https://github.com/glzjin/wechat_print_bot.git cd wechat_print_bot pip install -r requirements.txt配置
cp buu_config.py.example buu_config.py vi buu_config.py运行
python buu.py使用
- 扫码登录
- 用其他微信号加这个号为好友,随便发句话来获取菜单。
感谢
19 个评论
Joker
赵大,可以转载吗?(当然会附上原文地址
glzjin
当然可以
antior
非常棒的py程序,学习一下(当然先马克
glzjin
~
闲来无事,研究一波 – 自由技艺
[…] Cloudflare 最初的一波人的博客 https://www.zhaoj.in/read-4697.html […]
流浪
你好,看见了您的文章非常心动,但有一些地方不明白,配置confi里面具体得怎么配置呢?新手一枚,如果我的问题太简单请大大不要见笑
glzjin
里面 看名字- -理解 配置 不明白的话 可以在这里问~
xborner
不懂代码,还是很想尝试一下程序。请问下赵大,config 配置里的 smtp 都应该填些什么,mysql、redis 都是必要的吗,能否将机器人部署在远程服务器上,它又是如何给打印机发送命令开始打印的呢,有点乱 >_
glzjin
嗯都是必要的,你需要有一台支持 epsonconnect的打印机,这个发了邮件给这个服务来实现远程打印。
『教程』使用Python实现微信打印机器人 | Mr.KevinH
[…] 全文转载自https://www.zhaoj.in/read-4697.html […]
Kevin
已收藏!
来这里通知一下赵老师!
glzjin
感谢。
Fred
请问一下这是怎么回事呢
Traceback (most recent call last):
File “buu.py”, line 49, in
buu_model.class_model.init()
TypeError: unbound method init() must be called with class_model instance as first argument (got nothing instead)
谢谢!
Fred
不好意思打扰了,更新了python版本
Fred
不好意思,又来打扰了
Traceback (most recent call last):
File “buu.py”, line 6, in
import buu_msg_handle
File “/home/admin/wechat_print_bot/buu_msg_handle.py”, line 1, in
import buu_config, buu_command_dict, buu_database
File “/home/admin/wechat_print_bot/buu_command_dict.py”, line 2, in
import buu_config, buu_database
File “/home/admin/wechat_print_bot/buu_database.py”, line 2, in
import buu_config, buu_model
File “/home/admin/wechat_print_bot/buu_model.py”, line 4, in
class class_model(object):
File “/home/admin/wechat_print_bot/buu_model.py”, line 8, in class_model
host = buu_config.config.mysql_addr, db = buu_config.config.mysql_database)
File “/home/admin/miniconda3/lib/python3.7/site-packages/sqlobject/mysql/mysqlconnection.py”, line 99, in __init__
‘Cannot find a MySQL driver, tried %s’ % drivers)
ImportError: Cannot find a MySQL driver, tried mysqldb
这是为什么呢
glzjin
装个 mysql client 的包
Awelling
不好意思想问一下redis那里配置怎么填
log在这
Traceback (most recent call last):
File “/usr/local/lib/python3.5/dist-packages/redis/connection.py”, line 177, in _read_from_socket
raise socket.error(SERVER_CLOSED_CONNECTION_ERROR)
OSError: Connection closed by server.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File “/usr/local/lib/python3.5/dist-packages/redis/client.py”, line 667, in execute_command
connection.send_command(*args)
File “/usr/local/lib/python3.5/dist-packages/redis/connection.py”, line 610, in send_command
self.send_packed_command(self.pack_command(*args))
File “/usr/local/lib/python3.5/dist-packages/redis/connection.py”, line 585, in send_packed_command
self.connect()
File “/usr/local/lib/python3.5/dist-packages/redis/connection.py”, line 493, in connect
self.on_connect()
File “/usr/local/lib/python3.5/dist-packages/redis/connection.py”, line 567, in on_connect
if nativestr(self.read_response()) != ‘OK’:
File “/usr/local/lib/python3.5/dist-packages/redis/connection.py”, line 624, in read_response
response = self._parser.read_response()
File “/usr/local/lib/python3.5/dist-packages/redis/connection.py”, line 284, in read_response
response = self._buffer.readline()
File “/usr/local/lib/python3.5/dist-packages/redis/connection.py”, line 216, in readline
self._read_from_socket()
File “/usr/local/lib/python3.5/dist-packages/redis/connection.py”, line 191, in _read_from_socket
(e.args,))
redis.exceptions.ConnectionError: Error while reading from socket: (‘Connection closed by server.’,)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File “/usr/local/lib/python3.5/dist-packages/redis/connection.py”, line 177, in _read_from_socket
raise socket.error(SERVER_CLOSED_CONNECTION_ERROR)
OSError: Connection closed by server.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File “buu.py”, line 56, in
class_database_op.flush_redis()
File “/home/wechat_print_bot/buu_database.py”, line 14, in flush_redis
self.redis_ins.flushdb()
File “/usr/local/lib/python3.5/dist-packages/redis/client.py”, line 747, in flushdb
return self.execute_command(‘FLUSHDB’)
File “/usr/local/lib/python3.5/dist-packages/redis/client.py”, line 673, in execute_command
connection.send_command(*args)
File “/usr/local/lib/python3.5/dist-packages/redis/connection.py”, line 610, in send_command
self.send_packed_command(self.pack_command(*args))
File “/usr/local/lib/python3.5/dist-packages/redis/connection.py”, line 585, in send_packed_command
self.connect()
File “/usr/local/lib/python3.5/dist-packages/redis/connection.py”, line 493, in connect
self.on_connect()
File “/usr/local/lib/python3.5/dist-packages/redis/connection.py”, line 567, in on_connect
if nativestr(self.read_response()) != ‘OK’:
File “/usr/local/lib/python3.5/dist-packages/redis/connection.py”, line 624, in read_response
response = self._parser.read_response()
File “/usr/local/lib/python3.5/dist-packages/redis/connection.py”, line 284, in read_response
response = self._buffer.readline()
File “/usr/local/lib/python3.5/dist-packages/redis/connection.py”, line 216, in readline
self._read_from_socket()
File “/usr/local/lib/python3.5/dist-packages/redis/connection.py”, line 191, in _read_from_socket
(e.args,))
redis.exceptions.ConnectionError: Error while reading from socket: (‘Connection closed by server.’,)
Awelling
已解决
https://blog.csdn.net/Mikeoperfect/article/details/79468944
Awelling
抱歉又来了,请教一下赵大,itchat登陆成功后,发送任何文本给这个微信号都没有自动回复
root@Awelling:/home/wechat_print_bot# cat out.log
nohup: ignoring input
Start auto replying.
像上面那样
发送一个文件给微信号等待一段时间会有以下这个报错
root@Awelling:/home/wechat_print_bot# cat out.log
nohup: ignoring input
Start auto replying.
Traceback (most recent call last):
File “/usr/local/lib/python3.5/dist-packages/itchat/components/register.py”, line 60, in configured_reply
r = replyFn(msg)
File “buu.py”, line 16, in download_files
msg.download(“cache/files/” + real_file_name)
File “/usr/local/lib/python3.5/dist-packages/itchat/storage/messagequeue.py”, line 18, in download
return self.text(fileName)
File “/usr/local/lib/python3.5/dist-packages/itchat/components/messages.py”, line 163, in download_atta
with open(attaDir, ‘wb’) as f:
FileNotFoundError: [Errno 2] No such file or directory: ‘cache/files/pbbbwjlejkttcjugmvzqdonwcmbsxmyn.xlsx’