企业微信群管理员创建机器人后可以使用以下脚本定时使用企业机器人往群里丢消息
#! /bin/bash/python
import sys, os
import datetime
import time
# 群消息机器人post地址 - 必填参数 场景信息同步组url
wechat_url = "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=df413e57-e7f1-4f26-89f4-3560715b8548"
#想要周几去发 - 必填参数
send_days = [2]
# 想要几点发 - 必填参数。 填入24小时制时间,例: "18:00:00"
send_times = ["11:00:00"]
# 发送内容 - 必填参数
message = "测试"
# 群发时候要@的人 - 可选参数。注意邮箱@前名字
classmate_list = ["mingtao.li","yang.lu02","yinjie.chen","cheng.chen","jingyuan.gu","qile.tang","chengxin.ding","ru.lin","yanjiang.guo","chao.wang02","yuxia.zhou","lu.zuo"]
# 获取周几、和 当前时分秒
def getDate():
now_time = datetime.datetime.now().strftime('%u-%H:%M:%S')
return now_time.split("-")[0], now_time.split("-")[1]
if __name__ == '__main__':
cmd = "curl '%s' -H 'Content-Type: application/json' -d '{\"msgtype\": \"text\", \"text\": {\"content\": \"%s\", \"mentioned_list\":%s}}'" %(wechat_url,message,str(classmate_list).replace("'", "\""))
while True:
day, t = getDate()
if int(day) in send_days:
if t in send_times:
os.system(cmd)
#print(t," : ",cmd)
time.sleep(1)
网友评论