mirror of
https://github.com/FloatTech/ZeroBot-Plugin.git
synced 2025-12-19 13:59:39 +08:00
feat:增加煎蛋网无聊图 (#115)
* feat:添加煎蛋网无聊图 * fix:修lint * fix:修改model和名称 * fix:删除不要的驱动 * fix:修改日志错误的地方 * fix:修改权限 * fix:去掉数据库 Co-authored-by: Guohuiyuan <haibaraguo@yeahka.com>
This commit is contained in:
parent
8f6b3fa00d
commit
45edd86cb8
@ -227,6 +227,7 @@ zerobot [-h] [-t token] [-u url] [-n nickname] [-p prefix] [-d|w] [-g 监听地
|
|||||||
- **vtb语录** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_vtb_quotation"`
|
- **vtb语录** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_vtb_quotation"`
|
||||||
- [x] vtb语录
|
- [x] vtb语录
|
||||||
- [x] 随机vtb
|
- [x] 随机vtb
|
||||||
|
- [x] 更新vtb
|
||||||
- **书评** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_book_review"`
|
- **书评** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_book_review"`
|
||||||
- [x] 书评[xxx]
|
- [x] 书评[xxx]
|
||||||
- [x] 随机书评
|
- [x] 随机书评
|
||||||
@ -252,7 +253,7 @@ zerobot [-h] [-t token] [-u url] [-n nickname] [-p prefix] [-d|w] [-g 监听地
|
|||||||
- [x] 藏尾诗[xxx]
|
- [x] 藏尾诗[xxx]
|
||||||
- **cp短打** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_cpstory"`
|
- **cp短打** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_cpstory"`
|
||||||
- [x] 组cp[@xxx][@xxx]
|
- [x] 组cp[@xxx][@xxx]
|
||||||
- [x] 组cp大老师 雪乃
|
- [x] 磕cp大老师 雪乃
|
||||||
- **签到得分** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_score"`
|
- **签到得分** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_score"`
|
||||||
- [x] 签到
|
- [x] 签到
|
||||||
- [x] 获得签到背景[@xxx] | 获得签到背景
|
- [x] 获得签到背景[@xxx] | 获得签到背景
|
||||||
@ -269,6 +270,9 @@ zerobot [-h] [-t token] [-u url] [-n nickname] [-p prefix] [-d|w] [-g 监听地
|
|||||||
- [x] 来份网易云热评
|
- [x] 来份网易云热评
|
||||||
- **b站视频链接解析** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_bilibili_parse"`
|
- **b站视频链接解析** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_bilibili_parse"`
|
||||||
- [x] https://www.bilibili.com/video/BV1xx411c7BF | https://www.bilibili.com/video/av1605 | https://b23.tv/I8uzWCA
|
- [x] https://www.bilibili.com/video/BV1xx411c7BF | https://www.bilibili.com/video/av1605 | https://b23.tv/I8uzWCA
|
||||||
|
- **煎蛋网无聊图** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_jandan"`
|
||||||
|
- [x] 来份屌图
|
||||||
|
- [x] 更新屌图
|
||||||
- **TODO...**
|
- **TODO...**
|
||||||
|
|
||||||
## 使用方法
|
## 使用方法
|
||||||
|
|||||||
1
main.go
1
main.go
@ -39,6 +39,7 @@ import (
|
|||||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_funny" // 笑话
|
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_funny" // 笑话
|
||||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_gif" // 制图
|
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_gif" // 制图
|
||||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_hs" // 炉石
|
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_hs" // 炉石
|
||||||
|
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_jandan" // 煎蛋网无聊图
|
||||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_juejuezi" // 绝绝子生成器
|
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_juejuezi" // 绝绝子生成器
|
||||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_minecraft" // MCSManager
|
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_minecraft" // MCSManager
|
||||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_moyu" // 摸鱼
|
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_moyu" // 摸鱼
|
||||||
|
|||||||
@ -29,6 +29,7 @@ const (
|
|||||||
PrioGithub
|
PrioGithub
|
||||||
PrioHS
|
PrioHS
|
||||||
PrioImageFinder
|
PrioImageFinder
|
||||||
|
PrioJandan
|
||||||
PrioJueJueZi
|
PrioJueJueZi
|
||||||
PrioLolicon
|
PrioLolicon
|
||||||
PrioMinecraft
|
PrioMinecraft
|
||||||
|
|||||||
@ -7,7 +7,7 @@ import (
|
|||||||
"github.com/wdvxdr1123/ZeroBot/message"
|
"github.com/wdvxdr1123/ZeroBot/message"
|
||||||
"github.com/wdvxdr1123/ZeroBot/utils/helper"
|
"github.com/wdvxdr1123/ZeroBot/utils/helper"
|
||||||
|
|
||||||
control "github.com/FloatTech/zbputils/control"
|
"github.com/FloatTech/zbputils/control"
|
||||||
"github.com/FloatTech/zbputils/txt2img"
|
"github.com/FloatTech/zbputils/txt2img"
|
||||||
|
|
||||||
"github.com/FloatTech/ZeroBot-Plugin/order"
|
"github.com/FloatTech/ZeroBot-Plugin/order"
|
||||||
|
|||||||
@ -17,7 +17,7 @@ import (
|
|||||||
func init() {
|
func init() {
|
||||||
engine := control.Register("cpstory", order.PrioCPStory, &control.Options{
|
engine := control.Register("cpstory", order.PrioCPStory, &control.Options{
|
||||||
DisableOnDefault: false,
|
DisableOnDefault: false,
|
||||||
Help: "cp短打\n- 组cp[@xxx][@xxx]\n- 组cp大老师 雪乃",
|
Help: "cp短打\n- 组cp[@xxx][@xxx]\n- 磕cp大老师 雪乃",
|
||||||
})
|
})
|
||||||
engine.OnRegex("^组cp.*?(\\d+).*?(\\d+)", zero.OnlyGroup).SetBlock(true).Handle(func(ctx *zero.Ctx) {
|
engine.OnRegex("^组cp.*?(\\d+).*?(\\d+)", zero.OnlyGroup).SetBlock(true).Handle(func(ctx *zero.Ctx) {
|
||||||
cs := getRandomCpStory()
|
cs := getRandomCpStory()
|
||||||
@ -29,7 +29,7 @@ func init() {
|
|||||||
text = strings.ReplaceAll(text, cs.Shou, gong)
|
text = strings.ReplaceAll(text, cs.Shou, gong)
|
||||||
ctx.SendChain(message.Text(text))
|
ctx.SendChain(message.Text(text))
|
||||||
})
|
})
|
||||||
engine.OnPrefix("组cp").SetBlock(true).Handle(func(ctx *zero.Ctx) {
|
engine.OnPrefix("磕cp").SetBlock(true).Handle(func(ctx *zero.Ctx) {
|
||||||
cs := getRandomCpStory()
|
cs := getRandomCpStory()
|
||||||
params := strings.Split(ctx.State["args"].(string), " ")
|
params := strings.Split(ctx.State["args"].(string), " ")
|
||||||
if len(params) < 2 {
|
if len(params) < 2 {
|
||||||
|
|||||||
74
plugin_jandan/cron.go
Normal file
74
plugin_jandan/cron.go
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
package jandan
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/FloatTech/zbputils/process"
|
||||||
|
"github.com/antchfx/htmlquery"
|
||||||
|
"github.com/fumiama/cron"
|
||||||
|
log "github.com/sirupsen/logrus"
|
||||||
|
"regexp"
|
||||||
|
"strconv"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
chanPicture = make(chan string, 100000)
|
||||||
|
pageTotal int
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
go func() {
|
||||||
|
process.SleepAbout1sTo2s()
|
||||||
|
scorePicture()
|
||||||
|
log.Println("[jandan/cron] 开启jandan数据库日常更新")
|
||||||
|
jandanDaily()
|
||||||
|
}()
|
||||||
|
travelWebpage()
|
||||||
|
}
|
||||||
|
|
||||||
|
func jandanDaily() {
|
||||||
|
c := cron.New()
|
||||||
|
_, err := c.AddFunc("10 4 * * *", func() { travelWebpage() })
|
||||||
|
if err != nil {
|
||||||
|
log.Errorln("定时任务有错误:", err)
|
||||||
|
} else {
|
||||||
|
log.Println("开启jandan数据库定时任务")
|
||||||
|
c.Start()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func travelWebpage() {
|
||||||
|
pictureList = pictureList[0:0]
|
||||||
|
webpageURL := jandanPictureURL
|
||||||
|
doc, err := htmlquery.LoadURL(webpageURL)
|
||||||
|
if err != nil {
|
||||||
|
log.Errorln("[jandan]:", err)
|
||||||
|
}
|
||||||
|
re := regexp.MustCompile(`\d+`)
|
||||||
|
pageTotal, err = strconv.Atoi(re.FindString(htmlquery.FindOne(doc, "//*[@id='comments']/div[2]/div/span[@class='current-comment-page']/text()").Data))
|
||||||
|
if err != nil {
|
||||||
|
log.Errorln("[jandan]:", err)
|
||||||
|
}
|
||||||
|
for i := 0; i < pageTotal; i++ {
|
||||||
|
doc, err = htmlquery.LoadURL(webpageURL)
|
||||||
|
if err != nil {
|
||||||
|
log.Errorln("[jandan]:", err)
|
||||||
|
}
|
||||||
|
picList, err := htmlquery.QueryAll(doc, "//*[@class='view_img_link']")
|
||||||
|
if err != nil {
|
||||||
|
log.Errorln("[jandan]:", err)
|
||||||
|
}
|
||||||
|
if len(picList) != 0 {
|
||||||
|
for _, v := range picList {
|
||||||
|
chanPicture <- "https:" + v.Attr[0].Val
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if i != pageTotal-1 {
|
||||||
|
webpageURL = "https:" + htmlquery.FindOne(doc, "//*[@id='comments']/div[@class='comments']/div[@class='cp-pagenavi']/a[@class='previous-comment-page']").Attr[1].Val
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func scorePicture() {
|
||||||
|
for pictureURL := range chanPicture {
|
||||||
|
pictureList = append(pictureList, pictureURL)
|
||||||
|
}
|
||||||
|
}
|
||||||
39
plugin_jandan/jandan.go
Normal file
39
plugin_jandan/jandan.go
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
// Package jandan 煎蛋网无聊图
|
||||||
|
package jandan
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/FloatTech/ZeroBot-Plugin/order"
|
||||||
|
"github.com/FloatTech/zbputils/control"
|
||||||
|
"github.com/wdvxdr1123/ZeroBot/message"
|
||||||
|
"math/rand"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
zero "github.com/wdvxdr1123/ZeroBot"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
jandanPictureURL = "http://jandan.net/pic"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
pictureList []string
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
engine := control.Register("jandan", order.PrioJandan, &control.Options{
|
||||||
|
DisableOnDefault: false,
|
||||||
|
Help: "煎蛋网无聊图\n- 来份屌图\n- 更新屌图\n",
|
||||||
|
})
|
||||||
|
|
||||||
|
engine.OnFullMatch("来份屌图").SetBlock(true).
|
||||||
|
Handle(func(ctx *zero.Ctx) {
|
||||||
|
rand.Seed(time.Now().Unix())
|
||||||
|
ctx.SendChain(message.Image(pictureList[rand.Intn(len(pictureList))]))
|
||||||
|
})
|
||||||
|
|
||||||
|
engine.OnFullMatch("更新屌图", zero.SuperUserPermission).SetBlock(true).
|
||||||
|
Handle(func(ctx *zero.Ctx) {
|
||||||
|
ctx.Send("少女更新中......")
|
||||||
|
travelWebpage()
|
||||||
|
})
|
||||||
|
}
|
||||||
@ -29,7 +29,7 @@ const (
|
|||||||
|
|
||||||
var engine = control.Register("vtbquotation", order.PrioVtbQuotation, &control.Options{
|
var engine = control.Register("vtbquotation", order.PrioVtbQuotation, &control.Options{
|
||||||
DisableOnDefault: false,
|
DisableOnDefault: false,
|
||||||
Help: "vtbkeyboard.moe\n- vtb语录\n- 随机vtb",
|
Help: "vtbkeyboard.moe\n- vtb语录\n- 随机vtb\n- 更新vtb\n",
|
||||||
})
|
})
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
@ -195,4 +195,10 @@ func init() {
|
|||||||
}
|
}
|
||||||
db.Close()
|
db.Close()
|
||||||
})
|
})
|
||||||
|
engine.OnFullMatch("更新vtb", zero.SuperUserPermission).SetBlock(true).
|
||||||
|
Handle(func(ctx *zero.Ctx) {
|
||||||
|
ctx.Send("少女祈祷中......")
|
||||||
|
vtbData()
|
||||||
|
ctx.Send("vtb数据库已更新")
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user