杨戬在此,待我睁开第三只眼之时,便是我口嗨那一刻!
流程(我的流程呢?)
内容比较偏门,直接黏贴代码吧!
首先呢,当然是pip install django.dingtalkchatbot.chatbot 好像是这个?
然后呢就是在interview下创建dingtalk(该内容应该可以在对接文档看到)
from dingtalkchatbot.chatbot import DingtalkChatbotimport sysfrom settings import localsys.path.append('C:\\Users\\74708\\Desktop\\Django大法\\myyuque')def send(message, at_mobiles=[]):# 引用setting里面配置的钉钉群消息通知的webhook地址webhook = local.DINGTALK_WEB_HOOK# 初始化机器人小丁, 方式一:通常初始化方式xiaoding = DingtalkChatbot(webhook)# 方式二:勾选加签时候使用# xiaoding = DingtalkChatbot(webhook, secret=secret)# Test消息@所有人xiaoding.send_text(msg=('面试通知:%s' % message), at_mobiles=at_mobiles)
接着去admin.py文件定义通知按钮
@admin.action(description=u'通知')def notify_interview(message, request, queryset):candidates = ''interviewers = ''phone = []for obj in queryset:candidates = obj.username + ';' + candidatesinterviewers = obj.first_interviewer_user.username + ';' + interviewersphone.append(int(obj.first_interviewer_user.account_phone))dingtalk.send('候选人 %s 准备开始喂大便了,现在有请采屎官 %s 进来喂屎' % (candidates, interviewers), phone)
中间呢,需要去获取webhook地址,这个就需要去钉钉群获取,然后放到settings里面
from .base import *ALLOWED_HOSTS = ['']DINGTALK_WEB_HOOK = 'https://oapi.dingtalk.com/robot/send?access_token=09d14aae6ecc5fcaa9c78f08a06130d70d11781bc040498b78e40b0d0baf003e'
