🎨 改进代码样式

This commit is contained in:
github-actions[bot] 2021-09-05 08:42:56 +00:00
parent 2f902837f6
commit 8233950bad
6 changed files with 19 additions and 30 deletions

View File

@ -1,4 +1,4 @@
package main package main
import ( import (
"fmt" "fmt"

View File

@ -25,7 +25,6 @@ var (
func init() { // 插件主体 func init() { // 插件主体
zero.OnFullMatch("ATRI醒醒", zero.AdminPermission).SetBlock(true).SetPriority(prio). zero.OnFullMatch("ATRI醒醒", zero.AdminPermission).SetBlock(true).SetPriority(prio).
Handle(func(ctx *zero.Ctx) { Handle(func(ctx *zero.Ctx) {
enable = true enable = true
time.Sleep(time.Second * 1) time.Sleep(time.Second * 1)
ctx.SendChain(randText("嗯呜呜……夏生先生……?")) ctx.SendChain(randText("嗯呜呜……夏生先生……?"))
@ -50,7 +49,6 @@ func init() { // 插件主体
Handle(func(ctx *zero.Ctx) { Handle(func(ctx *zero.Ctx) {
time.Sleep(time.Second * 1) time.Sleep(time.Second * 1)
ctx.SendChain(randImage("SUKI.jpg", "SUKI1.jpg", "SUKI2.png")) ctx.SendChain(randImage("SUKI.jpg", "SUKI1.jpg", "SUKI2.png"))
}) })
zero.OnKeywordGroup([]string{"草你妈", "操你妈", "脑瘫", "废柴", "fw", "five", "废物", "战斗", "爬", "爪巴", "sb", "SB", "傻B"}, atriSwitch(), atriSleep(), zero.OnlyToMe).SetBlock(true).SetPriority(prio - 1). zero.OnKeywordGroup([]string{"草你妈", "操你妈", "脑瘫", "废柴", "fw", "five", "废物", "战斗", "爬", "爪巴", "sb", "SB", "傻B"}, atriSwitch(), atriSleep(), zero.OnlyToMe).SetBlock(true).SetPriority(prio - 1).
Handle(func(ctx *zero.Ctx) { Handle(func(ctx *zero.Ctx) {
@ -113,7 +111,7 @@ func init() { // 插件主体
)) ))
} }
}) })
zero.OnFullMatchGroup([]string{"晚安", "oyasuminasai", "おやすみなさい", "晚好","晚上好"}, atriSwitch()).SetBlock(true).SetPriority(prio). zero.OnFullMatchGroup([]string{"晚安", "oyasuminasai", "おやすみなさい", "晚好", "晚上好"}, atriSwitch()).SetBlock(true).SetPriority(prio).
Handle(func(ctx *zero.Ctx) { Handle(func(ctx *zero.Ctx) {
now := time.Now().Hour() now := time.Now().Hour()
switch { switch {

View File

@ -2,13 +2,14 @@ package qingyunke
//定时早安,晚安 //定时早安,晚安
import ( import (
"github.com/robfig/cron"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
"log" "log"
"math/rand" "math/rand"
"strconv" "strconv"
"time" "time"
"github.com/robfig/cron"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
) )
func init() { func init() {
@ -20,10 +21,8 @@ func init() {
for _, v := range result.Array() { for _, v := range result.Array() {
Daily(v.Get("group_id").Int()) Daily(v.Get("group_id").Int())
} }
}) })
} }
func morningData(groupId int64) { func morningData(groupId int64) {

View File

@ -12,6 +12,7 @@ import (
var ( var (
reImg = `https?://[^"]+?(\.((jpg)|(png)|(jpeg)|(gif)|(bmp)))` reImg = `https?://[^"]+?(\.((jpg)|(png)|(jpeg)|(gif)|(bmp)))`
) )
//取图片 //取图片
func getPicture() string { func getPicture() string {
prefix := "https://fabiaoqing.com/tag/detail/id/5682/page" prefix := "https://fabiaoqing.com/tag/detail/id/5682/page"

View File

@ -3,9 +3,6 @@ package qingyunke
import ( import (
"encoding/json" "encoding/json"
"fmt" "fmt"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/extension/rate"
"github.com/wdvxdr1123/ZeroBot/message"
"io/ioutil" "io/ioutil"
"math/rand" "math/rand"
"net/http" "net/http"
@ -13,6 +10,10 @@ import (
"strconv" "strconv"
"strings" "strings"
"time" "time"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/extension/rate"
"github.com/wdvxdr1123/ZeroBot/message"
) )
var prio = -1 var prio = -1
@ -41,13 +42,11 @@ func init() { // 插件主体
} }
textReply = strings.Replace(textReply, "菲菲", "椛椛", -1) textReply = strings.Replace(textReply, "菲菲", "椛椛", -1)
if ctx.Event.DetailType == "group" { if ctx.Event.DetailType == "group" {
if faceReply != -1 { if faceReply != -1 {
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(textReply), message.Face(faceReply)) ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(textReply), message.Face(faceReply))
} else { } else {
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(textReply)) ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(textReply))
} }
} }
if ctx.Event.DetailType == "private" { if ctx.Event.DetailType == "private" {
if faceReply != -1 { if faceReply != -1 {
@ -60,7 +59,6 @@ func init() { // 插件主体
default: default:
//频繁触发,不回复 //频繁触发,不回复
} }
}) })
zero.OnRegex("CQ:image,file=|CQ:face,id=", zero.OnlyToMe, atriSwitch()).SetBlock(false).FirstPriority(). zero.OnRegex("CQ:image,file=|CQ:face,id=", zero.OnlyToMe, atriSwitch()).SetBlock(false).FirstPriority().
Handle(func(ctx *zero.Ctx) { Handle(func(ctx *zero.Ctx) {
@ -72,26 +70,20 @@ func init() { // 插件主体
if ctx.Event.DetailType == "private" { if ctx.Event.DetailType == "private" {
ctx.SendChain(message.Image(imageUrl)) ctx.SendChain(message.Image(imageUrl))
} }
}) })
zero.OnFullMatch("开启自动回复", zero.SuperUserPermission).SetBlock(true).SetPriority(prio). zero.OnFullMatch("开启自动回复", zero.SuperUserPermission).SetBlock(true).SetPriority(prio).
Handle(func(ctx *zero.Ctx) { Handle(func(ctx *zero.Ctx) {
enable = true enable = true
ctx.SendChain(message.Text("自动回复开启")) ctx.SendChain(message.Text("自动回复开启"))
}) })
zero.OnFullMatch("关闭自动回复", zero.SuperUserPermission).SetBlock(true).SetPriority(prio). zero.OnFullMatch("关闭自动回复", zero.SuperUserPermission).SetBlock(true).SetPriority(prio).
Handle(func(ctx *zero.Ctx) { Handle(func(ctx *zero.Ctx) {
enable = false enable = false
ctx.SendChain(message.Text("自动回复关闭")) ctx.SendChain(message.Text("自动回复关闭"))
}) })
// 群空调 // 群空调
} }
type QYData struct { type QYData struct {

View File

@ -1,22 +1,21 @@
package qingyunke package qingyunke
import ( import (
zero "github.com/wdvxdr1123/ZeroBot" zero "github.com/wdvxdr1123/ZeroBot"
"log"
) )
//自动同意加群,加好友 //自动同意加群,加好友
func init() { func init() {
zero.OnRequest().SetBlock(false).FirstPriority().Handle(func(ctx *zero.Ctx) { zero.OnRequest().SetBlock(false).FirstPriority().Handle(func(ctx *zero.Ctx) {
if ctx.Event.RequestType == "friend"{ if ctx.Event.RequestType == "friend" {
log.Println("加好友") log.Println("加好友")
ctx.SetFriendAddRequest(ctx.Event.Flag,true,"") ctx.SetFriendAddRequest(ctx.Event.Flag, true, "")
} }
if ctx.Event.RequestType == "group" && ctx.Event.SubType == "invite"{ if ctx.Event.RequestType == "group" && ctx.Event.SubType == "invite" {
log.Println("加群") log.Println("加群")
ctx.SetGroupAddRequest(ctx.Event.Flag,"invite",true,"我爱你mua~") ctx.SetGroupAddRequest(ctx.Event.Flag, "invite", true, "我爱你mua~")
} }
}) })
} }