Skip to content

Commit 4075c92

Browse files
authored
✨ 添加qq空间表白墙 (#489)
1 parent 743e550 commit 4075c92

File tree

9 files changed

+561
-4
lines changed

9 files changed

+561
-4
lines changed

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1068,6 +1068,22 @@ NeteaseCloudMusicApi项目地址:https://binaryify.github.io/NeteaseCloudMusicAp
10681068
- [x] 重置花名册
10691069

10701070

1071+
</details>
1072+
<details>
1073+
<summary>qq空间表白墙</summary>
1074+
1075+
`import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/qzone"`
1076+
1077+
- [x] 登录QQ空间 (Cookie过期很快, 要经常登录)
1078+
1079+
- [x] 发说说[xxx]
1080+
1081+
- [x] (匿名)发表白墙[xxx]
1082+
1083+
- [x] [ 同意 | 拒绝 ]表白墙 1,2,3 (最后一个参数是表白墙的序号数组, 用英文逗号连接)
1084+
1085+
- [x] 查看[ 等待 | 同意 | 拒绝 | 所有 ]表白墙 0 (最后一个参数是页码, 建议私聊审稿)
1086+
10711087
</details>
10721088
<details>
10731089
<summary>Real-CUGAN清晰术</summary>

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ go 1.19
55
require (
66
github.com/Baidu-AIP/golang-sdk v1.1.1
77
github.com/Coloured-glaze/gg v1.3.4
8-
github.com/FloatTech/AnimeAPI v1.5.2-0.20221110071402-5672d8466e21
8+
github.com/FloatTech/AnimeAPI v1.5.2-0.20221112090201-4a200d6330d5
99
github.com/FloatTech/floatbox v0.0.0-20221110070748-e0d0b3af3e57
1010
github.com/FloatTech/sqlite v0.5.1
1111
github.com/FloatTech/ttl v0.0.0-20220715042055-15612be72f5b

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym
44
github.com/Coloured-glaze/gg v1.3.4 h1:l31zIF/HaVwkzjrj+A56RGQoSKyKuR1IWtIrqXGFStI=
55
github.com/Coloured-glaze/gg v1.3.4/go.mod h1:Ih5NLNNDHOy3RJbB0EPqGTreIzq/H02TGThIagh8HJg=
66
github.com/DATA-DOG/go-sqlmock v1.3.3/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM=
7-
github.com/FloatTech/AnimeAPI v1.5.2-0.20221110071402-5672d8466e21 h1:Ao45y4vcH2n5Qx1DPyDPc2Wmt7Lol4/MwY1ZknBhGw4=
8-
github.com/FloatTech/AnimeAPI v1.5.2-0.20221110071402-5672d8466e21/go.mod h1:D3VwaTmT25UM+x/0AULJtJw4Mzyhob5YOa90J5QAX/w=
7+
github.com/FloatTech/AnimeAPI v1.5.2-0.20221112090201-4a200d6330d5 h1:1SpesC37urPid5ChljT7fnq+kyJLDrCuHva9usiJptU=
8+
github.com/FloatTech/AnimeAPI v1.5.2-0.20221112090201-4a200d6330d5/go.mod h1:D3VwaTmT25UM+x/0AULJtJw4Mzyhob5YOa90J5QAX/w=
99
github.com/FloatTech/floatbox v0.0.0-20221110070748-e0d0b3af3e57 h1:1H1QSxBPqq7o4S5/xtl0cI/GOqaiajoBg+156cuK1e4=
1010
github.com/FloatTech/floatbox v0.0.0-20221110070748-e0d0b3af3e57/go.mod h1:72tI2fKLhrNpuj4AlE2HSjJOAtEnUEKOx/+dEYSc4FE=
1111
github.com/FloatTech/sqlite v0.5.1 h1:IjTdnqMVIVIoIEFXhvh/KKBfYxFvG0tk7Rghz65/DAU=

main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ import (
114114
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/nsfw" // nsfw图片识别
115115
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/omikuji" // 浅草寺求签
116116
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/qqwife" // 一群一天一夫一妻制群老婆
117+
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/qzone" // qq空间表白墙
117118
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/realcugan" // realcugan清晰术
118119
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/reborn" // 投胎
119120
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/runcode" // 在线运行代码

plugin/aipaint/aipaint.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"encoding/json"
77
"fmt"
88
"net/url"
9+
"os"
910
"regexp"
1011
"strconv"
1112
"strings"
@@ -62,6 +63,17 @@ func init() { // 插件主体
6263
PrivateDataFolder: "aipaint",
6364
})
6465
datapath = file.BOTPATH + "/" + engine.DataFolder()
66+
if file.IsNotExist(cfg.file) {
67+
s := serverConfig{}
68+
data, err := json.Marshal(s)
69+
if err != nil {
70+
panic(err)
71+
}
72+
err = os.WriteFile(cfg.file, data, 0666)
73+
if err != nil {
74+
panic(err)
75+
}
76+
}
6577
engine.OnPrefixGroup([]string{`ai绘图`, `生成色图`, `生成涩图`, `ai画图`}).SetBlock(true).
6678
Handle(func(ctx *zero.Ctx) {
6779
err := cfg.load()

plugin/bilibili/bilibili.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ var (
4040
3: "Superchat",
4141
4: "进入直播间",
4242
5: "标题变动",
43+
6: "分区变动",
44+
7: "直播中止",
45+
8: "直播继续",
4346
}
4447
cfg = bz.NewCookieConfig("data/Bilibili/config.json")
4548
)
@@ -492,13 +495,19 @@ func init() {
492495
canvas.DrawString(t, moveW, danmuNow)
493496
canvas.SetColor(color.Black)
494497
moveW += l + dz
495-
case 4, 5:
498+
case 4, 5, 6, 7, 8:
496499
t = danmakuTypeMap[danItem.Type]
497500
canvas.SetRGB255(0, 128, 0)
498501
l, _ = canvas.MeasureString(t)
499502
canvas.DrawString(t, moveW, danmuNow)
500503
canvas.SetColor(color.Black)
501504
moveW += l + dz
505+
default:
506+
canvas.SetRGB255(0, 128, 0)
507+
l, _ = canvas.MeasureString("未知类型" + strconv.Itoa(int(danItem.Type)))
508+
canvas.DrawString(t, moveW, danmuNow)
509+
canvas.SetColor(color.Black)
510+
moveW += l + dz
502511
}
503512
if moveW > mcw {
504513
mcw = moveW

plugin/qzone/README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# qq空间表白墙
2+
3+
## 参考
4+
5+
* [opq-osc/OPQBot](https://github.com/opq-osc/OPQBot) QQ空间发表说说流程
6+
* [【Ono】QQ空间协议分析----扫码登录----【1】](https://www.52pojie.cn/thread-1022123-1-1.html) QQ空间扫码登录流程
7+
8+
## 优化点
9+
- [ ] 匿名头像背景颜色优化
10+
- [ ] 转发消息生成图片气泡背景板
11+
- [x] 查看说说消息分页 (优先)
12+
- [ ] 加zbp水印 (优先)
13+
- [ ] 发表白墙互动优化, 监听对话
14+
- [ ] 自动审核稿
15+
- [x] 一次同意多条说说并发送 (优先)
16+
- [ ] 拒绝说说的时候可发送拒绝消息
17+
- [ ] 表白墙接入钱包 (待定)
18+

plugin/qzone/model.go

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
package qzone
2+
3+
import (
4+
"fmt"
5+
"os"
6+
7+
_ "github.com/fumiama/sqlite3" // use sql
8+
"github.com/jinzhu/gorm"
9+
)
10+
11+
// qdb qq空间数据库全局变量
12+
var qdb *qzonedb
13+
14+
// qzonedb qq空间数据库结构体
15+
type qzonedb gorm.DB
16+
17+
// initialize 初始化
18+
func initialize(dbpath string) *qzonedb {
19+
var err error
20+
if _, err = os.Stat(dbpath); err != nil || os.IsNotExist(err) {
21+
// 生成文件
22+
f, err := os.Create(dbpath)
23+
if err != nil {
24+
return nil
25+
}
26+
defer f.Close()
27+
}
28+
qdb, err := gorm.Open("sqlite3", dbpath)
29+
if err != nil {
30+
panic(err)
31+
}
32+
qdb.AutoMigrate(&qzoneConfig{}).AutoMigrate(&emotion{})
33+
return (*qzonedb)(qdb)
34+
}
35+
36+
// qzoneConfig qq空间初始化信息
37+
type qzoneConfig struct {
38+
ID uint `gorm:"primary_key;AUTO_INCREMENT"`
39+
QQ int64 `gorm:"column:qq;unique;not null"`
40+
Cookie string `gorm:"column:cookie;type:varchar(1024)"`
41+
}
42+
43+
// TableName 表名
44+
func (qzoneConfig) TableName() string {
45+
return "qzone_config"
46+
}
47+
48+
func (qdb *qzonedb) insertOrUpdate(qq int64, cookie string) (err error) {
49+
db := (*gorm.DB)(qdb)
50+
qc := qzoneConfig{
51+
QQ: qq,
52+
Cookie: cookie,
53+
}
54+
var oqc qzoneConfig
55+
err = db.Take(&oqc, "qq = ?", qc.QQ).Error
56+
if err != nil {
57+
if gorm.IsRecordNotFoundError(err) {
58+
err = db.Create(&qc).Error
59+
}
60+
return
61+
}
62+
err = db.Model(&oqc).Updates(qc).Error
63+
return
64+
}
65+
66+
func (qdb *qzonedb) getByUin(qq int64) (qc qzoneConfig, err error) {
67+
db := (*gorm.DB)(qdb)
68+
err = db.Take(&qc, "qq = ?", qq).Error
69+
return
70+
}
71+
72+
// emotion 说说信息
73+
type emotion struct {
74+
gorm.Model
75+
Anonymous bool `gorm:"column:anonymous"`
76+
QQ int64 `gorm:"column:qq"`
77+
Msg string `gorm:"column:msg"`
78+
Status int `gorm:"column:status"` // 1-审核中,2-同意,3-拒绝
79+
Tag string `gorm:"column:tag"`
80+
}
81+
82+
func (e emotion) textBrief() (t string) {
83+
t = fmt.Sprintf("序号: %v\nQQ: %v\n创建时间: %v\n", e.ID, e.QQ, e.CreatedAt.Format("2006-01-02 15:04:05"))
84+
switch e.Status {
85+
case 1:
86+
t += "状态: 审核中\n"
87+
case 2:
88+
t += "状态: 同意\n"
89+
case 3:
90+
t += "状态: 拒绝\n"
91+
}
92+
if e.Anonymous {
93+
t += "匿名: 是"
94+
} else {
95+
t += "匿名: 否"
96+
}
97+
return
98+
}
99+
100+
// TableName 表名
101+
func (emotion) TableName() string {
102+
return "emotion"
103+
}
104+
105+
func (qdb *qzonedb) saveEmotion(e emotion) (id int64, err error) {
106+
db := (*gorm.DB)(qdb)
107+
err = db.Create(&e).Error
108+
id = int64(e.ID)
109+
return
110+
}
111+
112+
func (qdb *qzonedb) getEmotionByIDList(idList []int64) (el []emotion, err error) {
113+
db := (*gorm.DB)(qdb)
114+
err = db.Find(&el, "id in (?)", idList).Error
115+
return
116+
}
117+
118+
func (qdb *qzonedb) getLoveEmotionByStatus(status int, pageNum int) (el []emotion, err error) {
119+
db := (*gorm.DB)(qdb)
120+
if status == 0 {
121+
err = db.Order("created_at desc").Limit(5).Offset(pageNum*5).Find(&el, "tag like ?", "%"+loveTag+"%").Error
122+
return
123+
}
124+
err = db.Order("created_at desc").Limit(5).Offset(pageNum*5).Find(&el, "status = ? and tag like ?", status, "%"+loveTag+"%").Error
125+
return
126+
}
127+
128+
func (qdb *qzonedb) updateEmotionStatusByIDList(idList []int64, status int) (err error) {
129+
db := (*gorm.DB)(qdb)
130+
err = db.Model(&emotion{}).Where("id in (?)", idList).Update("status", status).Error
131+
return
132+
}

0 commit comments

Comments
 (0)