# -*- coding: utf-8 -*-
"""
Created on Mon Jun 5 11:18:45 2023
@author: Administrator
"""
import requests
import json
from apscheduler.schedulers.blocking import BlockingScheduler
import datetime
#下午三点的下午茶
def job():
#飞书机器人发送
url = 'https://open.feishu.cn/open-apis/bot/v2/hook/7ae02b0f-63a5-4c13-af99-9f6fe6f05c46'
method = 'post'
headers = {
'Content-Type': 'application/json'
}
json = {
"msg_type": "interactive",
"card":
{
"config": {
"wide_screen_mode": True
},
"elements": [
{
"tag": "div",
"text": {
"content": "今天工作辛苦了,三点的下午茶记得奖励自己哦!",
"tag": "lark_md"
}
},
{
"actions": [
{
"tag": "button",
"text": {
"content": "立刻去",
"tag": "plain_text"
},
"type": "primary",
"multi_url": {
"url": "https://open.feishu.cn/",
"android_url": "",
"ios_url": "",
"pc_url": ""
}
},
{
"tag": "button",
"text": {
"content": "暂时不去",
"tag": "plain_text"
},
"type": "default",
"multi_url": {
"url": "https://open.feishu.cn/",
"android_url": "",
"ios_url": "",
"pc_url": ""
}
}
],
"tag": "action"
}
],
"header": {
"template": "turquoise",
"title": {
"content": "📚放松一下",
"tag": "plain_text"
}
}
}
}
requests.request(method=method, url=url, headers=headers, json=json)
#中午的午饭
def job1():
#飞书机器人发送
url1 = 'https://open.feishu.cn/open-apis/bot/v2/hook/7ae02b0f-63a5-4c13-af99-9f6fe6f05c46'
method = 'post'
headers = {
'Content-Type': 'application/json'
}
json = {
"msg_type": "interactive",
"card":
{
"config": {
"wide_screen_mode": True
},
"elements": [
{
"tag": "div",
"text": {
"content": "今天工作辛苦了,别忘了吃午饭哦!",
"tag": "lark_md"
}
},
{
"actions": [
{
"tag": "button",
"text": {
"content": "立刻去",
"tag": "plain_text"
},
"type": "primary",
"multi_url": {
"url": "https://open.feishu.cn/",
"android_url": "",
"ios_url": "",
"pc_url": ""
}
},
{
"tag": "button",
"text": {
"content": "暂时不去",
"tag": "plain_text"
},
"type": "default",
"multi_url": {
"url": "https://open.feishu.cn/",
"android_url": "",
"ios_url": "",
"pc_url": ""
}
}
],
"tag": "action"
}
],
"header": {
"template": "turquoise",
"title": {
"content": "📚放松一下",
"tag": "plain_text"
}
}
}
}
requests.request(method=method, url1=url1, headers=headers, json=json)
#下午五点五十五的晚饭
def job2():
#飞书机器人发送
url2 = 'https://open.feishu.cn/open-apis/bot/v2/hook/7ae02b0f-63a5-4c13-af99-9f6fe6f05c46'
method = 'post'
headers = {
'Content-Type': 'application/json'
}
json = {
"msg_type": "interactive",
"card":
{
"config": {
"wide_screen_mode": True
},
"elements": [
{
"tag": "div",
"text": {
"content": "今天工作辛苦了,晚饭别忘了哦!",
"tag": "lark_md"
}
},
{
"actions": [
{
"tag": "button",
"text": {
"content": "立刻去",
"tag": "plain_text"
},
"type": "primary",
"multi_url": {
"url": "https://open.feishu.cn/",
"android_url": "",
"ios_url": "",
"pc_url": ""
}
},
{
"tag": "button",
"text": {
"content": "暂时不去",
"tag": "plain_text"
},
"type": "default",
"multi_url": {
"url": "https://open.feishu.cn/",
"android_url": "",
"ios_url": "",
"pc_url": ""
}
}
],
"tag": "action"
}
],
"header": {
"template": "turquoise",
"title": {
"content": "📚放松一下",
"tag": "plain_text"
}
}
}
}
requests.request(method=method, url2=url2, headers=headers, json=json)
#早上打卡
def job3():
#飞书机器人发送
url3 = 'https://open.feishu.cn/open-apis/bot/v2/hook/7ae02b0f-63a5-4c13-af99-9f6fe6f05c46'
method = 'post'
headers = {
'Content-Type': 'application/json'
}
json = {
"msg_type": "interactive",
"card":
{
"config": {
"wide_screen_mode": True
},
"elements": [
{
"tag": "div",
"text": {
"content": "又是崭新的一天,别忘了打卡!",
"tag": "lark_md"
}
},
{
"actions": [
{
"tag": "button",
"text": {
"content": "马上打",
"tag": "plain_text"
},
"type": "primary",
"multi_url": {
"url": "https://open.feishu.cn/",
"android_url": "",
"ios_url": "",
"pc_url": ""
}
},
{
"tag": "button",
"text": {
"content": "马上到",
"tag": "plain_text"
},
"type": "default",
"multi_url": {
"url": "https://open.feishu.cn/",
"android_url": "",
"ios_url": "",
"pc_url": ""
}
}
],
"tag": "action"
}
],
"header": {
"template": "turquoise",
"title": {
"content": "📚记得打卡",
"tag": "plain_text"
}
}
}
}
requests.request(method=method, url2=url2, headers=headers, json=json)
#晚上打卡
def job4():
#飞书机器人发送
url2 = 'https://open.feishu.cn/open-apis/bot/v2/hook/7ae02b0f-63a5-4c13-af99-9f6fe6f05c46'
method = 'post'
headers = {
'Content-Type': 'application/json'
}
json = {
"msg_type": "interactive",
"card":
{
"config": {
"wide_screen_mode": True
},
"elements": [
{
"tag": "div",
"text": {
"content": "今天工作辛苦了,别忘了打卡!",
"tag": "lark_md"
}
},
{
"actions": [
{
"tag": "button",
"text": {
"content": "立刻打",
"tag": "plain_text"
},
"type": "primary",
"multi_url": {
"url": "https://open.feishu.cn/",
"android_url": "",
"ios_url": "",
"pc_url": ""
}
},
{
"tag": "button",
"text": {
"content": "等会儿打",
"tag": "plain_text"
},
"type": "default",
"multi_url": {
"url": "https://open.feishu.cn/",
"android_url": "",
"ios_url": "",
"pc_url": ""
}
}
],
"tag": "action"
}
],
"header": {
"template": "turquoise",
"title": {
"content": "📚记得打卡",
"tag": "plain_text"
}
}
}
}
requests.request(method=method, url2=url2, headers=headers, json=json)
# 创建一个调度器
scheduler = BlockingScheduler()
# 添加任务,每天早上 10 点执行一次
#scheduler.add_job(job, 'cron', hour=10)
scheduler.add_job(job, 'cron', hour=14, minute=58)
# 开始调度任务
scheduler.start()
# 创建一个调度器
scheduler1 = BlockingScheduler()
#scheduler.add_job(job, 'cron', hour=10)
scheduler1.add_job(job1, 'cron', hour=11, minute=30)
# 开始调度任务
scheduler1.start()
# 创建一个调度器
scheduler2 = BlockingScheduler()
#scheduler.add_job(job, 'cron', hour=10)
scheduler2.add_job(job2, 'cron', hour=17, minute=53)
# 开始调度任务
scheduler2.start()
# 创建一个调度器
scheduler3 = BlockingScheduler()
#scheduler.add_job(job, 'cron', hour=10)
scheduler3.add_job(job3, 'cron', hour=8, minute=50)
# 开始调度任务
scheduler3.start()
# 创建一个调度器
scheduler4 = BlockingScheduler()
#scheduler.add_job(job, 'cron', hour=10)
scheduler4.add_job(job4, 'cron', hour=18, minute=5)
# 开始调度任务
scheduler4.start()
飞书卡片发布多个定时任务案例python
最新推荐文章于 2024-07-26 21:19:18 发布