(1)每周一提醒业务组同事创建日报 wiki
(2)每周三提醒开发 owner 查看 bugly 问题
(3)每周五提醒学习小组 owner 组织分享
......等等诸如此类的需求
(1)发钉钉通知、确定通知内容、通知谁
(2)发送时间
(1)钉钉通知
钉钉公开 API
dingtalkchatbot(基于官方 AP 二次 I 封装)
(2)定时任务
python 定时任务 (sleep / Timer / schedule / APScheduler)
jenkisn 日程表
最后的选择:
(1)钉钉通知
from dingtalkchatbot.chatbot import DingtalkChatbot
from configparser import ConfigParser
class weekly():
def weeklyAlert(self, webhook, phone):
webhook = webhook
dingding = DingtalkChatbot(webhook)
# 发送 link消息
dingding.send_link(title='Python小助手', text='点击这里,查看本周的Python分享', message_url='https://wiki.lalal.ccc')
# 发送 Text消息@某人
at_mobiles = [phone]
dingding.send_text(msg='本周Python小助手', at_mobiles=at_mobiles)
print("phone : " + str(phone))
print(str("提醒成功"))
def read_config(self, cfg_file):
cfg = ConfigParser()
cfg.read(cfg_file)
return cfg
weekly = weekly()
cfg = weekly.read_config("/Users/test/Documents/weekly_base/weekphone.ini")
count = cfg.get('weekly', 'count')
webhook_week = 'https://oapi.dingtalk.com/robot/send?access_token=xxx'
if count == '0':
phone = '189xxx' # nico
weekly.weeklyAlert(webhook_week, phone)
cfg.set('weekly', 'count', '1')
cfg.write(open("/Users/test/Documents/weekly_base/weekphone.ini", "w"))
else :
phone = '158xxx' # budy
weekly.weeklyAlert(webhook_week, phone)
cfg.set('weekly', 'count', '0')
cfg.write(open("/Users/test/Documents/weekly_base/weekphone.ini", "w"))
(2)更新通知人
[weekly]
count = 3
(2)定时提醒
最终效果↓