mirror of
https://github.com/FloatTech/ZeroBot-Plugin.git
synced 2025-12-20 06:20:08 +08:00
✏️ make lint happy
This commit is contained in:
parent
a3b5a226ac
commit
7c5d08b723
@ -70,7 +70,7 @@ func init() {
|
|||||||
keyword := ctx.State["regex_matched"].([]string)[1]
|
keyword := ctx.State["regex_matched"].([]string)[1]
|
||||||
soutujson := soutuapi(keyword)
|
soutujson := soutuapi(keyword)
|
||||||
pom1 := "https://i.pixiv.re"
|
pom1 := "https://i.pixiv.re"
|
||||||
rannum := randintn(len(soutujson.Illusts))
|
rannum := rintn(len(soutujson.Illusts))
|
||||||
pom2 := soutujson.Illusts[rannum].ImageUrls.Medium[19:]
|
pom2 := soutujson.Illusts[rannum].ImageUrls.Medium[19:]
|
||||||
ctx.SendChain(message.Image(pom1 + pom2))
|
ctx.SendChain(message.Image(pom1 + pom2))
|
||||||
})
|
})
|
||||||
@ -102,8 +102,8 @@ func soutuapi(keyword string) *resultjson {
|
|||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
// randintn 从json里的30条数据中随机获取一条返回
|
// rintn 从json里的30条数据中随机获取一条返回
|
||||||
func randintn(len int) int {
|
func rintn(len int) int {
|
||||||
rand.Seed(time.Now().UnixNano())
|
rand.Seed(time.Now().UnixNano())
|
||||||
return rand.Intn(len)
|
return rand.Intn(len)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -33,7 +33,7 @@ func checkNewUser(qq, gid int64, ghun, hash string) (bool, string) {
|
|||||||
// 600s 内验证成功
|
// 600s 内验证成功
|
||||||
ok := math.Abs(int(time.Now().Unix()-st)) < 600
|
ok := math.Abs(int(time.Now().Unix()-st)) < 600
|
||||||
if ok {
|
if ok {
|
||||||
_ = db.Insert("member", &Member{QQ: qq, Ghun: ghun})
|
_ = db.Insert("member", &member{QQ: qq, Ghun: ghun})
|
||||||
return true, ""
|
return true, ""
|
||||||
}
|
}
|
||||||
return false, "时间戳超时"
|
return false, "时间戳超时"
|
||||||
|
|||||||
@ -1,11 +1,11 @@
|
|||||||
package manager
|
package manager
|
||||||
|
|
||||||
type Welcome struct {
|
type welcome struct {
|
||||||
GrpID int64 `db:"gid"`
|
GrpID int64 `db:"gid"`
|
||||||
Msg string `db:"msg"`
|
Msg string `db:"msg"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Member struct {
|
type member struct {
|
||||||
QQ int64 `db:"qq"`
|
QQ int64 `db:"qq"`
|
||||||
// github username
|
// github username
|
||||||
Ghun string `db:"ghun"`
|
Ghun string `db:"ghun"`
|
||||||
|
|||||||
@ -66,8 +66,14 @@ func init() { // 插件主体
|
|||||||
go func() {
|
go func() {
|
||||||
process.SleepAbout1sTo2s()
|
process.SleepAbout1sTo2s()
|
||||||
clock = timer.NewClock(db)
|
clock = timer.NewClock(db)
|
||||||
db.Create("welcome", &Welcome{})
|
err := db.Create("welcome", &welcome{})
|
||||||
db.Create("member", &Member{})
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
err = db.Create("member", &member{})
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
}()
|
}()
|
||||||
// 升为管理
|
// 升为管理
|
||||||
engine.OnRegex(`^升为管理.*?(\d+)`, zero.OnlyGroup, zero.SuperUserPermission).SetBlock(true).SetPriority(40).
|
engine.OnRegex(`^升为管理.*?(\d+)`, zero.OnlyGroup, zero.SuperUserPermission).SetBlock(true).SetPriority(40).
|
||||||
@ -362,7 +368,7 @@ func init() { // 插件主体
|
|||||||
engine.OnNotice().SetBlock(false).FirstPriority().
|
engine.OnNotice().SetBlock(false).FirstPriority().
|
||||||
Handle(func(ctx *zero.Ctx) {
|
Handle(func(ctx *zero.Ctx) {
|
||||||
if ctx.Event.NoticeType == "group_increase" && ctx.Event.SelfID != ctx.Event.UserID {
|
if ctx.Event.NoticeType == "group_increase" && ctx.Event.SelfID != ctx.Event.UserID {
|
||||||
var w Welcome
|
var w welcome
|
||||||
err := db.Find("welcome", &w, "where gid = "+strconv.FormatInt(ctx.Event.GroupID, 10))
|
err := db.Find("welcome", &w, "where gid = "+strconv.FormatInt(ctx.Event.GroupID, 10))
|
||||||
if err == nil {
|
if err == nil {
|
||||||
ctx.SendChain(message.Text(w.Msg))
|
ctx.SendChain(message.Text(w.Msg))
|
||||||
@ -422,7 +428,7 @@ func init() { // 插件主体
|
|||||||
// 设置欢迎语
|
// 设置欢迎语
|
||||||
engine.OnRegex(`^设置欢迎语([\s\S]*)$`, zero.OnlyGroup, zero.AdminPermission).SetBlock(true).SetPriority(40).
|
engine.OnRegex(`^设置欢迎语([\s\S]*)$`, zero.OnlyGroup, zero.AdminPermission).SetBlock(true).SetPriority(40).
|
||||||
Handle(func(ctx *zero.Ctx) {
|
Handle(func(ctx *zero.Ctx) {
|
||||||
w := &Welcome{
|
w := &welcome{
|
||||||
GrpID: ctx.Event.GroupID,
|
GrpID: ctx.Event.GroupID,
|
||||||
Msg: ctx.State["regex_matched"].([]string)[1],
|
Msg: ctx.State["regex_matched"].([]string)[1],
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,35 +6,35 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
type holiday struct {
|
// Holiday 节日
|
||||||
|
type Holiday struct {
|
||||||
name string
|
name string
|
||||||
date time.Time
|
date time.Time
|
||||||
dur time.Duration
|
dur time.Duration
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewHoliday 节日名 天数 年 月 日
|
// NewHoliday 节日名 天数 年 月 日
|
||||||
func NewHoliday(name string, dur, year int, month time.Month, day int) *holiday {
|
func NewHoliday(name string, dur, year int, month time.Month, day int) *Holiday {
|
||||||
return &holiday{name: name, date: time.Date(year, month, day, 0, 0, 0, 0, time.Local), dur: time.Duration(dur) * time.Hour * 24}
|
return &Holiday{name: name, date: time.Date(year, month, day, 0, 0, 0, 0, time.Local), dur: time.Duration(dur) * time.Hour * 24}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取两个时间相差
|
// 获取两个时间相差
|
||||||
func (h *holiday) String() string {
|
func (h *Holiday) String() string {
|
||||||
d := time.Until(h.date)
|
d := time.Until(h.date)
|
||||||
if d >= 0 {
|
switch {
|
||||||
|
case d >= 0:
|
||||||
return "距离" + h.name + "还有: " + strconv.FormatFloat(d.Hours()/24.0, 'f', 2, 64) + "天!"
|
return "距离" + h.name + "还有: " + strconv.FormatFloat(d.Hours()/24.0, 'f', 2, 64) + "天!"
|
||||||
} else if d+h.dur >= 0 {
|
case d+h.dur >= 0:
|
||||||
return "好好享受 " + h.name + " 假期吧!"
|
return "好好享受 " + h.name + " 假期吧!"
|
||||||
} else {
|
default:
|
||||||
return "今年 " + h.name + " 假期已过"
|
return "今年 " + h.name + " 假期已过"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func weekend() string {
|
func weekend() string {
|
||||||
t := time.Now().Weekday()
|
t := time.Now().Weekday()
|
||||||
switch t {
|
if t == time.Sunday || t == time.Saturday {
|
||||||
case time.Sunday, time.Saturday:
|
|
||||||
return "好好享受周末吧!"
|
return "好好享受周末吧!"
|
||||||
default:
|
|
||||||
return fmt.Sprintf("距离周末还有:%d天!", 5-t)
|
|
||||||
}
|
}
|
||||||
|
return fmt.Sprintf("距离周末还有:%d天!", 5-t)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
// Package moyu 摸鱼
|
||||||
package moyu
|
package moyu
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
// Package nativesetu 本地setu
|
||||||
package nativesetu
|
package nativesetu
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@ -116,8 +116,8 @@ func init() {
|
|||||||
if reg.MatchString(recordUrl) {
|
if reg.MatchString(recordUrl) {
|
||||||
// log.Println(reg.FindStringSubmatch(recordUrl)[1])
|
// log.Println(reg.FindStringSubmatch(recordUrl)[1])
|
||||||
// log.Println(url.QueryEscape(reg.FindStringSubmatch(recordUrl)[1]))
|
// log.Println(url.QueryEscape(reg.FindStringSubmatch(recordUrl)[1]))
|
||||||
recordUrl = strings.Replace(recordUrl, reg.FindStringSubmatch(recordUrl)[1], url.QueryEscape(reg.FindStringSubmatch(recordUrl)[1]), -1)
|
recordUrl = strings.ReplaceAll(recordUrl, reg.FindStringSubmatch(recordUrl)[1], url.QueryEscape(reg.FindStringSubmatch(recordUrl)[1]))
|
||||||
recordUrl = strings.Replace(recordUrl, "+", "%20", -1)
|
recordUrl = strings.ReplaceAll(recordUrl, "+", "%20")
|
||||||
// log.Println(recordUrl)
|
// log.Println(recordUrl)
|
||||||
}
|
}
|
||||||
ctx.SendChain(message.Reply(e.MessageID), message.Text("请欣赏《"+tc.ThirdCategoryName+"》"))
|
ctx.SendChain(message.Reply(e.MessageID), message.Text("请欣赏《"+tc.ThirdCategoryName+"》"))
|
||||||
@ -149,8 +149,8 @@ func init() {
|
|||||||
if reg.MatchString(recordUrl) {
|
if reg.MatchString(recordUrl) {
|
||||||
// log.Println(reg.FindStringSubmatch(recordUrl)[1])
|
// log.Println(reg.FindStringSubmatch(recordUrl)[1])
|
||||||
// log.Println(url.QueryEscape(reg.FindStringSubmatch(recordUrl)[1]))
|
// log.Println(url.QueryEscape(reg.FindStringSubmatch(recordUrl)[1]))
|
||||||
recordUrl = strings.Replace(recordUrl, reg.FindStringSubmatch(recordUrl)[1], url.QueryEscape(reg.FindStringSubmatch(recordUrl)[1]), -1)
|
recordUrl = strings.ReplaceAll(recordUrl, reg.FindStringSubmatch(recordUrl)[1], url.QueryEscape(reg.FindStringSubmatch(recordUrl)[1]))
|
||||||
recordUrl = strings.Replace(recordUrl, "+", "%20", -1)
|
recordUrl = strings.ReplaceAll(recordUrl, "+", "%20")
|
||||||
// log.Println(recordUrl)
|
// log.Println(recordUrl)
|
||||||
}
|
}
|
||||||
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text("请欣赏"+fc.FirstCategoryName+"的《"+tc.ThirdCategoryName+"》"))
|
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text("请欣赏"+fc.FirstCategoryName+"的《"+tc.ThirdCategoryName+"》"))
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
// Package wtf 鬼东西
|
||||||
package wtf
|
package wtf
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@ -27,7 +28,6 @@ func init() {
|
|||||||
s := ""
|
s := ""
|
||||||
for i, w := range table {
|
for i, w := range table {
|
||||||
s += fmt.Sprintf("%02d. %s\n", i, w.name)
|
s += fmt.Sprintf("%02d. %s\n", i, w.name)
|
||||||
i++
|
|
||||||
}
|
}
|
||||||
ctx.SendChain(message.Text(s))
|
ctx.SendChain(message.Text(s))
|
||||||
})
|
})
|
||||||
@ -43,7 +43,7 @@ func init() {
|
|||||||
ctx.SendChain(message.Text("ERROR: ", err))
|
ctx.SendChain(message.Text("ERROR: ", err))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
w := NewWtf(i)
|
w := newWtf(i)
|
||||||
if w == nil {
|
if w == nil {
|
||||||
ctx.SendChain(message.Text("没有这项内容!"))
|
ctx.SendChain(message.Text("没有这项内容!"))
|
||||||
return
|
return
|
||||||
@ -58,9 +58,9 @@ func init() {
|
|||||||
name = ctx.Event.Sender.NickName
|
name = ctx.Event.Sender.NickName
|
||||||
var text string
|
var text string
|
||||||
if secondname != "" {
|
if secondname != "" {
|
||||||
text, err = w.Predict(name, secondname)
|
text, err = w.predict(name, secondname)
|
||||||
} else {
|
} else {
|
||||||
text, err = w.Predict(name)
|
text, err = w.predict(name)
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.SendChain(message.Text("ERROR: ", err))
|
ctx.SendChain(message.Text("ERROR: ", err))
|
||||||
|
|||||||
@ -18,12 +18,12 @@ for(i=0; i<a.length; i++) {
|
|||||||
|
|
||||||
const apiprefix = "https://wtf.hiigara.net/api/run/"
|
const apiprefix = "https://wtf.hiigara.net/api/run/"
|
||||||
|
|
||||||
type Wtf struct {
|
type wtf struct {
|
||||||
name string
|
name string
|
||||||
path string
|
path string
|
||||||
}
|
}
|
||||||
|
|
||||||
var table = [...]*Wtf{
|
var table = [...]*wtf{
|
||||||
{"你的意义是什么?", "mRIFuS"},
|
{"你的意义是什么?", "mRIFuS"},
|
||||||
{"【ABO】性別和信息素", "KXyy9"},
|
{"【ABO】性別和信息素", "KXyy9"},
|
||||||
{"测测cp", "ZoGXQd"},
|
{"测测cp", "ZoGXQd"},
|
||||||
@ -114,7 +114,7 @@ var table = [...]*Wtf{
|
|||||||
{"你的蘿莉控程度全國排名", "IIWh9k"},
|
{"你的蘿莉控程度全國排名", "IIWh9k"},
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewWtf(index int) *Wtf {
|
func newWtf(index int) *wtf {
|
||||||
if index >= 0 && index < len(table) {
|
if index >= 0 && index < len(table) {
|
||||||
return table[index]
|
return table[index]
|
||||||
}
|
}
|
||||||
@ -128,7 +128,7 @@ type result struct {
|
|||||||
Msg string `json:"msg"`
|
Msg string `json:"msg"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *Wtf) Predict(names ...string) (string, error) {
|
func (w *wtf) predict(names ...string) (string, error) {
|
||||||
name := ""
|
name := ""
|
||||||
for _, n := range names {
|
for _, n := range names {
|
||||||
name += "/" + url.QueryEscape(n)
|
name += "/" + url.QueryEscape(n)
|
||||||
|
|||||||
@ -29,9 +29,9 @@ func DownloadTo(url, file string, chkcrt bool) error {
|
|||||||
f, err = os.Create(file)
|
f, err = os.Create(file)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
_, err = io.Copy(f, resp.Body)
|
_, err = io.Copy(f, resp.Body)
|
||||||
resp.Body.Close()
|
|
||||||
f.Close()
|
f.Close()
|
||||||
}
|
}
|
||||||
|
resp.Body.Close()
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@ -23,6 +23,7 @@ var (
|
|||||||
lzmu sync.Mutex
|
lzmu sync.Mutex
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// GetLazyData 获取懒加载数据
|
||||||
func GetLazyData(path string, isReturnDataBytes, isDataMustEqual bool) ([]byte, error) {
|
func GetLazyData(path string, isReturnDataBytes, isDataMustEqual bool) ([]byte, error) {
|
||||||
var data []byte
|
var data []byte
|
||||||
var resp *http.Response
|
var resp *http.Response
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user