[{"createTime":1735734952000,"id":1,"img":"hwy_ms_500_252.jpeg","link":"https://activity.huaweicloud.com/cps.html?fromacct=261f35b6-af54-4511-a2ca-910fa15905d1&utm_source=V1g3MDY4NTY=&utm_medium=cps&utm_campaign=201905","name":"华为云秒杀","status":9,"txt":"华为云38元秒杀","type":1,"updateTime":1735747411000,"userId":3},{"createTime":1736173885000,"id":2,"img":"txy_480_300.png","link":"https://cloud.tencent.com/act/cps/redirect?redirect=1077&cps_key=edb15096bfff75effaaa8c8bb66138bd&from=console","name":"腾讯云秒杀","status":9,"txt":"腾讯云限量秒杀","type":1,"updateTime":1736173885000,"userId":3},{"createTime":1736177492000,"id":3,"img":"aly_251_140.png","link":"https://www.aliyun.com/minisite/goods?userCode=pwp8kmv3","memo":"","name":"阿里云","status":9,"txt":"阿里云2折起","type":1,"updateTime":1736177492000,"userId":3},{"createTime":1735660800000,"id":4,"img":"vultr_560_300.png","link":"https://www.vultr.com/?ref=9603742-8H","name":"Vultr","status":9,"txt":"Vultr送$100","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":5,"img":"jdy_663_320.jpg","link":"https://3.cn/2ay1-e5t","name":"京东云","status":9,"txt":"京东云特惠专区","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":6,"img":"new_ads.png","link":"https://www.iodraw.com/ads","name":"发布广告","status":9,"txt":"发布广告","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":7,"img":"yun_910_50.png","link":"https://activity.huaweicloud.com/discount_area_v5/index.html?fromacct=261f35b6-af54-4511-a2ca-910fa15905d1&utm_source=aXhpYW95YW5nOA===&utm_medium=cps&utm_campaign=201905","name":"底部","status":9,"txt":"高性能云服务器2折起","type":2,"updateTime":1735660800000,"userId":3}]
python实实现现定定时时发发送送qq消消息息
这篇文章主要为大家详细介绍了python实现定时发送qq消息,具有一定的参考价值,感兴趣的小伙伴们可以参考
一下
因为生 中老是忘记各种事情,刚好又在学python,便突发奇想通过python实现提醒任务的功能 (尽管TIM有定时功
能),也可定时给好友、群、讨论组发送qq消息。其工作流程是 :访问数据库提取最近计划—— >根据数据内容 (提
醒时间、提醒对象、提醒内容)设置定时任务—— >给特定qq好友发送消息。
1. 软件版本 :
2.安装依赖环境
pymysql安装 :pip install pymysql
qqbot安装 :pip install qqbot
3.数据库操作
数据库操作非常简 ,跟Java类似,自己去菜鸟教程看一下基础语法就好了。
#coding: utf-8
import pymysql #导入pymysql模块
db = pymysql.connect("localhost","root","root","info_db" #数据库链接信息
cursor = db.cursor(
#插入任务
def insertSchedule(schedule :
insertsql = "insert into dutyschedule_tb(worktime,name values(%s,%s "
try:
#这种查询语句可以防止sql注入
cursor.execute(insertsql,(schedule['worktime'],schedule['name']
mit(
except Exception:
db.rollback(
raise Exception
#删除任务
def deleteSchedule( :
deletesql = ""
try:
cursor.execute(deletesql
mit(
except Exception:
db.rollback(
def updateSchedule(user :
updatesql = ""
try:
cursor.execute(updatesql
mit(
except Exception:
db.rollback(
#获取下一个任务
def findScheduleByNewTime( :
selectsql = "SELECT * FROM dutyschedule_tb where NOW( <=
date_format(worktime,'%Y-%m-%d
%H:%i:%S' ORDER BY worktime ASC;"
try:
cursor.execute(selectsql
results = cursor.fetchone(
schedule = {}
schedule['worktime'] = results[1]
schedule['name'] = results[2]
schedule['content '] = results[3]
return schedule
except Exception:
return None
4.配置qqbot登陆信息
也可以不配置,不配置的话就是每次扫码登陆,但这在Linux系统下不好用,我按说明将配置改成了每次将登陆二维
码发到固定qq邮箱。qqbot模块在GitHub上,大家可以去看一下模块说明 :qqbot
配置文件默认在用户目录下的.qqbot tmp/v2.3.conf,linux下类似
{
# QQBot 的配置文件
# 使用 qqbot -u somebody 启动程