4 Star 13 Fork 6

Gitee 极速下载 / Chanify

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
此仓库是为了提升国内下载速度的镜像仓库,每日同步一次。 原始仓库: https://github.com/chanify/chanify
克隆/下载
github.lua 1.00 KB
一键复制 编辑 原始数据 按行查看 历史
wizjin 提交于 2022-03-10 11:00 . docs: lua api doc (close #118).
-- Github Webhook Event
-- Ref: https://docs.github.com/en/developers/webhooks-and-events/webhooks
local hex = require 'hex'
local json = require 'json'
local crypto = require'crypto'
local seckey = ctx:env("SECRET_TOKEN")
local req = ctx:request()
local sign = hex.decode(req:header("X-HUB-SIGNATURE-256"):sub(8))
if not crypto.equal(crypto.hmac("sha256", seckey, req:body()), sign) then
return 401
end
local data = json.decode(req:body())
local event = req:header("X-GitHub-Event")
local msg = ""
if event == "push" then
msg = string.format("push commit:\n%s", data["head_commit"]["message"])
elseif event == "release" then
msg = string.format("release %s %s", data["release"]["tag_name"], data["action"])
elseif event == "issues" then
msg = string.format("issues %s:\n%s", data["action"], data["issue"]["title"])
else
msg = string.format("%s %s", event, data["action"])
end
local ret = ctx:send({
title = "Github " .. data["repository"]["full_name"],
text = msg,
sound = req:query("sound"),
})
return 200, ret
1
https://gitee.com/mirrors/Chanify.git
git@gitee.com:mirrors/Chanify.git
mirrors
Chanify
Chanify
main

搜索帮助