Skip to content
This repository has been archived by the owner on Jun 22, 2023. It is now read-only.

Commit

Permalink
add 疫情播报开关
Browse files Browse the repository at this point in the history
  • Loading branch information
mcoo committed Jun 3, 2021
1 parent 9d91169 commit bc587ee
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 47 deletions.
4 changes: 1 addition & 3 deletions Bili/bili.go
Original file line number Diff line number Diff line change
Expand Up @@ -361,9 +361,8 @@ func NewManager() (m Manager) {
m.ups[mid] = Up{
Name: v1.Name,
Created: v1.Created,
UserId: v1.UserId,
Groups: []int64{groupId},
UserId: v1.UserId,
Groups: []int64{groupId},
}
}
}
Expand All @@ -376,7 +375,6 @@ func NewManager() (m Manager) {
Id: v1.Id,
UserId: v1.UserId,
Groups: []int64{groupId},
UserId: v1.UserId,
}
}
}
Expand Down
1 change: 1 addition & 0 deletions Config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ type CoreConfigStruct struct {
Url string
QQ int64
}
YiQing bool
ReverseProxy string
DefaultGroupConfig GroupConfig
SuperAdminUin int64
Expand Down
19 changes: 15 additions & 4 deletions githubManager/hookManager.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,18 +117,29 @@ func NewManager(app *iris.Application, bot *OPQBot.BotManager) Manager {
}
r, _ := requests.Get(v.Sender.AvatarURL)
for _, v1 := range h.Groups {
m.b.SendGroupPicMsg(v1, fmt.Sprintf("%s\nCommit:\n%s", v.Repository.FullName, strings.Join(commitString, "\n")), r.Content())
m.b.SendGroupPicMsg(v1, fmt.Sprintf("%s\n%s发起了Push\nCommit:\n%s", v.Repository.FullName, v.Pusher.Name, strings.Join(commitString, "\n")), r.Content())
}
case github.ReleasePayload:
r, _ := requests.Get(v.Sender.AvatarURL)

for _, v1 := range h.Groups {
m.b.SendGroupPicMsg(v1, fmt.Sprintf("%s\n发布了:\n%s", v.Repository.FullName, v.Release.TagName), r.Content())
m.b.SendGroupPicMsg(v1, fmt.Sprintf("%s\n%s发布了新版本:\n%s", v.Repository.FullName, v.Sender.Login, v.Release.TagName), r.Content())

}
case github.PullRequestPayload:
r, _ := requests.Get(v.Sender.AvatarURL)
r, _ := requests.Get(v.PullRequest.User.AvatarURL)
msg := ""
switch v.Action {
case "closed":
msg = fmt.Sprintf("%s\n%s关闭了PR:%s to %s", v.Repository.FullName, v.PullRequest.User.Login, v.PullRequest.Head.Label, v.PullRequest.Base.Label)
case "opened":
msg = fmt.Sprintf("%s\n%s打开了PR:%s to %s", v.Repository.FullName, v.PullRequest.User.Login, v.PullRequest.Head.Label, v.PullRequest.Base.Label)
default:
ctx.StatusCode(503)
return
}
for _, v1 := range h.Groups {
m.b.SendGroupPicMsg(v1, fmt.Sprintf("%s\nPR:\n%s to %s", v.Repository.FullName, v.PullRequest.Head.Label, v.PullRequest.Base.Label), r.Content())
m.b.SendGroupPicMsg(v1, msg, r.Content())
}

}
Expand Down
81 changes: 43 additions & 38 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,31 +138,36 @@ func main() {
}
}
})
c.AddJob(-1, "Yiqing" ,"* * 8,18 * * ? " , func() {
client := &http.Client{}
baseUrl := "https://m.sm.cn/api/rest?method=Huoshenshan.local"
req ,err := http.NewRequest("GET",baseUrl,nil)
req.Header.Add("User-Agent","Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1")
req.Header.Add("referer" , "https://broccoli.uc.cn/" )
if(err !=nil){
panic(err)
}
response, _ := client.Do(req)
defer response.Body.Close()
s,err:=ioutil.ReadAll(response.Body)
var res yiqing.YiqingRes
json.Unmarshal(s, &res)
ups := fmt.Sprintf("疫情报告")
ups += fmt.Sprintf("%s-%s\n全国单日报告%s\n" ,res.Title ,res.Time,res.MainReport.Report)
ups += fmt.Sprintf("[表情190][表情190][表情190]信息总览[表情190][表情190][表情190]\n")
ups += fmt.Sprintf("[表情145]全国累计确诊%s个昨日新增%s个\n",res.ContryData.SureCnt,res.ContryData.YstCureCnt)
ups += fmt.Sprintf("[表情145]全国现存确诊%s个昨日新增%s个\n",res.ContryData.RestSureCnt,res.ContryData.RestSureCntIncr)
ups += fmt.Sprintf("[表情145]累计输入确诊%s个\n",res.ContryData.InputCnt)
ups += fmt.Sprintf("[表情145]全国累计治愈%s个昨日新增%s个\n",res.ContryData.CureCnt,res.ContryData.YstCureCnt)
ups += fmt.Sprintf("[表情66][表情66][表情66]疫情当下,请注意保护安全")
b.SendGroupTextMsg(-1, fmt.Sprintf(ups))
fmt.Println(ups)
})
Config.Lock.RLock()
yq := Config.CoreConfig.YiQing
Config.Lock.RUnlock()
if yq {
c.AddJob(-1, "Yiqing", "* * 8,18 * * ? ", func() {
client := &http.Client{}
baseUrl := "https://m.sm.cn/api/rest?method=Huoshenshan.local"
req, err := http.NewRequest("GET", baseUrl, nil)
req.Header.Add("User-Agent", "Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1")
req.Header.Add("referer", "https://broccoli.uc.cn/")
if err != nil {
panic(err)
}
response, _ := client.Do(req)
defer response.Body.Close()
s, err := ioutil.ReadAll(response.Body)
var res yiqing.YiqingRes
json.Unmarshal(s, &res)
ups := fmt.Sprintf("疫情报告")
ups += fmt.Sprintf("%s-%s\n全国单日报告%s\n", res.Title, res.Time, res.MainReport.Report)
ups += fmt.Sprintf("[表情190][表情190][表情190]信息总览[表情190][表情190][表情190]\n")
ups += fmt.Sprintf("[表情145]全国累计确诊%s个昨日新增%s个\n", res.ContryData.SureCnt, res.ContryData.YstCureCnt)
ups += fmt.Sprintf("[表情145]全国现存确诊%s个昨日新增%s个\n", res.ContryData.RestSureCnt, res.ContryData.RestSureCntIncr)
ups += fmt.Sprintf("[表情145]累计输入确诊%s个\n", res.ContryData.InputCnt)
ups += fmt.Sprintf("[表情145]全国累计治愈%s个昨日新增%s个\n", res.ContryData.CureCnt, res.ContryData.YstCureCnt)
ups += fmt.Sprintf("[表情66][表情66][表情66]疫情当下,请注意保护安全")
b.SendGroupTextMsg(-1, fmt.Sprintf(ups))
//fmt.Println(ups)
})
}
err = b.AddEvent(OPQBot.EventNameOnFriendMessage, func(qq int64, packet *OPQBot.FriendMsgPack) {
s := b.Session.SessionStart(packet.FromUin)
if v, err := s.GetString("github"); err == nil {
Expand Down Expand Up @@ -550,7 +555,7 @@ func main() {
b.SendGroupTextMsg(packet.FromGroupID, "本群没有订阅UP主")
return
}
for mid, v1 := range c.BiliUps {
for mid, v1 := range c.BiliUps {
ups += fmt.Sprintf("%d - %s -订阅者:%d\n", mid, v1.Name, v1.UserId)
}
b.SendGroupTextMsg(packet.FromGroupID, ups)
Expand Down Expand Up @@ -606,31 +611,31 @@ func main() {
return
}
for mid, v1 := range c.Fanjus {
ups += fmt.Sprintf("%d - %s-订阅用户为:%d \n", mid, v1.Title,v1.UserId)
ups += fmt.Sprintf("%d - %s-订阅用户为:%d \n", mid, v1.Title, v1.UserId)
}
b.SendGroupTextMsg(packet.FromGroupID, ups)
}
if packet.Content == "疫情信息"{
if packet.Content == "疫情信息" {
b.SendGroupTextMsg(packet.FromGroupID, "正在查找信息")
client := &http.Client{}
baseUrl := "https://m.sm.cn/api/rest?method=Huoshenshan.local"
req ,err := http.NewRequest("GET",baseUrl,nil)
req.Header.Add("User-Agent","Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1")
req.Header.Add("referer" , "https://broccoli.uc.cn/" )
if(err !=nil){
req, err := http.NewRequest("GET", baseUrl, nil)
req.Header.Add("User-Agent", "Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1")
req.Header.Add("referer", "https://broccoli.uc.cn/")
if err != nil {
panic(err)
}
response, _ := client.Do(req)
defer response.Body.Close()
s,err:=ioutil.ReadAll(response.Body)
s, err := ioutil.ReadAll(response.Body)
var res yiqing.YiqingRes
json.Unmarshal(s, &res)
ups := fmt.Sprintf("%s-%s\n全国单日报告%s\n" ,res.Title ,res.Time,res.MainReport.Report)
ups := fmt.Sprintf("%s-%s\n全国单日报告%s\n", res.Title, res.Time, res.MainReport.Report)
ups += fmt.Sprintf("[表情190][表情190][表情190]信息总览[表情190][表情190][表情190]\n")
ups += fmt.Sprintf("[表情145]全国累计确诊%s个昨日新增%s个\n",res.ContryData.SureCnt,res.ContryData.YstCureCnt)
ups += fmt.Sprintf("[表情145]全国现存确诊%s个昨日新增%s个\n",res.ContryData.RestSureCnt,res.ContryData.RestSureCntIncr)
ups += fmt.Sprintf("[表情145]累计输入确诊%s个\n",res.ContryData.InputCnt)
ups += fmt.Sprintf("[表情145]全国累计治愈%s个昨日新增%s个\n",res.ContryData.CureCnt,res.ContryData.YstCureCnt)
ups += fmt.Sprintf("[表情145]全国累计确诊%s个昨日新增%s个\n", res.ContryData.SureCnt, res.ContryData.YstCureCnt)
ups += fmt.Sprintf("[表情145]全国现存确诊%s个昨日新增%s个\n", res.ContryData.RestSureCnt, res.ContryData.RestSureCntIncr)
ups += fmt.Sprintf("[表情145]累计输入确诊%s个\n", res.ContryData.InputCnt)
ups += fmt.Sprintf("[表情145]全国累计治愈%s个昨日新增%s个\n", res.ContryData.CureCnt, res.ContryData.YstCureCnt)
ups += fmt.Sprintf("[表情66][表情66][表情66]疫情当下,请注意保护安全")
b.SendGroupTextMsg(packet.FromGroupID, fmt.Sprintf(ups))
fmt.Println(ups)
Expand Down
3 changes: 1 addition & 2 deletions update.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package main

import (
"OPQBot-QQGroupManager"
"github.com/mcoo/requests"
"log"
"runtime"
Expand Down Expand Up @@ -94,7 +93,7 @@ func CheckUpdate() {
log.Println(err)
return
}
if !strings.HasSuffix(result.TagName, main.version) {
if !strings.HasSuffix(result.TagName, version) {
log.Println("检测到更新欧~ " + result.TagName)
if result.Prerelease {
log.Println("注意最新版本为预发行版本")
Expand Down

0 comments on commit bc587ee

Please sign in to comment.