0
点赞
收藏
分享

微信扫一扫

企业微信打卡机器人

witmy 2022-01-20 阅读 98
from datetime import datetime
from chinese_calendar import is_workday
import copy
import json
import time
import requests
import schedule
def daka(content):
    api_path = "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=xxx"
    headers = {'Content-Type': 'application/json'}

    data = {
    "msgtype": "text",
    "text": {
        "content": content,
        "mentioned_list":["@all",],
    }
}

    date = datetime.now().date()
    if (is_workday(date)):
        a = requests.post(api_path, data=json.dumps(data), headers=headers)
        print(a.content)
        print("xxxxxxxxx企业微信机器人,请勿关闭xxxxxxxxx")
    
if __name__ == '__main__':
    print('-----------启动定时任务,请勿关闭该窗体---------------')
    schedule.every().day.at("08:45").do(daka, "宝宝们,早上打卡")
    schedule.every().day.at("21:00").do(daka, "宝宝们,发日报")
    while True:
        schedule.run_pending()

举报

相关推荐

0 条评论