mirror of
https://github.com/FloatTech/ZeroBot-Plugin.git
synced 2026-02-06 15:20:22 +00:00
Compare commits
47 Commits
v1.6.2-bet
...
v1.7.0-bet
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c55e31ed6f | ||
|
|
f3a0813fed | ||
|
|
c1602c323d | ||
|
|
1bceaa52ff | ||
|
|
86296a28df | ||
|
|
fe9b5023f6 | ||
|
|
d68223f63d | ||
|
|
1c274d6eb8 | ||
|
|
0e52bbe0f7 | ||
|
|
a177448315 | ||
|
|
ca3ff1b522 | ||
|
|
41f0b11469 | ||
|
|
ba0e471a19 | ||
|
|
84115a7316 | ||
|
|
4dc837854b | ||
|
|
64f9e309ef | ||
|
|
67a1050df6 | ||
|
|
d85865825e | ||
|
|
2704d3e7d4 | ||
|
|
0944fc7854 | ||
|
|
611c275092 | ||
|
|
e3e991e6ab | ||
|
|
f2cebcf95a | ||
|
|
4aca16a393 | ||
|
|
891bbb96aa | ||
|
|
d60acd3a47 | ||
|
|
7dc6499127 | ||
|
|
f28e746652 | ||
|
|
3c905d9061 | ||
|
|
091d3170fc | ||
|
|
bdc4138d78 | ||
|
|
e231235ed1 | ||
|
|
1795b9196b | ||
|
|
d5d0563544 | ||
|
|
723b7a9857 | ||
|
|
6a0a16662e | ||
|
|
f82ba852ba | ||
|
|
180945670b | ||
|
|
56984ef7fb | ||
|
|
ac4de84188 | ||
|
|
591ad79201 | ||
|
|
2e51c9e9c3 | ||
|
|
ca89f01f7d | ||
|
|
5dfc118f64 | ||
|
|
2410a7b3ed | ||
|
|
7e11924b3f | ||
|
|
4f65900688 |
2
.github/workflows/nightly.yml
vendored
2
.github/workflows/nightly.yml
vendored
@@ -28,7 +28,7 @@ jobs:
|
||||
- name: Setup Go environment
|
||||
uses: actions/setup-go@master
|
||||
with:
|
||||
go-version: 1.19
|
||||
go-version: '1.20'
|
||||
- name: Cache downloaded module
|
||||
uses: actions/cache@master
|
||||
with:
|
||||
|
||||
2
.github/workflows/pull.yml
vendored
2
.github/workflows/pull.yml
vendored
@@ -8,7 +8,7 @@ jobs:
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@master
|
||||
with:
|
||||
go-version: 1.19
|
||||
go-version: '1.20'
|
||||
|
||||
- name: Check out code into the Go module directory
|
||||
uses: actions/checkout@master
|
||||
|
||||
2
.github/workflows/push.yml
vendored
2
.github/workflows/push.yml
vendored
@@ -8,7 +8,7 @@ jobs:
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@master
|
||||
with:
|
||||
go-version: 1.19
|
||||
go-version: '1.20'
|
||||
|
||||
- name: Check out code into the Go module directory
|
||||
uses: actions/checkout@master
|
||||
|
||||
2
.github/workflows/release.yml
vendored
2
.github/workflows/release.yml
vendored
@@ -16,7 +16,7 @@ jobs:
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@master
|
||||
with:
|
||||
go-version: '1.19'
|
||||
go-version: '1.20'
|
||||
|
||||
- name: Run GoReleaser
|
||||
uses: goreleaser/goreleaser-action@master
|
||||
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -7,3 +7,4 @@ go-zero*
|
||||
nohup.out
|
||||
zerobot
|
||||
ZeroBot-Plugin*
|
||||
*.syso
|
||||
|
||||
@@ -59,7 +59,7 @@ run:
|
||||
tests: false
|
||||
skip-dirs:
|
||||
- order
|
||||
go: '1.19'
|
||||
go: '1.20'
|
||||
|
||||
# output configuration options
|
||||
output:
|
||||
|
||||
@@ -4,6 +4,8 @@ env:
|
||||
before:
|
||||
hooks:
|
||||
- go mod tidy
|
||||
- go install github.com/tc-hib/go-winres@latest
|
||||
- go-winres make
|
||||
builds:
|
||||
- id: nowin
|
||||
env:
|
||||
|
||||
44
README.md
44
README.md
@@ -18,7 +18,7 @@
|
||||
|
||||
[](https://goreportcard.com/badge/github.com/FloatTech/ZeroBot-Plugin)
|
||||
[](https://t.me/zerobotplugin)
|
||||
[](https://github.com/wdvxdr1123/ZeroBot)
|
||||
[](https://github.com/wdvxdr1123/ZeroBot)
|
||||
[](https://raw.githubusercontent.com/FloatTech/ZeroBot-Plugin/master/LICENSE)
|
||||
[](https://jq.qq.com/?_wv=1027&k=QMb7x1mM)
|
||||
[](https://t.me/zerobotplugin)
|
||||
@@ -620,6 +620,14 @@ print("run[CQ:image,file="+j["img"]+"]")
|
||||
|
||||
- [x] 磕cp大老师 雪乃
|
||||
|
||||
</details>
|
||||
<details>
|
||||
<summary>今日早报</summary>
|
||||
|
||||
`import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/dailynews"`
|
||||
|
||||
- [x] 今日早报
|
||||
|
||||
</details>
|
||||
<details>
|
||||
<summary>DeepDanbooru二次元图标签识别</summary>
|
||||
@@ -872,6 +880,26 @@ print("run[CQ:image,file="+j["img"]+"]")
|
||||
|
||||
- [x] 喝奶茶绝绝子 | 绝绝子吃饭
|
||||
|
||||
</details>
|
||||
<details>
|
||||
<summary>疯狂星期四</summary>
|
||||
|
||||
`import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/kfccrazythursday"`
|
||||
|
||||
- [x] 疯狂星期四
|
||||
|
||||
</details>
|
||||
<details>
|
||||
<summary>kokomi原神面板</summary>
|
||||
|
||||
`import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/kokomi"`
|
||||
|
||||
- [x] kokomi菜单
|
||||
|
||||
- [x] XX面板
|
||||
|
||||
- 注:本插件未并入主仓库,需自行安装(须源码方式运行才能添加插件),安装地址[kokomi-原神面板查询插件](https://github.com/lianhong2758/kokomi-plugin)
|
||||
|
||||
</details>
|
||||
<details>
|
||||
<summary>lolicon</summary>
|
||||
@@ -1271,6 +1299,16 @@ print("run[CQ:image,file="+j["img"]+"]")
|
||||
|
||||
- [x] 更新vtb
|
||||
|
||||
</details>
|
||||
<details>
|
||||
<summary>vtb语录</summary>
|
||||
|
||||
`import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/vtbmusic"`
|
||||
|
||||
- [x] vtb点歌
|
||||
|
||||
- [x] vtb随机点歌
|
||||
|
||||
</details>
|
||||
<details>
|
||||
<summary>钱包</summary>
|
||||
@@ -1469,7 +1507,9 @@ print("run[CQ:image,file="+j["img"]+"]")
|
||||
|
||||
- [x] @Bot 任意文本(任意一句话回复)
|
||||
|
||||
- [x] 设置回复模式[青云客 | 小爱]
|
||||
- [x] 设置回复模式[青云客 | 小爱 | ChatGPT]
|
||||
|
||||
- [x] 设置 ChatGPT api key xxx
|
||||
|
||||
</details>
|
||||
|
||||
|
||||
12
console/console.go
Normal file
12
console/console.go
Normal file
@@ -0,0 +1,12 @@
|
||||
// Package console sets console's behavior on init
|
||||
package console
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/FloatTech/ZeroBot-Plugin/kanban/banner"
|
||||
)
|
||||
|
||||
func init() {
|
||||
fmt.Print("\033]0;ZeroBot-Blugin " + banner.Version + " " + banner.Copyright + "\007")
|
||||
}
|
||||
137
console/console_windows.go
Normal file
137
console/console_windows.go
Normal file
@@ -0,0 +1,137 @@
|
||||
package console
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"os"
|
||||
"strings"
|
||||
"syscall"
|
||||
"unsafe"
|
||||
|
||||
"golang.org/x/sys/windows"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
|
||||
"github.com/FloatTech/ZeroBot-Plugin/kanban/banner"
|
||||
)
|
||||
|
||||
var (
|
||||
//go:linkname modkernel32 golang.org/x/sys/windows.modkernel32
|
||||
modkernel32 *windows.LazyDLL
|
||||
procSetConsoleTitle = modkernel32.NewProc("SetConsoleTitleW")
|
||||
)
|
||||
|
||||
//go:linkname errnoErr golang.org/x/sys/windows.errnoErr
|
||||
func errnoErr(e syscall.Errno) error
|
||||
|
||||
func setConsoleTitle(title string) (err error) {
|
||||
var p0 *uint16
|
||||
p0, err = syscall.UTF16PtrFromString(title)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
r1, _, e1 := syscall.Syscall(procSetConsoleTitle.Addr(), 1, uintptr(unsafe.Pointer(p0)), 0, 0)
|
||||
if r1 == 0 {
|
||||
err = errnoErr(e1)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func init() {
|
||||
stdin := windows.Handle(os.Stdin.Fd())
|
||||
|
||||
var mode uint32
|
||||
err := windows.GetConsoleMode(stdin, &mode)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
mode &^= windows.ENABLE_QUICK_EDIT_MODE // 禁用快速编辑模式
|
||||
mode |= windows.ENABLE_EXTENDED_FLAGS // 启用扩展标志
|
||||
|
||||
mode &^= windows.ENABLE_MOUSE_INPUT // 禁用鼠标输入
|
||||
mode |= windows.ENABLE_PROCESSED_INPUT // 启用控制输入
|
||||
|
||||
mode &^= windows.ENABLE_INSERT_MODE // 禁用插入模式
|
||||
mode |= windows.ENABLE_ECHO_INPUT | windows.ENABLE_LINE_INPUT // 启用输入回显&逐行输入
|
||||
|
||||
mode &^= windows.ENABLE_WINDOW_INPUT // 禁用窗口输入
|
||||
mode &^= windows.ENABLE_VIRTUAL_TERMINAL_INPUT // 禁用虚拟终端输入
|
||||
|
||||
err = windows.SetConsoleMode(stdin, mode)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
stdout := windows.Handle(os.Stdout.Fd())
|
||||
err = windows.GetConsoleMode(stdout, &mode)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
mode |= windows.ENABLE_VIRTUAL_TERMINAL_PROCESSING // 启用虚拟终端处理
|
||||
mode |= windows.ENABLE_PROCESSED_OUTPUT // 启用处理后的输出
|
||||
|
||||
err = windows.SetConsoleMode(stdout, mode)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
// windows 带颜色 log 自定义格式
|
||||
logrus.SetFormatter(&LogFormat{})
|
||||
|
||||
err = setConsoleTitle("ZeroBot-Blugin " + banner.Version + " " + banner.Copyright)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
const (
|
||||
colorCodePanic = "\x1b[1;31m" // color.Style{color.Bold, color.Red}.String()
|
||||
colorCodeFatal = "\x1b[1;31m" // color.Style{color.Bold, color.Red}.String()
|
||||
colorCodeError = "\x1b[31m" // color.Style{color.Red}.String()
|
||||
colorCodeWarn = "\x1b[33m" // color.Style{color.Yellow}.String()
|
||||
colorCodeInfo = "\x1b[37m" // color.Style{color.White}.String()
|
||||
colorCodeDebug = "\x1b[32m" // color.Style{color.Green}.String()
|
||||
colorCodeTrace = "\x1b[36m" // color.Style{color.Cyan}.String()
|
||||
colorReset = "\x1b[0m"
|
||||
)
|
||||
|
||||
// LogFormat specialize for zbp
|
||||
type LogFormat struct{}
|
||||
|
||||
// Format implements logrus.Formatter
|
||||
func (f LogFormat) Format(entry *logrus.Entry) ([]byte, error) {
|
||||
buf := new(bytes.Buffer)
|
||||
|
||||
buf.WriteByte('[')
|
||||
buf.WriteString(getLogLevelColorCode(entry.Level))
|
||||
buf.WriteString(strings.ToUpper(entry.Level.String()))
|
||||
buf.WriteString(colorReset)
|
||||
buf.WriteString("] ")
|
||||
buf.WriteString(entry.Message)
|
||||
buf.WriteString(" \n")
|
||||
|
||||
return buf.Bytes(), nil
|
||||
}
|
||||
|
||||
// getLogLevelColorCode 获取日志等级对应色彩code
|
||||
func getLogLevelColorCode(level logrus.Level) string {
|
||||
switch level {
|
||||
case logrus.PanicLevel:
|
||||
return colorCodePanic
|
||||
case logrus.FatalLevel:
|
||||
return colorCodeFatal
|
||||
case logrus.ErrorLevel:
|
||||
return colorCodeError
|
||||
case logrus.WarnLevel:
|
||||
return colorCodeWarn
|
||||
case logrus.InfoLevel:
|
||||
return colorCodeInfo
|
||||
case logrus.DebugLevel:
|
||||
return colorCodeDebug
|
||||
case logrus.TraceLevel:
|
||||
return colorCodeTrace
|
||||
|
||||
default:
|
||||
return colorCodeInfo
|
||||
}
|
||||
}
|
||||
2
data
2
data
Submodule data updated: 5e0fa81c3b...b9848c9a4e
21
go.mod
21
go.mod
@@ -1,17 +1,18 @@
|
||||
module github.com/FloatTech/ZeroBot-Plugin
|
||||
|
||||
go 1.19
|
||||
go 1.20
|
||||
|
||||
require (
|
||||
github.com/Baidu-AIP/golang-sdk v1.1.1
|
||||
github.com/FloatTech/AnimeAPI v1.6.1-0.20230130095520-be357484e5a7
|
||||
github.com/FloatTech/floatbox v0.0.0-20230205065512-4039f6dd0a68
|
||||
github.com/FloatTech/gg v1.1.0
|
||||
github.com/FloatTech/rendercard v0.0.9-0.20230206125820-929cee91387c
|
||||
github.com/FloatTech/AnimeAPI v1.6.1-0.20230301080805-a8aa0e4cee1f
|
||||
github.com/FloatTech/floatbox v0.0.0-20230301074105-03017a267762
|
||||
github.com/FloatTech/gg v1.1.2
|
||||
github.com/FloatTech/imgfactory v0.2.2-0.20230215052637-9f7b05520ca9
|
||||
github.com/FloatTech/rendercard v0.0.10-0.20230223064326-45d29fa4ede9
|
||||
github.com/FloatTech/sqlite v1.5.7
|
||||
github.com/FloatTech/ttl v0.0.0-20220715042055-15612be72f5b
|
||||
github.com/FloatTech/zbpctrl v1.5.3-0.20230130095145-714ad318cd52
|
||||
github.com/FloatTech/zbputils v1.6.2-0.20230206130001-6b404926bf66
|
||||
github.com/FloatTech/zbpctrl v1.5.3-0.20230301071613-f2c5c97cec88
|
||||
github.com/FloatTech/zbputils v1.6.2-0.20230301080528-6560d8a50f34
|
||||
github.com/RomiChan/syncx v0.0.0-20221202055724-5f842c53020e
|
||||
github.com/RomiChan/websocket v1.4.3-0.20220227141055-9b2c6168c9c5
|
||||
github.com/antchfx/htmlquery v1.2.5
|
||||
@@ -21,7 +22,7 @@ require (
|
||||
github.com/fumiama/ahsai v0.1.0
|
||||
github.com/fumiama/cron v1.3.0
|
||||
github.com/fumiama/go-base16384 v1.6.4
|
||||
github.com/fumiama/go-registry v0.2.5
|
||||
github.com/fumiama/go-registry v0.2.6
|
||||
github.com/fumiama/gotracemoe v0.0.3
|
||||
github.com/fumiama/jieba v0.0.0-20221203025406-36c17a10b565
|
||||
github.com/fumiama/unibase2n v0.0.0-20221020155353-02876e777430
|
||||
@@ -36,9 +37,10 @@ require (
|
||||
github.com/sirupsen/logrus v1.9.0
|
||||
github.com/tidwall/gjson v1.14.4
|
||||
github.com/wcharczuk/go-chart/v2 v2.1.0
|
||||
github.com/wdvxdr1123/ZeroBot v1.6.8
|
||||
github.com/wdvxdr1123/ZeroBot v1.6.10
|
||||
gitlab.com/gomidi/midi/v2 v2.0.25
|
||||
golang.org/x/image v0.3.0
|
||||
golang.org/x/sys v0.4.0
|
||||
golang.org/x/text v0.6.0
|
||||
gopkg.in/yaml.v3 v3.0.1
|
||||
)
|
||||
@@ -84,7 +86,6 @@ require (
|
||||
golang.org/x/mobile v0.0.0-20201217150744-e6ae53a27f4f // indirect
|
||||
golang.org/x/mod v0.6.0 // indirect
|
||||
golang.org/x/net v0.4.0 // indirect
|
||||
golang.org/x/sys v0.4.0 // indirect
|
||||
golang.org/x/tools v0.2.0 // indirect
|
||||
modernc.org/libc v1.21.5 // indirect
|
||||
modernc.org/mathutil v1.5.0 // indirect
|
||||
|
||||
34
go.sum
34
go.sum
@@ -2,22 +2,24 @@ github.com/Baidu-AIP/golang-sdk v1.1.1 h1:RQsAmgDSAkiq22I6n7XJ2t3afgzFeqjY46FGhv
|
||||
github.com/Baidu-AIP/golang-sdk v1.1.1/go.mod h1:bXnGw7xPeKt8aF7UCELKrV6UZ/46spItONK1RQBQj1Y=
|
||||
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
|
||||
github.com/DATA-DOG/go-sqlmock v1.3.3/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM=
|
||||
github.com/FloatTech/AnimeAPI v1.6.1-0.20230130095520-be357484e5a7 h1:4FCjcjcsjUSJzmuUi8u570SUnmYasZ98ugSRg2SIl18=
|
||||
github.com/FloatTech/AnimeAPI v1.6.1-0.20230130095520-be357484e5a7/go.mod h1:LmHu358Oovtxhc/7xz+IfffUAMCX2bijpEvWatacEYQ=
|
||||
github.com/FloatTech/floatbox v0.0.0-20230205065512-4039f6dd0a68 h1:K03MRdjGBtoZ7QOnyeKf8dmxsRoNF7dN0udNrR5t138=
|
||||
github.com/FloatTech/floatbox v0.0.0-20230205065512-4039f6dd0a68/go.mod h1:OoZE4Ra7olpFaJSrlD6mcyT4chPLg9QBRE1pzTC8R84=
|
||||
github.com/FloatTech/gg v1.1.0 h1:4qmsleYqRZ/gv48izGgkyJgvP1RmybA5xJJnzkhK/OU=
|
||||
github.com/FloatTech/gg v1.1.0/go.mod h1:uzPzAeT35egARdRuu+1oyjU3CmTwCceoq3Vvje7LpcI=
|
||||
github.com/FloatTech/rendercard v0.0.9-0.20230206125820-929cee91387c h1:nE1X4Z3BAyYydlo0QKVU/nUtEyF5ek/cN6S5sZsyio4=
|
||||
github.com/FloatTech/rendercard v0.0.9-0.20230206125820-929cee91387c/go.mod h1:0LVxMhsw6LayHM78pJ58/TCkx0/CIVuYc19fCHpM/5g=
|
||||
github.com/FloatTech/AnimeAPI v1.6.1-0.20230301080805-a8aa0e4cee1f h1:X1qnXmZgogBgTdhpXz3Gl31nHdh5X6EP1F7iKH7JRHg=
|
||||
github.com/FloatTech/AnimeAPI v1.6.1-0.20230301080805-a8aa0e4cee1f/go.mod h1:4oFxa7b00MOHULzGm0GN97u/VqCq0J0NvLCF7Puymbs=
|
||||
github.com/FloatTech/floatbox v0.0.0-20230301074105-03017a267762 h1:UU9kPDPm9vRA2/qRTK33fa07AEnE6skjdyyvImAlel0=
|
||||
github.com/FloatTech/floatbox v0.0.0-20230301074105-03017a267762/go.mod h1:J0zCOJayFOyswwCNlqBQGu2q7OPjiu78kjr0oVF+MrM=
|
||||
github.com/FloatTech/gg v1.1.2 h1:YolgOYg3uDHc1+g0bLtt6QuRA/pvLn+b9IBCIhOOX88=
|
||||
github.com/FloatTech/gg v1.1.2/go.mod h1:uzPzAeT35egARdRuu+1oyjU3CmTwCceoq3Vvje7LpcI=
|
||||
github.com/FloatTech/imgfactory v0.2.2-0.20230215052637-9f7b05520ca9 h1:Havq0z/N79KeD50L7ms+Hv8F4Sw98Dt8lXM8jECp04o=
|
||||
github.com/FloatTech/imgfactory v0.2.2-0.20230215052637-9f7b05520ca9/go.mod h1:el5hGpj1C1bDRxcTXYRwEivDCr40zZeJpcrLrB1fajs=
|
||||
github.com/FloatTech/rendercard v0.0.10-0.20230223064326-45d29fa4ede9 h1:hffajvmQFfP68U6wUwHemPuuwCUoss+SEFfoLYwbGwE=
|
||||
github.com/FloatTech/rendercard v0.0.10-0.20230223064326-45d29fa4ede9/go.mod h1:NBFPhWae4hqVMeG8ELBBnUQkKce3nDjkljVn6PdiUNs=
|
||||
github.com/FloatTech/sqlite v1.5.7 h1:Bvo4LSojcZ6dVtbHrkqvt6z4v8e+sj0G5PSUIvdawsk=
|
||||
github.com/FloatTech/sqlite v1.5.7/go.mod h1:zFbHzRfB+CJ+VidfjuVbrcin3DAz283F7hF1hIeHzpY=
|
||||
github.com/FloatTech/ttl v0.0.0-20220715042055-15612be72f5b h1:tvciXWq2nuvTbFeJGLDNIdRX3BI546D3O7k7vrVueZw=
|
||||
github.com/FloatTech/ttl v0.0.0-20220715042055-15612be72f5b/go.mod h1:fHZFWGquNXuHttu9dUYoKuNbm3dzLETnIOnm1muSfDs=
|
||||
github.com/FloatTech/zbpctrl v1.5.3-0.20230130095145-714ad318cd52 h1:BrStRXeosWh8L0iA/EjPd8w6xNexDkqki39ITZko/9Q=
|
||||
github.com/FloatTech/zbpctrl v1.5.3-0.20230130095145-714ad318cd52/go.mod h1:qqMLUwR7tKpqnAqsgI7aZbn0hbs2FEVF4ylMXqIpBdY=
|
||||
github.com/FloatTech/zbputils v1.6.2-0.20230206130001-6b404926bf66 h1:Flhj6lBRDQQnAkRML2pIJEwqSu1NjfS2Tzh0HncaC2Q=
|
||||
github.com/FloatTech/zbputils v1.6.2-0.20230206130001-6b404926bf66/go.mod h1:cJiEzrjnkGlnw1oyL4wXmF64njoDN/jNV1Qm+Hu3B2o=
|
||||
github.com/FloatTech/zbpctrl v1.5.3-0.20230301071613-f2c5c97cec88 h1:jdTWiYXGtYZhxIn9oGYkObNVa8GtJvki+ihsoMlLJPs=
|
||||
github.com/FloatTech/zbpctrl v1.5.3-0.20230301071613-f2c5c97cec88/go.mod h1:8IRMtcWhK4S8QdpStJqXQZtIBgAqUH72Imq3BQ45TWg=
|
||||
github.com/FloatTech/zbputils v1.6.2-0.20230301080528-6560d8a50f34 h1:RyZCH94Rwx8tP+f22NH+ZUckq7xrIeqpt313W8dHcqE=
|
||||
github.com/FloatTech/zbputils v1.6.2-0.20230301080528-6560d8a50f34/go.mod h1:IZtlPpQUAcZcf3YRZqcIyDsxFcklArub1Sjz1ZIa6M0=
|
||||
github.com/PuerkitoBio/goquery v1.5.1/go.mod h1:GsLWisAFVj4WgDibEWF4pvYnkVQBpKBKeU+7zCJoLcc=
|
||||
github.com/RomiChan/syncx v0.0.0-20221202055724-5f842c53020e h1:wR3MXQ3VbUlPKOOUwLOYgh/QaJThBTYtsl673O3lqSA=
|
||||
github.com/RomiChan/syncx v0.0.0-20221202055724-5f842c53020e/go.mod h1:vD7Ra3Q9onRtojoY5sMCLQ7JBgjUsrXDnDKyFxqpf9w=
|
||||
@@ -58,8 +60,8 @@ github.com/fumiama/cron v1.3.0 h1:ZWlwuexF+HQHl3cYytEE5HNwD99q+3vNZF1GrEiXCFo=
|
||||
github.com/fumiama/cron v1.3.0/go.mod h1:bz5Izvgi/xEUI8tlBN8BI2jr9Moo8N4or0KV8xXuPDY=
|
||||
github.com/fumiama/go-base16384 v1.6.4 h1:rYDRwD/th2cG4U7QLokpzmST1cCxZGXtHmolOUePt5o=
|
||||
github.com/fumiama/go-base16384 v1.6.4/go.mod h1:OEn+947GV5gsbTAnyuUW/SrfxJYUdYupSIQXOuGOcXM=
|
||||
github.com/fumiama/go-registry v0.2.5 h1:Y6tnHnTThQPv7E4JPM2vBprU+4EQw/LEDO33HCmxgI4=
|
||||
github.com/fumiama/go-registry v0.2.5/go.mod h1:GP45kejHuDLFxcWdksrt75r5rHBqYwtfeUl3JzGWxfQ=
|
||||
github.com/fumiama/go-registry v0.2.6 h1:+vEeBUwa1+GC87ujW3Km42fi8O/H7QcpVJWu1iuGNh0=
|
||||
github.com/fumiama/go-registry v0.2.6/go.mod h1:HjYagPZXzR2xCCxaSQerqX7JRzC0yiv2kslDdBiTq/g=
|
||||
github.com/fumiama/go-simple-protobuf v0.1.0 h1:rLzJgNqB6LHNDVMl81yyNt6ZKziWtVfu+ioF0edlEVw=
|
||||
github.com/fumiama/go-simple-protobuf v0.1.0/go.mod h1:5yYNapXq1tQMOZg9bOIVhQlZk9pQqpuFIO4DZLbsdy4=
|
||||
github.com/fumiama/gofastTEA v0.0.10 h1:JJJ+brWD4kie+mmK2TkspDXKzqq0IjXm89aGYfoGhhQ=
|
||||
@@ -196,8 +198,8 @@ github.com/tklauser/numcpus v0.6.0 h1:kebhY2Qt+3U6RNK7UqpYNA+tJ23IBEGKkB7JQBfDYm
|
||||
github.com/tklauser/numcpus v0.6.0/go.mod h1:FEZLMke0lhOUG6w2JadTzp0a+Nl8PF/GFkQ5UVIcaL4=
|
||||
github.com/wcharczuk/go-chart/v2 v2.1.0 h1:tY2slqVQ6bN+yHSnDYwZebLQFkphK4WNrVwnt7CJZ2I=
|
||||
github.com/wcharczuk/go-chart/v2 v2.1.0/go.mod h1:yx7MvAVNcP/kN9lKXM/NTce4au4DFN99j6i1OwDclNA=
|
||||
github.com/wdvxdr1123/ZeroBot v1.6.8 h1:jdFhd6Bk0JBIKPpKhHnkACtjnIf4co6Hdw3U16e4Gi0=
|
||||
github.com/wdvxdr1123/ZeroBot v1.6.8/go.mod h1:T5kD5vLi/YxL/fyDOCOaawi96LRBdJjcXh2CIjDyFfg=
|
||||
github.com/wdvxdr1123/ZeroBot v1.6.10 h1:exmPWNjWtOMLgLQW/svQDybExRJAfDkjpE3S2U6fBOY=
|
||||
github.com/wdvxdr1123/ZeroBot v1.6.10/go.mod h1:y29UIOy0RD3P+0meDNIWRhcJF3jtWPN9xP9hgt/AJAU=
|
||||
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
|
||||
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
||||
github.com/yusufpapurcu/wmi v1.2.2 h1:KBNDSne4vP5mbSWnJbO+51IMOXJB67QiYCSBrubbPRg=
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
package kanban
|
||||
|
||||
// Version ...
|
||||
var Version = "v1.6.2-beta2"
|
||||
|
||||
// Banner ...
|
||||
var Banner = "* OneBot + ZeroBot + Golang\n" +
|
||||
"* Version " + Version + " - 2023-02-06 21:46:22 +0800 CST\n" +
|
||||
"* Copyright © 2020 - 2023 FloatTech. All Rights Reserved.\n" +
|
||||
"* Project: https://github.com/FloatTech/ZeroBot-Plugin"
|
||||
15
kanban/banner/banner.go
Normal file
15
kanban/banner/banner.go
Normal file
@@ -0,0 +1,15 @@
|
||||
// Code generated by kanban/gen. DO NOT EDIT.
|
||||
|
||||
package banner
|
||||
|
||||
// Version ...
|
||||
var Version = "v1.7.0-beta1"
|
||||
|
||||
// Copyright ...
|
||||
var Copyright = "© 2020 - 2023 FloatTech"
|
||||
|
||||
// Banner ...
|
||||
var Banner = "* OneBot + ZeroBot + Golang\n" +
|
||||
"* Version " + Version + " - 2023-03-01 16:16:25 +0800 CST\n" +
|
||||
"* Copyright " + Copyright + ". All Rights Reserved.\n" +
|
||||
"* Project: https://github.com/FloatTech/ZeroBot-Plugin"
|
||||
@@ -10,22 +10,27 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
const banner = `package kanban
|
||||
const banner = `// Code generated by kanban/gen. DO NOT EDIT.
|
||||
|
||||
package banner
|
||||
|
||||
// Version ...
|
||||
var Version = "%s"
|
||||
|
||||
// Copyright ...
|
||||
var Copyright = "© 2020 - %d FloatTech"
|
||||
|
||||
// Banner ...
|
||||
var Banner = "* OneBot + ZeroBot + Golang\n" +
|
||||
"* Version " + Version + " - %s\n" +
|
||||
"* Copyright © 2020 - %d FloatTech. All Rights Reserved.\n" +
|
||||
"* Copyright " + Copyright + ". All Rights Reserved.\n" +
|
||||
"* Project: https://github.com/FloatTech/ZeroBot-Plugin"
|
||||
`
|
||||
|
||||
const timeformat = `2006-01-02 15:04:05 +0800 CST`
|
||||
|
||||
func main() {
|
||||
f, err := os.Create("banner.go")
|
||||
f, err := os.Create("banner/banner.go")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -39,7 +44,7 @@ func main() {
|
||||
}
|
||||
s := strings.Split(vartag.String(), "\n")
|
||||
now := time.Now()
|
||||
_, err = fmt.Fprintf(f, banner, s[len(s)-2], now.Format(timeformat), now.Year())
|
||||
_, err = fmt.Fprintf(f, banner, s[len(s)-2], now.Year(), now.Format(timeformat))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
@@ -3,18 +3,17 @@ package kanban
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"sync"
|
||||
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
"github.com/fumiama/go-registry"
|
||||
|
||||
"github.com/FloatTech/ZeroBot-Plugin/kanban/banner"
|
||||
)
|
||||
|
||||
//go:generate go run github.com/FloatTech/ZeroBot-Plugin/kanban/gen
|
||||
|
||||
var once sync.Once
|
||||
|
||||
func init() {
|
||||
once.Do(PrintBanner)
|
||||
PrintBanner()
|
||||
}
|
||||
|
||||
var reg = registry.NewRegReader("reilia.fumiama.top:32664", control.Md5File, "fumiama")
|
||||
@@ -23,7 +22,7 @@ var reg = registry.NewRegReader("reilia.fumiama.top:32664", control.Md5File, "fu
|
||||
func PrintBanner() {
|
||||
fmt.Print(
|
||||
"\n======================[ZeroBot-Plugin]======================",
|
||||
"\n", Banner, "\n",
|
||||
"\n", banner.Banner, "\n",
|
||||
"----------------------[ZeroBot-公告栏]----------------------",
|
||||
"\n", Kanban(), "\n",
|
||||
"============================================================\n\n",
|
||||
|
||||
184
main.go
184
main.go
@@ -7,10 +7,14 @@ import (
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"os"
|
||||
"runtime"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/FloatTech/ZeroBot-Plugin/kanban" // 在最前打印 banner
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/console" // 更改控制台属性
|
||||
|
||||
"github.com/FloatTech/ZeroBot-Plugin/kanban" // 打印 banner
|
||||
|
||||
// ---------以下插件均可通过前面加 // 注释,注释后停用并不加载插件--------- //
|
||||
// ----------------------插件优先级按顺序从高到低---------------------- //
|
||||
@@ -56,89 +60,91 @@ import (
|
||||
// vvvvvvvvvvvvvv //
|
||||
// vvvv //
|
||||
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/ahsai" // ahsai tts
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/ai_false" // 服务器监控
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/aipaint" // ai绘图
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/aiwife" // 随机老婆
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/alipayvoice" // 支付宝到账语音
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/autowithdraw" // 触发者撤回时也自动撤回
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/b14" // base16384加解密
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/baidu" // 百度一下
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/baiduaudit" // 百度内容审核
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/base64gua" // base64卦加解密
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/baseamasiro" // base天城文加解密
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/bilibili" // b站相关
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/book_review" // 哀伤雪刃吧推书记录
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/cangtoushi" // 藏头诗
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/choose" // 选择困难症帮手
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/chouxianghua" // 说抽象话
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/chrev" // 英文字符翻转
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/coser" // 三次元小姐姐
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/cpstory" // cp短打
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/danbooru" // DeepDanbooru二次元图标签识别
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/diana" // 嘉心糖发病
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/dress" // 女装
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/drift_bottle" // 漂流瓶
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/emojimix" // 合成emoji
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/event" // 好友申请群聊邀请事件处理
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/font" // 渲染任意文字到图片
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/fortune" // 运势
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/funny" // 笑话
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/genshin" // 原神抽卡
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/gif" // 制图
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/github" // 搜索GitHub仓库
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/guessmusic" // 猜歌
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/heisi" // 黑丝
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/hs" // 炉石
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/hyaku" // 百人一首
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/image_finder" // 关键字搜图
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/inject" // 注入指令
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/jandan" // 煎蛋网无聊图
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/jiami" // 兽语加密
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/jikipedia" // 小鸡词典
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/jptingroom" // 日语听力学习材料
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/juejuezi" // 绝绝子生成器
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/lolicon" // lolicon 随机图片
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/magicprompt" // magicprompt吟唱提示
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/midicreate" // 简易midi音乐制作
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/moegoe" // 日韩 VITS 模型拟声
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/moyu" // 摸鱼
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/moyu_calendar" // 摸鱼人日历
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/music" // 点歌
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/nativesetu" // 本地涩图
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/nativewife" // 本地老婆
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/nbnhhsh" // 拼音首字母缩写释义工具
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/nihongo" // 日语语法学习
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/novel" // 铅笔小说网搜索
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/nsfw" // nsfw图片识别
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/omikuji" // 浅草寺求签
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/qqwife" // 一群一天一夫一妻制群老婆
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/quan" // QQ权重查询
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/qzone" // qq空间表白墙
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/realcugan" // realcugan清晰术
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/reborn" // 投胎
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/runcode" // 在线运行代码
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/saucenao" // 以图搜图
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/scale" // 叔叔的AI二次元图片放大
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/score" // 分数
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/setutime" // 来份涩图
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/shadiao" // 沙雕app
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/shindan" // 测定
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/tarot" // 抽塔罗牌
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/tiangou" // 舔狗日记
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/tracemoe" // 搜番
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/translation" // 翻译
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/vitsnyaru" // vits猫雷
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/vtb_quotation" // vtb语录
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/wallet" // 钱包
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/wangyiyun" // 网易云音乐热评
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/warframeapi" // warframeAPI插件
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/wenben" // 文本指令大全
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/wenxinAI" // 百度文心AI画图
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/word_count" // 聊天热词
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/wordle" // 猜单词
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/ygo" // 游戏王相关插件
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/ymgal" // 月幕galgame
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/ahsai" // ahsai tts
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/ai_false" // 服务器监控
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/aipaint" // ai绘图
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/aiwife" // 随机老婆
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/alipayvoice" // 支付宝到账语音
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/autowithdraw" // 触发者撤回时也自动撤回
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/b14" // base16384加解密
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/baidu" // 百度一下
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/baiduaudit" // 百度内容审核
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/base64gua" // base64卦加解密
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/baseamasiro" // base天城文加解密
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/bilibili" // b站相关
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/book_review" // 哀伤雪刃吧推书记录
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/cangtoushi" // 藏头诗
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/choose" // 选择困难症帮手
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/chouxianghua" // 说抽象话
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/chrev" // 英文字符翻转
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/coser" // 三次元小姐姐
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/cpstory" // cp短打
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/dailynews" // 今日早报
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/danbooru" // DeepDanbooru二次元图标签识别
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/diana" // 嘉心糖发病
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/dress" // 女装
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/drift_bottle" // 漂流瓶
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/emojimix" // 合成emoji
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/event" // 好友申请群聊邀请事件处理
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/font" // 渲染任意文字到图片
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/fortune" // 运势
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/funny" // 笑话
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/genshin" // 原神抽卡
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/gif" // 制图
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/github" // 搜索GitHub仓库
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/guessmusic" // 猜歌
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/heisi" // 黑丝
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/hs" // 炉石
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/hyaku" // 百人一首
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/image_finder" // 关键字搜图
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/inject" // 注入指令
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/jandan" // 煎蛋网无聊图
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/jiami" // 兽语加密
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/jptingroom" // 日语听力学习材料
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/juejuezi" // 绝绝子生成器
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/kfccrazythursday" // 疯狂星期四
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/lolicon" // lolicon 随机图片
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/magicprompt" // magicprompt吟唱提示
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/midicreate" // 简易midi音乐制作
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/moegoe" // 日韩 VITS 模型拟声
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/moyu" // 摸鱼
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/moyu_calendar" // 摸鱼人日历
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/music" // 点歌
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/nativesetu" // 本地涩图
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/nativewife" // 本地老婆
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/nbnhhsh" // 拼音首字母缩写释义工具
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/nihongo" // 日语语法学习
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/novel" // 铅笔小说网搜索
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/nsfw" // nsfw图片识别
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/omikuji" // 浅草寺求签
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/qqwife" // 一群一天一夫一妻制群老婆
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/quan" // QQ权重查询
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/qzone" // qq空间表白墙
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/realcugan" // realcugan清晰术
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/reborn" // 投胎
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/runcode" // 在线运行代码
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/saucenao" // 以图搜图
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/scale" // 叔叔的AI二次元图片放大
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/score" // 分数
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/setutime" // 来份涩图
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/shadiao" // 沙雕app
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/shindan" // 测定
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/tarot" // 抽塔罗牌
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/tiangou" // 舔狗日记
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/tracemoe" // 搜番
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/translation" // 翻译
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/vitsnyaru" // vits猫雷
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/vtb_quotation" // vtb语录
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/vtbmusic" // vtb点歌
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/wallet" // 钱包
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/wangyiyun" // 网易云音乐热评
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/warframeapi" // warframeAPI插件
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/wenben" // 文本指令大全
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/wenxinAI" // 百度文心AI画图
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/word_count" // 聊天热词
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/wordle" // 猜单词
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/ygo" // 游戏王相关插件
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/ymgal" // 月幕galgame
|
||||
|
||||
// _ "github.com/FloatTech/ZeroBot-Plugin/plugin/thesaurus" // 词典匹配回复
|
||||
// _ "github.com/FloatTech/ZeroBot-Plugin/plugin/wtf" // 鬼东西
|
||||
@@ -184,6 +190,8 @@ import (
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/driver"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
|
||||
"github.com/FloatTech/ZeroBot-Plugin/kanban/banner"
|
||||
// -----------------------以上为内置依赖,勿动------------------------ //
|
||||
)
|
||||
|
||||
@@ -289,15 +297,17 @@ func init() {
|
||||
}
|
||||
|
||||
func main() {
|
||||
rand.Seed(time.Now().UnixNano()) // 全局 seed,其他插件无需再 seed
|
||||
if !strings.Contains(runtime.Version(), "go1.2") { // go1.20之前版本需要全局 seed,其他插件无需再 seed
|
||||
rand.Seed(time.Now().UnixNano()) //nolint: staticcheck
|
||||
}
|
||||
// 帮助
|
||||
zero.OnFullMatchGroup([]string{"/help", ".help", "菜单"}, zero.OnlyToMe).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
ctx.SendChain(message.Text(kanban.Banner, "\n可发送\"/服务列表\"查看 bot 功能"))
|
||||
ctx.SendChain(message.Text(banner.Banner, "\n管理发送\"/服务列表\"查看 bot 功能\n发送\"/用法name\"查看功能用法"))
|
||||
})
|
||||
zero.OnFullMatch("查看zbp公告", zero.OnlyToMe, zero.AdminPermission).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
ctx.SendChain(message.Text(kanban.Kanban()))
|
||||
ctx.SendChain(message.Text(strings.ReplaceAll(kanban.Kanban(), "\t", "")))
|
||||
})
|
||||
zero.RunAndBlock(&config.Z, process.GlobalInitMutex.Unlock)
|
||||
}
|
||||
|
||||
70
main_win.go
70
main_win.go
@@ -1,70 +0,0 @@
|
||||
//go:build windows
|
||||
// +build windows
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"strings"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
func init() {
|
||||
// windows 带颜色 log 自定义格式
|
||||
logrus.SetFormatter(&LogFormat{})
|
||||
}
|
||||
|
||||
const (
|
||||
colorCodePanic = "\x1b[1;31m" // color.Style{color.Bold, color.Red}.String()
|
||||
colorCodeFatal = "\x1b[1;31m" // color.Style{color.Bold, color.Red}.String()
|
||||
colorCodeError = "\x1b[31m" // color.Style{color.Red}.String()
|
||||
colorCodeWarn = "\x1b[33m" // color.Style{color.Yellow}.String()
|
||||
colorCodeInfo = "\x1b[37m" // color.Style{color.White}.String()
|
||||
colorCodeDebug = "\x1b[32m" // color.Style{color.Green}.String()
|
||||
colorCodeTrace = "\x1b[36m" // color.Style{color.Cyan}.String()
|
||||
colorReset = "\x1b[0m"
|
||||
)
|
||||
|
||||
// LogFormat specialize for zbp
|
||||
type LogFormat struct{}
|
||||
|
||||
// Format implements logrus.Formatter
|
||||
func (f LogFormat) Format(entry *logrus.Entry) ([]byte, error) {
|
||||
buf := new(bytes.Buffer)
|
||||
|
||||
buf.WriteString(getLogLevelColorCode(entry.Level))
|
||||
|
||||
buf.WriteByte('[')
|
||||
buf.WriteString(strings.ToUpper(entry.Level.String()))
|
||||
buf.WriteString("] ")
|
||||
buf.WriteString(entry.Message)
|
||||
buf.WriteString(" \n")
|
||||
|
||||
buf.WriteString(colorReset)
|
||||
|
||||
return buf.Bytes(), nil
|
||||
}
|
||||
|
||||
// getLogLevelColorCode 获取日志等级对应色彩code
|
||||
func getLogLevelColorCode(level logrus.Level) string {
|
||||
switch level {
|
||||
case logrus.PanicLevel:
|
||||
return colorCodePanic
|
||||
case logrus.FatalLevel:
|
||||
return colorCodeFatal
|
||||
case logrus.ErrorLevel:
|
||||
return colorCodeError
|
||||
case logrus.WarnLevel:
|
||||
return colorCodeWarn
|
||||
case logrus.InfoLevel:
|
||||
return colorCodeInfo
|
||||
case logrus.DebugLevel:
|
||||
return colorCodeDebug
|
||||
case logrus.TraceLevel:
|
||||
return colorCodeTrace
|
||||
|
||||
default:
|
||||
return colorCodeInfo
|
||||
}
|
||||
}
|
||||
@@ -10,18 +10,19 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
"unsafe"
|
||||
|
||||
"github.com/FloatTech/AnimeAPI/bilibili"
|
||||
"github.com/FloatTech/floatbox/file"
|
||||
"github.com/FloatTech/floatbox/img/writer"
|
||||
"github.com/FloatTech/floatbox/web"
|
||||
"github.com/FloatTech/gg"
|
||||
"github.com/FloatTech/imgfactory"
|
||||
"github.com/FloatTech/rendercard"
|
||||
ctrl "github.com/FloatTech/zbpctrl"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/ctxext"
|
||||
"github.com/FloatTech/zbputils/img"
|
||||
"github.com/FloatTech/zbputils/img/text"
|
||||
"github.com/disintegration/imaging"
|
||||
"github.com/shirou/gopsutil/v3/cpu"
|
||||
@@ -32,7 +33,7 @@ import (
|
||||
"golang.org/x/text/cases"
|
||||
"golang.org/x/text/language"
|
||||
|
||||
"github.com/FloatTech/ZeroBot-Plugin/kanban"
|
||||
"github.com/FloatTech/ZeroBot-Plugin/kanban/banner"
|
||||
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
@@ -43,7 +44,11 @@ const (
|
||||
referer = "https://weibo.com/"
|
||||
)
|
||||
|
||||
var boottime = time.Now()
|
||||
var (
|
||||
boottime = time.Now()
|
||||
bgdata *[]byte
|
||||
bgcount uintptr
|
||||
)
|
||||
|
||||
func init() { // 插件主体
|
||||
engine := control.Register("aifalse", &ctrl.Options[*zero.Ctx]{
|
||||
@@ -70,11 +75,14 @@ func init() { // 插件主体
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
sendimg, cl := writer.ToBytes(img)
|
||||
sendimg, err := imgfactory.ToBytes(img)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
if id := ctx.SendChain(message.ImageBytes(sendimg)); id.ID() == 0 {
|
||||
ctx.SendChain(message.Text("ERROR: 可能被风控了"))
|
||||
}
|
||||
cl()
|
||||
})
|
||||
engine.OnRegex(`^设置默认限速为每\s*(\d+)\s*(分钟|秒)\s*(\d+)\s*次触发$`, zero.SuperUserPermission).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
@@ -132,14 +140,22 @@ func drawstatus(m *ctrl.Control[*zero.Ctx], uid int64, botname string) (sendimg
|
||||
return
|
||||
}
|
||||
|
||||
url, err := bilibili.GetRealURL(backgroundURL)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
data, err := web.RequestDataWith(web.NewDefaultClient(), url, "", referer, "", nil)
|
||||
if err != nil {
|
||||
return
|
||||
dldata := (*[]byte)(atomic.LoadPointer((*unsafe.Pointer)(unsafe.Pointer(&bgdata))))
|
||||
if dldata == (*[]byte)(nil) || uintptr(time.Since(boottime).Hours()/24) >= atomic.LoadUintptr(&bgcount) {
|
||||
url, err1 := bilibili.GetRealURL(backgroundURL)
|
||||
if err1 != nil {
|
||||
return nil, err1
|
||||
}
|
||||
data, err1 := web.RequestDataWith(web.NewDefaultClient(), url, "", referer, "", nil)
|
||||
if err1 != nil {
|
||||
return nil, err1
|
||||
}
|
||||
atomic.AddUintptr(&bgcount, 1)
|
||||
atomic.StorePointer((*unsafe.Pointer)(unsafe.Pointer(&bgdata)), unsafe.Pointer(&data))
|
||||
dldata = &data
|
||||
}
|
||||
data := *dldata
|
||||
|
||||
back, _, err := image.Decode(bytes.NewReader(data))
|
||||
if err != nil {
|
||||
return
|
||||
@@ -153,7 +169,7 @@ func drawstatus(m *ctrl.Control[*zero.Ctx], uid int64, botname string) (sendimg
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
avatarf := img.Size(avatar, 200, 200)
|
||||
avatarf := imgfactory.Size(avatar, 200, 200)
|
||||
|
||||
fontbyte, err := file.GetLazyData(text.GlowSansFontFile, control.Md5File, true)
|
||||
if err != nil {
|
||||
@@ -165,10 +181,10 @@ func drawstatus(m *ctrl.Control[*zero.Ctx], uid int64, botname string) (sendimg
|
||||
bh, bw, ch, cw := float64(back.Bounds().Dy()), float64(back.Bounds().Dx()), float64(canvas.H()), float64(canvas.W())
|
||||
|
||||
if bh/bw < ch/cw {
|
||||
back = img.Size(back, int(bw*ch/bh), int(bh*ch/bh)).Im
|
||||
back = imgfactory.Size(back, int(bw*ch/bh), int(bh*ch/bh)).Image()
|
||||
canvas.DrawImageAnchored(back, canvas.W()/2, canvas.H()/2, 0.5, 0.5)
|
||||
} else {
|
||||
back = img.Size(back, int(bw*cw/bw), int(bh*cw/bw)).Im
|
||||
back = imgfactory.Size(back, int(bw*cw/bw), int(bh*cw/bw)).Image()
|
||||
canvas.DrawImage(back, 0, 0)
|
||||
}
|
||||
|
||||
@@ -194,7 +210,7 @@ func drawstatus(m *ctrl.Control[*zero.Ctx], uid int64, botname string) (sendimg
|
||||
titlecard.SetRGBA255(255, 255, 255, 140)
|
||||
titlecard.Fill()
|
||||
|
||||
titlecard.DrawImage(avatarf.Circle(0).Im, (titlecardh-avatarf.H)/2, (titlecardh-avatarf.H)/2)
|
||||
titlecard.DrawImage(avatarf.Circle(0).Image(), (titlecardh-avatarf.H())/2, (titlecardh-avatarf.H())/2)
|
||||
|
||||
err = titlecard.ParseFontFace(fontbyte, 72)
|
||||
if err != nil {
|
||||
@@ -437,9 +453,9 @@ func drawstatus(m *ctrl.Control[*zero.Ctx], uid int64, botname string) (sendimg
|
||||
return
|
||||
}
|
||||
canvas.SetRGBA255(0, 0, 0, 255)
|
||||
canvas.DrawStringAnchored("Created By ZeroBot-Plugin "+kanban.Version, float64(canvas.W())/2+3, float64(canvas.H())-70/2+3, 0.5, 0.5)
|
||||
canvas.DrawStringAnchored("Created By ZeroBot-Plugin "+banner.Version, float64(canvas.W())/2+3, float64(canvas.H())-70/2+3, 0.5, 0.5)
|
||||
canvas.SetRGBA255(255, 255, 255, 255)
|
||||
canvas.DrawStringAnchored("Created By ZeroBot-Plugin "+kanban.Version, float64(canvas.W())/2, float64(canvas.H())-70/2, 0.5, 0.5)
|
||||
canvas.DrawStringAnchored("Created By ZeroBot-Plugin "+banner.Version, float64(canvas.W())/2, float64(canvas.H())-70/2, 0.5, 0.5)
|
||||
|
||||
sendimg = canvas.Image()
|
||||
return
|
||||
|
||||
@@ -32,20 +32,28 @@ const (
|
||||
mockingbirdttsindex
|
||||
)
|
||||
|
||||
// extrattsname is the tts other than genshin vits
|
||||
var extrattsname = []string{"百度", "拟声鸟"}
|
||||
|
||||
const (
|
||||
defaultttsindexkey = -2905
|
||||
defaultttsindexkey = -2905
|
||||
gsapikeyextragrp = -1
|
||||
chatgptapikeyextragrp = -2
|
||||
)
|
||||
|
||||
var replyModes = [...]string{"青云客", "小爱"}
|
||||
type replymode struct {
|
||||
APIKey string // APIKey is for chatgpt
|
||||
replyModes []string `json:"-"`
|
||||
}
|
||||
|
||||
func setReplyMode(ctx *zero.Ctx, name string) error {
|
||||
func (r *replymode) setReplyMode(ctx *zero.Ctx, name string) error {
|
||||
gid := ctx.Event.GroupID
|
||||
if gid == 0 {
|
||||
gid = -ctx.Event.UserID
|
||||
}
|
||||
var ok bool
|
||||
var index int64
|
||||
for i, s := range replyModes {
|
||||
for i, s := range r.replyModes {
|
||||
if s == name {
|
||||
ok = true
|
||||
index = int64(i)
|
||||
@@ -62,24 +70,47 @@ func setReplyMode(ctx *zero.Ctx, name string) error {
|
||||
return m.SetData(gid, (m.GetData(index)&^0xff)|(index&0xff))
|
||||
}
|
||||
|
||||
func getReplyMode(ctx *zero.Ctx) aireply.AIReply {
|
||||
func (r *replymode) getReplyMode(ctx *zero.Ctx) aireply.AIReply {
|
||||
gid := ctx.Event.GroupID
|
||||
if gid == 0 {
|
||||
gid = -ctx.Event.UserID
|
||||
}
|
||||
m, ok := ctx.State["manager"].(*ctrl.Control[*zero.Ctx])
|
||||
if ok {
|
||||
if m.GetData(gid)&0xff == 1 {
|
||||
switch m.GetData(gid) & 0xff {
|
||||
case 0:
|
||||
return aireply.NewQYK(aireply.QYKURL, aireply.QYKBotName)
|
||||
case 1:
|
||||
return aireply.NewXiaoAi(aireply.XiaoAiURL, aireply.XiaoAiBotName)
|
||||
case 2:
|
||||
k := r.getAPIKey(ctx)
|
||||
if k != "" {
|
||||
return aireply.NewChatGPT(aireply.ChatGPTURL, k)
|
||||
}
|
||||
return aireply.NewQYK(aireply.QYKURL, aireply.QYKBotName)
|
||||
}
|
||||
return aireply.NewQYK(aireply.QYKURL, aireply.QYKBotName)
|
||||
}
|
||||
return aireply.NewQYK(aireply.QYKURL, aireply.QYKBotName)
|
||||
}
|
||||
|
||||
func (r *replymode) getAPIKey(ctx *zero.Ctx) string {
|
||||
if r.APIKey == "" {
|
||||
m := ctx.State["manager"].(*ctrl.Control[*zero.Ctx])
|
||||
_ = m.Manager.GetExtra(chatgptapikeyextragrp, &r)
|
||||
logrus.Debugln("[tts] get api key:", r.APIKey)
|
||||
}
|
||||
return r.APIKey
|
||||
}
|
||||
|
||||
func (r *replymode) setAPIKey(m *ctrl.Control[*zero.Ctx], key string) error {
|
||||
r.APIKey = key
|
||||
_ = m.Manager.Response(chatgptapikeyextragrp)
|
||||
return m.Manager.SetExtra(chatgptapikeyextragrp, r)
|
||||
}
|
||||
|
||||
var ttsins = func() map[string]tts.TTS {
|
||||
m := make(map[string]tts.TTS, 128)
|
||||
for _, mode := range append(genshin.SoundList[:], "百度", "拟声鸟") {
|
||||
for _, mode := range append(genshin.SoundList[:], extrattsname...) {
|
||||
m[mode] = nil
|
||||
}
|
||||
return m
|
||||
@@ -87,7 +118,7 @@ var ttsins = func() map[string]tts.TTS {
|
||||
|
||||
var ttsModes = func() []string {
|
||||
s := append(genshin.SoundList[:], make([]string, 64-len(genshin.SoundList))...) // 0-63
|
||||
s = append(s, "百度", "拟声鸟") // 64 65
|
||||
s = append(s, extrattsname...) // 64 65 ...
|
||||
return s
|
||||
}()
|
||||
|
||||
@@ -127,7 +158,7 @@ func newttsmode() *ttsmode {
|
||||
func (t *ttsmode) getAPIKey(ctx *zero.Ctx) string {
|
||||
if t.APIKey == "" {
|
||||
m := ctx.State["manager"].(*ctrl.Control[*zero.Ctx])
|
||||
_ = m.Manager.GetExtra(-1, &t)
|
||||
_ = m.Manager.GetExtra(gsapikeyextragrp, &t)
|
||||
logrus.Debugln("[tts] get api key:", t.APIKey)
|
||||
}
|
||||
return url.QueryEscape(t.APIKey)
|
||||
@@ -135,8 +166,8 @@ func (t *ttsmode) getAPIKey(ctx *zero.Ctx) string {
|
||||
|
||||
func (t *ttsmode) setAPIKey(m *ctrl.Control[*zero.Ctx], key string) error {
|
||||
t.APIKey = key
|
||||
_ = m.Manager.Response(-1)
|
||||
return m.Manager.SetExtra(-1, t)
|
||||
_ = m.Manager.Response(gsapikeyextragrp)
|
||||
return m.Manager.SetExtra(gsapikeyextragrp, t)
|
||||
}
|
||||
|
||||
func (t *ttsmode) setSoundMode(ctx *zero.Ctx, name string, baiduper, mockingsynt int) error {
|
||||
@@ -157,9 +188,9 @@ func (t *ttsmode) setSoundMode(ctx *zero.Ctx, name string, baiduper, mockingsynt
|
||||
}
|
||||
if index == -1 {
|
||||
switch name {
|
||||
case "百度":
|
||||
case extrattsname[0]:
|
||||
index = baiduttsindex
|
||||
case "拟声鸟":
|
||||
case extrattsname[1]:
|
||||
index = mockingbirdttsindex
|
||||
default:
|
||||
return errors.New("语音人物" + name + "未注册index")
|
||||
@@ -189,9 +220,9 @@ func (t *ttsmode) getSoundMode(ctx *zero.Ctx) (tts.TTS, error) {
|
||||
ins, ok := ttsins[mode]
|
||||
if !ok || ins == nil {
|
||||
switch mode {
|
||||
case "百度":
|
||||
case extrattsname[0]:
|
||||
ins = baidutts.NewBaiduTTS(int(i&0x0f00) >> 8)
|
||||
case "拟声鸟":
|
||||
case extrattsname[1]:
|
||||
var err error
|
||||
ins, err = mockingbird.NewMockingBirdTTS(int(i&0xf000) >> 12)
|
||||
if err != nil {
|
||||
@@ -234,9 +265,9 @@ func (t *ttsmode) setDefaultSoundMode(name string, baiduper, mockingsynt int) er
|
||||
}
|
||||
if index == -1 {
|
||||
switch name {
|
||||
case "百度":
|
||||
case extrattsname[0]:
|
||||
index = baiduttsindex
|
||||
case "拟声鸟":
|
||||
case extrattsname[1]:
|
||||
index = mockingbirdttsindex
|
||||
default:
|
||||
return errors.New("语音人物" + name + "未注册index")
|
||||
|
||||
@@ -15,7 +15,11 @@ import (
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
)
|
||||
|
||||
var t = newttsmode()
|
||||
var replmd = replymode{
|
||||
replyModes: []string{"青云客", "小爱", "ChatGPT"},
|
||||
}
|
||||
|
||||
var ttsmd = newttsmode()
|
||||
|
||||
func init() { // 插件主体
|
||||
ent := control.Register("tts", &ctrl.Options[*zero.Ctx]{
|
||||
@@ -32,13 +36,13 @@ func init() { // 插件主体
|
||||
enr := control.Register("aireply", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Brief: "人工智能回复",
|
||||
Help: "- @Bot 任意文本(任意一句话回复)\n- 设置回复模式[青云客|小爱]",
|
||||
Help: "- @Bot 任意文本(任意一句话回复)\n- 设置回复模式[青云客|小爱|ChatGPT]\n- 设置 ChatGPT api key xxx",
|
||||
PrivateDataFolder: "aireply",
|
||||
})
|
||||
|
||||
enr.OnMessage(zero.OnlyToMe).SetBlock(true).Limit(ctxext.LimitByUser).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
aireply := getReplyMode(ctx)
|
||||
aireply := replmd.getReplyMode(ctx)
|
||||
reply := message.ParseMessageFromString(aireply.Talk(ctx.Event.UserID, ctx.ExtractPlainText(), zero.BotConfig.NickName[0]))
|
||||
// 回复
|
||||
time.Sleep(time.Second * 1)
|
||||
@@ -52,7 +56,7 @@ func init() { // 插件主体
|
||||
|
||||
enr.OnPrefix("设置回复模式", zero.AdminPermission).SetBlock(true).Handle(func(ctx *zero.Ctx) {
|
||||
param := ctx.State["args"].(string)
|
||||
err := setReplyMode(ctx, param)
|
||||
err := replmd.setReplyMode(ctx, param)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(err))
|
||||
return
|
||||
@@ -60,16 +64,25 @@ func init() { // 插件主体
|
||||
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text("成功"))
|
||||
})
|
||||
|
||||
enr.OnRegex(`^设置\s*ChatGPT\s*api\s*key\s*(.*)$`, zero.OnlyPrivate, zero.SuperUserPermission).SetBlock(true).Handle(func(ctx *zero.Ctx) {
|
||||
err := replmd.setAPIKey(ctx.State["manager"].(*ctrl.Control[*zero.Ctx]), ctx.State["regex_matched"].([]string)[1])
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Text("设置成功"))
|
||||
})
|
||||
|
||||
endpre := regexp.MustCompile(`\pP$`)
|
||||
ent.OnMessage(zero.OnlyToMe).SetBlock(true).Limit(ctxext.LimitByUser).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
msg := ctx.ExtractPlainText()
|
||||
// 获取回复模式
|
||||
r := getReplyMode(ctx)
|
||||
r := replmd.getReplyMode(ctx)
|
||||
// 获取回复的文本
|
||||
reply := r.TalkPlain(ctx.Event.UserID, msg, zero.BotConfig.NickName[0])
|
||||
// 获取语音
|
||||
speaker, err := t.getSoundMode(ctx)
|
||||
speaker, err := ttsmd.getSoundMode(ctx)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
@@ -104,7 +117,7 @@ func init() { // 插件主体
|
||||
}
|
||||
// 保存设置
|
||||
logrus.Debugln("[tts] t.setSoundMode( ctx", param, n, n, ")")
|
||||
err = t.setSoundMode(ctx, param, n, n)
|
||||
err = ttsmd.setSoundMode(ctx, param, n, n)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(err))
|
||||
return
|
||||
@@ -112,7 +125,7 @@ func init() { // 插件主体
|
||||
if banner, ok := genshin.TestRecord[param]; ok {
|
||||
logrus.Debugln("[tts] banner:", banner, "get sound mode...")
|
||||
// 设置验证
|
||||
speaker, err := t.getSoundMode(ctx)
|
||||
speaker, err := ttsmd.getSoundMode(ctx)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
@@ -146,7 +159,7 @@ func init() { // 插件主体
|
||||
}
|
||||
}
|
||||
// 保存设置
|
||||
err = t.setDefaultSoundMode(param, n, n)
|
||||
err = ttsmd.setDefaultSoundMode(param, n, n)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(err))
|
||||
return
|
||||
@@ -155,13 +168,13 @@ func init() { // 插件主体
|
||||
})
|
||||
|
||||
ent.OnFullMatch("恢复成默认语音模式", zero.AdminPermission).SetBlock(true).Handle(func(ctx *zero.Ctx) {
|
||||
err := t.resetSoundMode(ctx)
|
||||
err := ttsmd.resetSoundMode(ctx)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(err))
|
||||
return
|
||||
}
|
||||
// 设置验证
|
||||
speaker, err := t.getSoundMode(ctx)
|
||||
speaker, err := ttsmd.getSoundMode(ctx)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
@@ -170,7 +183,7 @@ func init() { // 插件主体
|
||||
})
|
||||
|
||||
ent.OnRegex(`^设置原神语音\s*api\s*key\s*([0-9a-zA-Z-_]{54}==)$`, zero.OnlyPrivate, zero.SuperUserPermission).SetBlock(true).Handle(func(ctx *zero.Ctx) {
|
||||
err := t.setAPIKey(ctx.State["manager"].(*ctrl.Control[*zero.Ctx]), ctx.State["regex_matched"].([]string)[1])
|
||||
err := ttsmd.setAPIKey(ctx.State["manager"].(*ctrl.Control[*zero.Ctx]), ctx.State["regex_matched"].([]string)[1])
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
|
||||
@@ -11,8 +11,8 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/FloatTech/floatbox/file"
|
||||
"github.com/FloatTech/floatbox/img/writer"
|
||||
"github.com/FloatTech/floatbox/web"
|
||||
"github.com/FloatTech/imgfactory"
|
||||
ctrl "github.com/FloatTech/zbpctrl"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
@@ -73,7 +73,7 @@ func init() { // 插件主体
|
||||
}
|
||||
|
||||
// 图片转base64
|
||||
base64Bytes, err := writer.ToBase64(img)
|
||||
base64Bytes, err := imgfactory.ToBase64(img)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
|
||||
@@ -19,12 +19,11 @@ import (
|
||||
bz "github.com/FloatTech/AnimeAPI/bilibili"
|
||||
fcext "github.com/FloatTech/floatbox/ctxext"
|
||||
"github.com/FloatTech/floatbox/file"
|
||||
"github.com/FloatTech/floatbox/img/writer"
|
||||
"github.com/FloatTech/floatbox/web"
|
||||
"github.com/FloatTech/gg"
|
||||
"github.com/FloatTech/imgfactory"
|
||||
ctrl "github.com/FloatTech/zbpctrl"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/img"
|
||||
"github.com/FloatTech/zbputils/img/text"
|
||||
log "github.com/sirupsen/logrus"
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
@@ -174,7 +173,7 @@ func init() {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
back = img.Size(back, backX, backY).Im
|
||||
back = imgfactory.Size(back, backX, backY).Image()
|
||||
}
|
||||
if len(vups) > 50 {
|
||||
ctx.SendChain(message.Text(u.Name + "关注的up主太多了, 只展示前50个up"))
|
||||
@@ -188,11 +187,11 @@ func init() {
|
||||
canvas.DrawImage(back, 0, 0)
|
||||
}
|
||||
canvas.SetColor(color.Black)
|
||||
_, err = file.GetLazyData(text.BoldFontFile, control.Md5File, true)
|
||||
data, err := file.GetLazyData(text.BoldFontFile, control.Md5File, true)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
}
|
||||
if err = canvas.LoadFontFace(text.BoldFontFile, fontSize); err != nil {
|
||||
if err = canvas.ParseFontFace(data, fontSize); err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
@@ -259,12 +258,15 @@ func init() {
|
||||
f, err := os.Create(drawedFile)
|
||||
if err != nil {
|
||||
log.Errorln("[bilibili]", err)
|
||||
data, cl := writer.ToBytes(canvas.Image())
|
||||
data, err := imgfactory.ToBytes(canvas.Image())
|
||||
if err != nil {
|
||||
log.Errorln("[bilibili]", err)
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.ImageBytes(data))
|
||||
cl()
|
||||
return
|
||||
}
|
||||
_, err = writer.WriteTo(canvas.Image(), f)
|
||||
_, err = imgfactory.WriteTo(canvas.Image(), f)
|
||||
_ = f.Close()
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
@@ -318,15 +320,15 @@ func init() {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
back = img.Size(back, backX, backY).Im
|
||||
back = imgfactory.Size(back, backX, backY).Image()
|
||||
}
|
||||
canvas := gg.NewContext(100, 100)
|
||||
fontSize := 50.0
|
||||
_, err = file.GetLazyData(text.BoldFontFile, control.Md5File, true)
|
||||
data, err = file.GetLazyData(text.BoldFontFile, control.Md5File, true)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
}
|
||||
if err = canvas.LoadFontFace(text.BoldFontFile, fontSize); err != nil {
|
||||
if err = canvas.ParseFontFace(data, fontSize); err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
@@ -338,14 +340,14 @@ func init() {
|
||||
for i := 0; i < len(danmaku.Data.Data); i++ {
|
||||
totalDanmuku += len(danmaku.Data.Data[i].Danmakus) + 1
|
||||
}
|
||||
cw := 10000
|
||||
cw := 3000
|
||||
mcw := float64(2000)
|
||||
ch := 550 + len(danmaku.Data.Data)*int(faceH) + totalDanmuku*int(danmuH)
|
||||
canvas = gg.NewContext(cw, ch)
|
||||
canvas.SetColor(color.White)
|
||||
canvas.Clear()
|
||||
canvas.SetColor(color.Black)
|
||||
if err = canvas.LoadFontFace(text.BoldFontFile, fontSize); err != nil {
|
||||
if err = canvas.ParseFontFace(data, fontSize); err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
@@ -384,7 +386,7 @@ func init() {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
back = img.Size(back, backX, backY).Im
|
||||
back = imgfactory.Size(back, backX, backY).Image()
|
||||
}
|
||||
if back != nil {
|
||||
canvas.DrawImage(back, facestart, int(channelStart))
|
||||
@@ -520,12 +522,15 @@ func init() {
|
||||
f, err := os.Create(drawedFile)
|
||||
if err != nil {
|
||||
log.Errorln("[bilibili]", err)
|
||||
data, cl := writer.ToBytes(nim)
|
||||
data, err := imgfactory.ToBytes(nim)
|
||||
if err != nil {
|
||||
log.Errorln("[bilibili]", err)
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.ImageBytes(data))
|
||||
cl()
|
||||
return
|
||||
}
|
||||
_, err = writer.WriteTo(nim, f)
|
||||
_, err = imgfactory.WriteTo(nim, f)
|
||||
_ = f.Close()
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
@@ -175,7 +176,19 @@ func getName(buid int64) (name string, err error) {
|
||||
var ok bool
|
||||
if name, ok = upMap[buid]; !ok {
|
||||
var data []byte
|
||||
data, err = web.RequestDataWith(web.NewDefaultClient(), fmt.Sprintf(infoURL, buid), "GET", referer, ua, nil)
|
||||
data, err = web.RequestDataWithHeaders(web.NewDefaultClient(), fmt.Sprintf(infoURL, buid), "GET", func(r *http.Request) error {
|
||||
r.Header.Set("refer", referer)
|
||||
r.Header.Set("user-agent", ua)
|
||||
cookie := ""
|
||||
if cfg != nil {
|
||||
cookie, err = cfg.Load()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
r.Header.Set("cookie", cookie)
|
||||
return nil
|
||||
}, nil)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
37
plugin/dailynews/dailynews.go
Normal file
37
plugin/dailynews/dailynews.go
Normal file
@@ -0,0 +1,37 @@
|
||||
// Package dailynews 今日早报
|
||||
package dailynews
|
||||
|
||||
import (
|
||||
"github.com/FloatTech/floatbox/binary"
|
||||
"github.com/FloatTech/floatbox/web"
|
||||
ctrl "github.com/FloatTech/zbpctrl"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
"github.com/tidwall/gjson"
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
)
|
||||
|
||||
const api = "http://dwz.2xb.cn/zaob"
|
||||
|
||||
func init() {
|
||||
engine := control.Register("dailynews", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Brief: "今日早报",
|
||||
Help: "- 今日早报",
|
||||
PrivateDataFolder: "dailynews",
|
||||
})
|
||||
|
||||
engine.OnFullMatch(`今日早报`).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
data, err := web.GetData(api)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
picURL := gjson.Get(binary.BytesToString(data), "imageUrl").String()
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Image(picURL))
|
||||
})
|
||||
}
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/FloatTech/floatbox/file"
|
||||
"github.com/FloatTech/floatbox/img/writer"
|
||||
"github.com/FloatTech/imgfactory"
|
||||
ctrl "github.com/FloatTech/zbpctrl"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/ctxext"
|
||||
@@ -39,7 +39,7 @@ func init() { // 插件主体
|
||||
digest := md5.Sum(helper.StringToBytes(url))
|
||||
f := cachefolder + hex.EncodeToString(digest[:])
|
||||
if file.IsNotExist(f) {
|
||||
_ = writer.SavePNG2Path(f, t)
|
||||
_ = imgfactory.SavePNG2Path(f, t)
|
||||
}
|
||||
m := message.Message{ctxext.FakeSenderForwardNode(ctx, message.Image("file:///"+file.BOTPATH+"/"+f))}
|
||||
m = append(m, ctxext.FakeSenderForwardNode(ctx, message.Text("tags: ", strings.Join(st.tseq, ","))))
|
||||
|
||||
@@ -11,8 +11,8 @@ import (
|
||||
"github.com/FloatTech/floatbox/file"
|
||||
"github.com/FloatTech/floatbox/web"
|
||||
"github.com/FloatTech/gg"
|
||||
"github.com/FloatTech/imgfactory"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
imgutils "github.com/FloatTech/zbputils/img"
|
||||
"github.com/FloatTech/zbputils/img/text" // jpg png gif
|
||||
_ "golang.org/x/image/webp" // webp
|
||||
)
|
||||
@@ -76,11 +76,11 @@ func tagurl(name, u string) (im image.Image, st *sorttags, err error) {
|
||||
st = newsorttags(tags)
|
||||
sort.Sort(st)
|
||||
|
||||
_, err = file.GetLazyData(text.BoldFontFile, control.Md5File, true)
|
||||
boldfd, err := file.GetLazyData(text.BoldFontFile, control.Md5File, true)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
_, err = file.GetLazyData(text.ConsolasFontFile, control.Md5File, true)
|
||||
consfd, err := file.GetLazyData(text.ConsolasFontFile, control.Md5File, true)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
@@ -94,19 +94,19 @@ func tagurl(name, u string) (im image.Image, st *sorttags, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
img = imgutils.Limit(img, 1280, 720)
|
||||
img = imgfactory.Limit(img, 1280, 720)
|
||||
|
||||
canvas := gg.NewContext(img.Bounds().Size().X, img.Bounds().Size().Y+int(float64(img.Bounds().Size().X)*0.2)+len(tags)*img.Bounds().Size().X/25)
|
||||
canvas.SetRGB(1, 1, 1)
|
||||
canvas.Clear()
|
||||
canvas.DrawImage(img, 0, 0)
|
||||
if err = canvas.LoadFontFace(text.BoldFontFile, float64(img.Bounds().Size().X)*0.1); err != nil {
|
||||
if err = canvas.ParseFontFace(boldfd, float64(img.Bounds().Size().X)*0.1); err != nil {
|
||||
return
|
||||
}
|
||||
canvas.SetRGB(0, 0, 0)
|
||||
canvas.DrawString(name, float64(img.Bounds().Size().X)*0.02, float64(img.Bounds().Size().Y)+float64(img.Bounds().Size().X)*0.1)
|
||||
i := float64(img.Bounds().Size().Y) + float64(img.Bounds().Size().X)*0.2
|
||||
if err = canvas.LoadFontFace(text.ConsolasFontFile, float64(img.Bounds().Size().X)*0.04); err != nil {
|
||||
if err = canvas.ParseFontFace(consfd, float64(img.Bounds().Size().X)*0.04); err != nil {
|
||||
return
|
||||
}
|
||||
rate := float64(img.Bounds().Size().X) * 0.04
|
||||
|
||||
@@ -12,6 +12,7 @@ import (
|
||||
"strconv"
|
||||
|
||||
"github.com/FloatTech/gg" // 注册了 jpg png gif
|
||||
"github.com/FloatTech/imgfactory"
|
||||
"github.com/sirupsen/logrus"
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
@@ -19,7 +20,6 @@ import (
|
||||
|
||||
fcext "github.com/FloatTech/floatbox/ctxext"
|
||||
"github.com/FloatTech/floatbox/file"
|
||||
"github.com/FloatTech/floatbox/img/writer"
|
||||
"github.com/FloatTech/floatbox/math"
|
||||
ctrl "github.com/FloatTech/zbpctrl"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
@@ -32,8 +32,6 @@ const (
|
||||
images = "data/Fortune/"
|
||||
// 基础文件位置
|
||||
omikujson = "data/Fortune/text.json"
|
||||
// 字体文件位置
|
||||
font = "data/Font/sakura.ttf"
|
||||
// 生成图缓存位置
|
||||
cache = images + "cache/"
|
||||
)
|
||||
@@ -45,6 +43,7 @@ var (
|
||||
index = make(map[string]uint8)
|
||||
// 签文
|
||||
omikujis []map[string]string
|
||||
fontdata []byte
|
||||
)
|
||||
|
||||
func init() {
|
||||
@@ -100,10 +99,12 @@ func init() {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return false
|
||||
}
|
||||
_, err = file.GetLazyData(font, control.Md5File, true)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return false
|
||||
if fontdata == nil {
|
||||
fontdata, err = file.GetLazyData("data/Font/sakura.ttf", control.Md5File, true)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
},
|
||||
@@ -150,7 +151,7 @@ func init() {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_, err = draw(background, title, text, f)
|
||||
_, err = draw(background, fontdata, title, text, f)
|
||||
_ = f.Close()
|
||||
return err
|
||||
}, ctxext.Send(ctx), ctxext.GetMessage(ctx))
|
||||
@@ -189,19 +190,19 @@ func randimage(path string, ctx *zero.Ctx) (im image.Image, index int, err error
|
||||
// @param title 签名
|
||||
// @param text 签文
|
||||
// @return 错误信息
|
||||
func draw(back image.Image, title, txt string, f io.Writer) (int64, error) {
|
||||
func draw(back image.Image, fontdata []byte, title, txt string, f io.Writer) (int64, error) {
|
||||
canvas := gg.NewContext(back.Bounds().Size().Y, back.Bounds().Size().X)
|
||||
canvas.DrawImage(back, 0, 0)
|
||||
// 写标题
|
||||
canvas.SetRGB(1, 1, 1)
|
||||
if err := canvas.LoadFontFace(font, 45); err != nil {
|
||||
if err := canvas.ParseFontFace(fontdata, 45); err != nil {
|
||||
return -1, err
|
||||
}
|
||||
sw, _ := canvas.MeasureString(title)
|
||||
canvas.DrawString(title, 140-sw/2, 112)
|
||||
// 写正文
|
||||
canvas.SetRGB(0, 0, 0)
|
||||
if err := canvas.LoadFontFace(font, 23); err != nil {
|
||||
if err := canvas.ParseFontFace(fontdata, 23); err != nil {
|
||||
return -1, err
|
||||
}
|
||||
tw, th := canvas.MeasureString("测")
|
||||
@@ -230,7 +231,7 @@ func draw(back image.Image, title, txt string, f io.Writer) (int64, error) {
|
||||
}
|
||||
}
|
||||
}
|
||||
return writer.WriteTo(canvas.Image(), f)
|
||||
return imgfactory.WriteTo(canvas.Image(), f)
|
||||
}
|
||||
|
||||
func offest(total, now int, distance float64) float64 {
|
||||
|
||||
@@ -14,8 +14,8 @@ import (
|
||||
"sync/atomic"
|
||||
|
||||
fcext "github.com/FloatTech/floatbox/ctxext"
|
||||
"github.com/FloatTech/floatbox/img/writer"
|
||||
"github.com/FloatTech/floatbox/process"
|
||||
"github.com/FloatTech/imgfactory"
|
||||
ctrl "github.com/FloatTech/zbpctrl"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/ctxext"
|
||||
@@ -100,7 +100,11 @@ func init() {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
b, cl := writer.ToBytes(img)
|
||||
b, err := imgfactory.ToBytes(img)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
if mode {
|
||||
ctx.Send(message.ReplyWithMessage(ctx.Event.MessageID,
|
||||
message.Text("恭喜你抽到了: \n", str), message.ImageBytes(b)))
|
||||
@@ -108,7 +112,6 @@ func init() {
|
||||
ctx.Send(message.ReplyWithMessage(ctx.Event.MessageID,
|
||||
message.Text("十连成功~"), message.ImageBytes(b)))
|
||||
}
|
||||
cl()
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
|
||||
"github.com/FloatTech/floatbox/file"
|
||||
"github.com/FloatTech/floatbox/web"
|
||||
"github.com/FloatTech/zbputils/img"
|
||||
"github.com/FloatTech/imgfactory"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
@@ -97,10 +97,10 @@ func newContext(user int64) *context {
|
||||
return c
|
||||
}
|
||||
|
||||
func loadFirstFrames(paths []string, size int) (imgs []*img.Factory, err error) {
|
||||
imgs = make([]*img.Factory, size)
|
||||
func loadFirstFrames(paths []string, size int) (imgs []*imgfactory.Factory, err error) {
|
||||
imgs = make([]*imgfactory.Factory, size)
|
||||
for i := range imgs {
|
||||
imgs[i], err = img.LoadFirstFrame(paths[i], 0, 0)
|
||||
imgs[i], err = imgfactory.LoadFirstFrame(paths[i], 0, 0)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -7,10 +7,9 @@ import (
|
||||
"sync"
|
||||
|
||||
"github.com/FloatTech/floatbox/file"
|
||||
"github.com/FloatTech/floatbox/img/writer"
|
||||
"github.com/FloatTech/gg"
|
||||
"github.com/FloatTech/imgfactory"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/img"
|
||||
"github.com/FloatTech/zbputils/img/text"
|
||||
)
|
||||
|
||||
@@ -39,13 +38,13 @@ func mo(cc *context, value ...string) (string, error) {
|
||||
return "", err
|
||||
}
|
||||
mo := []*image.NRGBA{
|
||||
imgs[0].InsertBottom(tou, 80, 80, 32, 32).Im,
|
||||
imgs[1].InsertBottom(tou, 70, 90, 42, 22).Im,
|
||||
imgs[2].InsertBottom(tou, 75, 85, 37, 27).Im,
|
||||
imgs[3].InsertBottom(tou, 85, 75, 27, 37).Im,
|
||||
imgs[4].InsertBottom(tou, 90, 70, 22, 42).Im,
|
||||
imgs[0].InsertBottom(tou, 80, 80, 32, 32).Image(),
|
||||
imgs[1].InsertBottom(tou, 70, 90, 42, 22).Image(),
|
||||
imgs[2].InsertBottom(tou, 75, 85, 37, 27).Image(),
|
||||
imgs[3].InsertBottom(tou, 85, 75, 27, 37).Image(),
|
||||
imgs[4].InsertBottom(tou, 90, 70, 22, 42).Image(),
|
||||
}
|
||||
return "file:///" + name, writer.SaveGIF2Path(name, img.MergeGif(1, mo))
|
||||
return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(1, mo))
|
||||
}
|
||||
|
||||
// cuo 搓
|
||||
@@ -64,10 +63,10 @@ func cuo(cc *context, value ...string) (string, error) {
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
m1 := img.Rotate(tou, 72, 0, 0)
|
||||
m2 := img.Rotate(tou, 144, 0, 0)
|
||||
m3 := img.Rotate(tou, 216, 0, 0)
|
||||
m4 := img.Rotate(tou, 288, 0, 0)
|
||||
m1 := imgfactory.Rotate(tou, 72, 0, 0)
|
||||
m2 := imgfactory.Rotate(tou, 144, 0, 0)
|
||||
m3 := imgfactory.Rotate(tou, 216, 0, 0)
|
||||
m4 := imgfactory.Rotate(tou, 288, 0, 0)
|
||||
wg.Wait()
|
||||
if errwg != nil {
|
||||
return "", errwg
|
||||
@@ -77,13 +76,13 @@ func cuo(cc *context, value ...string) (string, error) {
|
||||
return "", err
|
||||
}
|
||||
cuo := []*image.NRGBA{
|
||||
imgs[0].InsertBottomC(tou, 0, 0, 75, 130).Im,
|
||||
imgs[1].InsertBottomC(m1.Im, 0, 0, 75, 130).Im,
|
||||
imgs[2].InsertBottomC(m2.Im, 0, 0, 75, 130).Im,
|
||||
imgs[3].InsertBottomC(m3.Im, 0, 0, 75, 130).Im,
|
||||
imgs[4].InsertBottomC(m4.Im, 0, 0, 75, 130).Im,
|
||||
imgs[0].InsertBottomC(tou, 0, 0, 75, 130).Image(),
|
||||
imgs[1].InsertBottomC(m1.Image(), 0, 0, 75, 130).Image(),
|
||||
imgs[2].InsertBottomC(m2.Image(), 0, 0, 75, 130).Image(),
|
||||
imgs[3].InsertBottomC(m3.Image(), 0, 0, 75, 130).Image(),
|
||||
imgs[4].InsertBottomC(m4.Image(), 0, 0, 75, 130).Image(),
|
||||
}
|
||||
return "file:///" + name, writer.SaveGIF2Path(name, img.MergeGif(5, cuo))
|
||||
return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(5, cuo))
|
||||
}
|
||||
|
||||
// qiao 敲
|
||||
@@ -111,10 +110,10 @@ func qiao(cc *context, value ...string) (string, error) {
|
||||
return "", err
|
||||
}
|
||||
qiao := []*image.NRGBA{
|
||||
imgs[0].InsertUp(tou, 40, 33, 57, 52).Im,
|
||||
imgs[1].InsertUp(tou, 38, 36, 58, 50).Im,
|
||||
imgs[0].InsertUp(tou, 40, 33, 57, 52).Image(),
|
||||
imgs[1].InsertUp(tou, 38, 36, 58, 50).Image(),
|
||||
}
|
||||
return "file:///" + name, writer.SaveGIF2Path(name, img.MergeGif(1, qiao))
|
||||
return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(1, qiao))
|
||||
}
|
||||
|
||||
// chi 吃
|
||||
@@ -142,11 +141,11 @@ func chi(cc *context, value ...string) (string, error) {
|
||||
return "", err
|
||||
}
|
||||
chi := []*image.NRGBA{
|
||||
imgs[0].InsertBottom(tou, 0, 0, 1, 38).Im,
|
||||
imgs[1].InsertBottom(tou, 0, 0, 1, 38).Im,
|
||||
imgs[2].InsertBottom(tou, 0, 0, 1, 38).Im,
|
||||
imgs[0].InsertBottom(tou, 0, 0, 1, 38).Image(),
|
||||
imgs[1].InsertBottom(tou, 0, 0, 1, 38).Image(),
|
||||
imgs[2].InsertBottom(tou, 0, 0, 1, 38).Image(),
|
||||
}
|
||||
return "file:///" + name, writer.SaveGIF2Path(name, img.MergeGif(1, chi))
|
||||
return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(1, chi))
|
||||
}
|
||||
|
||||
// ceng 蹭
|
||||
@@ -178,14 +177,14 @@ func ceng(cc *context, value ...string) (string, error) {
|
||||
return "", err
|
||||
}
|
||||
ceng := []*image.NRGBA{
|
||||
imgs[0].InsertUp(tou, 75, 77, 40, 88).InsertUp(tou2, 77, 103, 102, 81).Im,
|
||||
imgs[1].InsertUp(tou, 75, 77, 46, 100).InsertUp(img.Rotate(tou2, 10, 62, 127).Im, 0, 0, 92, 40).Im,
|
||||
imgs[2].InsertUp(tou, 75, 77, 67, 99).InsertUp(tou2, 76, 117, 90, 8).Im,
|
||||
imgs[3].InsertUp(tou, 75, 77, 52, 83).InsertUp(img.Rotate(tou2, -40, 94, 94).Im, 0, 0, 53, -20).Im,
|
||||
imgs[4].InsertUp(tou, 75, 77, 56, 110).InsertUp(img.Rotate(tou2, -66, 132, 80).Im, 0, 0, 78, 40).Im,
|
||||
imgs[5].InsertUp(tou, 75, 77, 62, 102).InsertUp(tou2, 71, 100, 110, 94).Im,
|
||||
imgs[0].InsertUp(tou, 75, 77, 40, 88).InsertUp(tou2, 77, 103, 102, 81).Image(),
|
||||
imgs[1].InsertUp(tou, 75, 77, 46, 100).InsertUp(imgfactory.Rotate(tou2, 10, 62, 127).Image(), 0, 0, 92, 40).Image(),
|
||||
imgs[2].InsertUp(tou, 75, 77, 67, 99).InsertUp(tou2, 76, 117, 90, 8).Image(),
|
||||
imgs[3].InsertUp(tou, 75, 77, 52, 83).InsertUp(imgfactory.Rotate(tou2, -40, 94, 94).Image(), 0, 0, 53, -20).Image(),
|
||||
imgs[4].InsertUp(tou, 75, 77, 56, 110).InsertUp(imgfactory.Rotate(tou2, -66, 132, 80).Image(), 0, 0, 78, 40).Image(),
|
||||
imgs[5].InsertUp(tou, 75, 77, 62, 102).InsertUp(tou2, 71, 100, 110, 94).Image(),
|
||||
}
|
||||
return "file:///" + name, writer.SaveGIF2Path(name, img.MergeGif(8, ceng))
|
||||
return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(8, ceng))
|
||||
}
|
||||
|
||||
// ken 啃
|
||||
@@ -213,24 +212,24 @@ func ken(cc *context, value ...string) (string, error) {
|
||||
return "", err
|
||||
}
|
||||
ken := []*image.NRGBA{
|
||||
imgs[0].InsertBottom(tou, 90, 90, 105, 150).Im,
|
||||
imgs[1].InsertBottom(tou, 90, 83, 96, 172).Im,
|
||||
imgs[2].InsertBottom(tou, 90, 90, 106, 148).Im,
|
||||
imgs[3].InsertBottom(tou, 88, 88, 97, 167).Im,
|
||||
imgs[4].InsertBottom(tou, 90, 85, 89, 179).Im,
|
||||
imgs[5].InsertBottom(tou, 90, 90, 106, 151).Im,
|
||||
imgs[6].Im,
|
||||
imgs[7].Im,
|
||||
imgs[8].Im,
|
||||
imgs[9].Im,
|
||||
imgs[10].Im,
|
||||
imgs[11].Im,
|
||||
imgs[12].Im,
|
||||
imgs[13].Im,
|
||||
imgs[14].Im,
|
||||
imgs[15].Im,
|
||||
imgs[0].InsertBottom(tou, 90, 90, 105, 150).Image(),
|
||||
imgs[1].InsertBottom(tou, 90, 83, 96, 172).Image(),
|
||||
imgs[2].InsertBottom(tou, 90, 90, 106, 148).Image(),
|
||||
imgs[3].InsertBottom(tou, 88, 88, 97, 167).Image(),
|
||||
imgs[4].InsertBottom(tou, 90, 85, 89, 179).Image(),
|
||||
imgs[5].InsertBottom(tou, 90, 90, 106, 151).Image(),
|
||||
imgs[6].Image(),
|
||||
imgs[7].Image(),
|
||||
imgs[8].Image(),
|
||||
imgs[9].Image(),
|
||||
imgs[10].Image(),
|
||||
imgs[11].Image(),
|
||||
imgs[12].Image(),
|
||||
imgs[13].Image(),
|
||||
imgs[14].Image(),
|
||||
imgs[15].Image(),
|
||||
}
|
||||
return "file:///" + name, writer.SaveGIF2Path(name, img.MergeGif(7, ken))
|
||||
return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(7, ken))
|
||||
}
|
||||
|
||||
// pai 拍
|
||||
@@ -258,10 +257,10 @@ func pai(cc *context, value ...string) (string, error) {
|
||||
return "", err
|
||||
}
|
||||
pai := []*image.NRGBA{
|
||||
imgs[0].InsertUp(tou, 0, 0, 1, 47).Im,
|
||||
imgs[1].InsertUp(tou, 0, 0, 1, 67).Im,
|
||||
imgs[0].InsertUp(tou, 0, 0, 1, 47).Image(),
|
||||
imgs[1].InsertUp(tou, 0, 0, 1, 67).Image(),
|
||||
}
|
||||
return "file:///" + name, writer.SaveGIF2Path(name, img.MergeGif(1, pai))
|
||||
return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(1, pai))
|
||||
}
|
||||
|
||||
// xqe 冲
|
||||
@@ -289,10 +288,10 @@ func xqe(cc *context, value ...string) (string, error) {
|
||||
return "", err
|
||||
}
|
||||
chong := []*image.NRGBA{
|
||||
imgs[0].InsertUp(tou, 30, 30, 15, 53).Im,
|
||||
imgs[1].InsertUp(tou, 30, 30, 40, 53).Im,
|
||||
imgs[0].InsertUp(tou, 30, 30, 15, 53).Image(),
|
||||
imgs[1].InsertUp(tou, 30, 30, 40, 53).Image(),
|
||||
}
|
||||
return "file:///" + name, writer.SaveGIF2Path(name, img.MergeGif(1, chong))
|
||||
return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(1, chong))
|
||||
}
|
||||
|
||||
// diu 丢
|
||||
@@ -320,16 +319,16 @@ func diu(cc *context, value ...string) (string, error) {
|
||||
return "", err
|
||||
}
|
||||
diu := []*image.NRGBA{
|
||||
imgs[0].InsertUp(tou, 32, 32, 108, 36).Im,
|
||||
imgs[1].InsertUp(tou, 32, 32, 122, 36).Im,
|
||||
imgs[2].Im,
|
||||
imgs[3].InsertUp(tou, 123, 123, 19, 129).Im,
|
||||
imgs[4].InsertUp(tou, 185, 185, -50, 200).InsertUp(tou, 33, 33, 289, 70).Im,
|
||||
imgs[5].InsertUp(tou, 32, 32, 280, 73).Im,
|
||||
imgs[6].InsertUp(tou, 35, 35, 259, 31).Im,
|
||||
imgs[7].InsertUp(tou, 175, 175, -50, 220).Im,
|
||||
imgs[0].InsertUp(tou, 32, 32, 108, 36).Image(),
|
||||
imgs[1].InsertUp(tou, 32, 32, 122, 36).Image(),
|
||||
imgs[2].Image(),
|
||||
imgs[3].InsertUp(tou, 123, 123, 19, 129).Image(),
|
||||
imgs[4].InsertUp(tou, 185, 185, -50, 200).InsertUp(tou, 33, 33, 289, 70).Image(),
|
||||
imgs[5].InsertUp(tou, 32, 32, 280, 73).Image(),
|
||||
imgs[6].InsertUp(tou, 35, 35, 259, 31).Image(),
|
||||
imgs[7].InsertUp(tou, 175, 175, -50, 220).Image(),
|
||||
}
|
||||
return "file:///" + name, writer.SaveGIF2Path(name, img.MergeGif(7, diu))
|
||||
return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(7, diu))
|
||||
}
|
||||
|
||||
// kiss 亲
|
||||
@@ -366,9 +365,9 @@ func kiss(cc *context, value ...string) (string, error) {
|
||||
kiss := make([]*image.NRGBA, piclen)
|
||||
for i := 0; i < piclen; i++ {
|
||||
kiss[i] = imgs[i].InsertUp(tou, 50, 50, userLocs[i][0], userLocs[i][1]).
|
||||
InsertUp(tou2, 40, 40, selfLocs[i][0], selfLocs[i][1]).Im
|
||||
InsertUp(tou2, 40, 40, selfLocs[i][0], selfLocs[i][1]).Image()
|
||||
}
|
||||
return "file:///" + name, writer.SaveGIF2Path(name, img.MergeGif(7, kiss))
|
||||
return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(7, kiss))
|
||||
}
|
||||
|
||||
// garbage 垃圾 垃圾桶
|
||||
@@ -388,7 +387,7 @@ func garbage(cc *context, value ...string) (string, error) {
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
im, err := img.LoadFirstFrame(cc.headimgsdir[0], 79, 79)
|
||||
im, err := imgfactory.LoadFirstFrame(cc.headimgsdir[0], 79, 79)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
@@ -399,9 +398,9 @@ func garbage(cc *context, value ...string) (string, error) {
|
||||
}
|
||||
garbage := make([]*image.NRGBA, piclen)
|
||||
for i := 0; i < piclen; i++ {
|
||||
garbage[i] = imgs[i].InsertBottom(im.Im, 0, 0, locs[i][0], locs[i][1]).Im
|
||||
garbage[i] = imgs[i].InsertBottom(im.Image(), 0, 0, locs[i][0], locs[i][1]).Image()
|
||||
}
|
||||
return "file:///" + name, writer.SaveGIF2Path(name, img.MergeGif(7, garbage))
|
||||
return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(7, garbage))
|
||||
}
|
||||
|
||||
// thump 捶
|
||||
@@ -421,7 +420,7 @@ func thump(cc *context, value ...string) (string, error) {
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
im, err := img.LoadFirstFrame(cc.headimgsdir[0], 0, 0)
|
||||
im, err := imgfactory.LoadFirstFrame(cc.headimgsdir[0], 0, 0)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
@@ -432,9 +431,9 @@ func thump(cc *context, value ...string) (string, error) {
|
||||
}
|
||||
thump := make([]*image.NRGBA, piclen)
|
||||
for i := 0; i < piclen; i++ {
|
||||
thump[i] = imgs[i].InsertBottom(im.Im, locs[i][2], locs[i][3], locs[i][0], locs[i][1]).Im
|
||||
thump[i] = imgs[i].InsertBottom(im.Image(), locs[i][2], locs[i][3], locs[i][0], locs[i][1]).Image()
|
||||
}
|
||||
return "file:///" + name, writer.SaveGIF2Path(name, img.MergeGif(7, thump))
|
||||
return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(7, thump))
|
||||
}
|
||||
|
||||
// jiujiu 啾啾
|
||||
@@ -454,7 +453,7 @@ func jiujiu(cc *context, value ...string) (string, error) {
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
im, err := img.LoadFirstFrame(cc.headimgsdir[0], 75, 51)
|
||||
im, err := imgfactory.LoadFirstFrame(cc.headimgsdir[0], 75, 51)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
@@ -464,9 +463,9 @@ func jiujiu(cc *context, value ...string) (string, error) {
|
||||
}
|
||||
jiujiu := make([]*image.NRGBA, piclen)
|
||||
for i := 0; i < piclen; i++ {
|
||||
jiujiu[i] = imgs[i].InsertBottom(im.Im, 0, 0, 0, 0).Im
|
||||
jiujiu[i] = imgs[i].InsertBottom(im.Image(), 0, 0, 0, 0).Image()
|
||||
}
|
||||
return "file:///" + name, writer.SaveGIF2Path(name, img.MergeGif(7, jiujiu))
|
||||
return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(7, jiujiu))
|
||||
}
|
||||
|
||||
// knock 2敲
|
||||
@@ -486,7 +485,7 @@ func knock(cc *context, value ...string) (string, error) {
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
im, err := img.LoadFirstFrame(cc.headimgsdir[0], 0, 0)
|
||||
im, err := imgfactory.LoadFirstFrame(cc.headimgsdir[0], 0, 0)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
@@ -497,9 +496,9 @@ func knock(cc *context, value ...string) (string, error) {
|
||||
}
|
||||
knock := make([]*image.NRGBA, piclen)
|
||||
for i := 0; i < piclen; i++ {
|
||||
knock[i] = imgs[i].InsertBottom(im.Im, locs[i][2], locs[i][3], locs[i][0], locs[i][1]).Im
|
||||
knock[i] = imgs[i].InsertBottom(im.Image(), locs[i][2], locs[i][3], locs[i][0], locs[i][1]).Image()
|
||||
}
|
||||
return "file:///" + name, writer.SaveGIF2Path(name, img.MergeGif(7, knock))
|
||||
return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(7, knock))
|
||||
}
|
||||
|
||||
// 听音乐 listenMusic
|
||||
@@ -529,9 +528,9 @@ func listenMusic(cc *context, value ...string) (string, error) {
|
||||
}
|
||||
listenmusic := make([]*image.NRGBA, 36)
|
||||
for i := 0; i < 36; i++ {
|
||||
listenmusic[i] = imgs[0].InsertBottomC(img.Rotate(face, float64(-i*10), 215, 215).Im, 0, 0, 207, 207).Im
|
||||
listenmusic[i] = imgs[0].InsertBottomC(imgfactory.Rotate(face, float64(-i*10), 215, 215).Image(), 0, 0, 207, 207).Image()
|
||||
}
|
||||
return "file:///" + name, writer.SaveGIF2Path(name, img.MergeGif(7, listenmusic))
|
||||
return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(7, listenmusic))
|
||||
}
|
||||
|
||||
// loveYou 永远爱你
|
||||
@@ -551,7 +550,7 @@ func loveYou(cc *context, value ...string) (string, error) {
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
im, err := img.LoadFirstFrame(cc.headimgsdir[0], 0, 0)
|
||||
im, err := imgfactory.LoadFirstFrame(cc.headimgsdir[0], 0, 0)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
@@ -562,9 +561,9 @@ func loveYou(cc *context, value ...string) (string, error) {
|
||||
}
|
||||
loveyou := make([]*image.NRGBA, piclen)
|
||||
for i := 0; i < piclen; i++ {
|
||||
loveyou[i] = imgs[i].InsertBottom(im.Im, locs[i][2], locs[i][3], locs[i][0], locs[i][1]).Im
|
||||
loveyou[i] = imgs[i].InsertBottom(im.Image(), locs[i][2], locs[i][3], locs[i][0], locs[i][1]).Image()
|
||||
}
|
||||
return "file:///" + name, writer.SaveGIF2Path(name, img.MergeGif(7, loveyou))
|
||||
return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(7, loveyou))
|
||||
}
|
||||
|
||||
// pat 2拍
|
||||
@@ -584,7 +583,7 @@ func pat(cc *context, value ...string) (string, error) {
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
im, err := img.LoadFirstFrame(cc.headimgsdir[0], 0, 0)
|
||||
im, err := imgfactory.LoadFirstFrame(cc.headimgsdir[0], 0, 0)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
@@ -596,9 +595,9 @@ func pat(cc *context, value ...string) (string, error) {
|
||||
p := make([]*image.NRGBA, piclen)
|
||||
for i := 0; i < piclen; i++ {
|
||||
if i == 2 {
|
||||
p[i] = imgs[i].InsertBottom(im.Im, locs[1][2], locs[1][3], locs[1][0], locs[1][1]).Im
|
||||
p[i] = imgs[i].InsertBottom(im.Image(), locs[1][2], locs[1][3], locs[1][0], locs[1][1]).Image()
|
||||
} else {
|
||||
p[i] = imgs[i].InsertBottom(im.Im, locs[0][2], locs[0][3], locs[0][0], locs[0][1]).Im
|
||||
p[i] = imgs[i].InsertBottom(im.Image(), locs[0][2], locs[0][3], locs[0][0], locs[0][1]).Image()
|
||||
}
|
||||
}
|
||||
seq := []int{0, 1, 2, 3, 1, 2, 3, 0, 1, 2, 3, 0, 0, 1, 2, 3, 0, 0, 0, 0, 4, 5, 5, 5, 6, 7, 8, 9}
|
||||
@@ -606,7 +605,7 @@ func pat(cc *context, value ...string) (string, error) {
|
||||
for i := 0; i < len(pat); i++ {
|
||||
pat[i] = p[seq[i]]
|
||||
}
|
||||
return "file:///" + name, writer.SaveGIF2Path(name, img.MergeGif(7, pat))
|
||||
return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(7, pat))
|
||||
}
|
||||
|
||||
// jackUp 顶
|
||||
@@ -626,7 +625,7 @@ func jackUp(cc *context, value ...string) (string, error) {
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
im, err := img.LoadFirstFrame(cc.headimgsdir[0], 0, 0)
|
||||
im, err := imgfactory.LoadFirstFrame(cc.headimgsdir[0], 0, 0)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
@@ -638,9 +637,9 @@ func jackUp(cc *context, value ...string) (string, error) {
|
||||
p := make([]*image.NRGBA, piclen)
|
||||
for i := 0; i < piclen; i++ {
|
||||
if i < len(locs) {
|
||||
p[i] = imgs[i].InsertBottom(im.Im, locs[i][2], locs[i][3], locs[i][0], locs[i][1]).Im
|
||||
p[i] = imgs[i].InsertBottom(im.Image(), locs[i][2], locs[i][3], locs[i][0], locs[i][1]).Image()
|
||||
} else {
|
||||
p[i] = imgs[i].Im
|
||||
p[i] = imgs[i].Image()
|
||||
}
|
||||
}
|
||||
play := make([]*image.NRGBA, 0, 16)
|
||||
@@ -649,7 +648,7 @@ func jackUp(cc *context, value ...string) (string, error) {
|
||||
play = append(play, p[0:8]...)
|
||||
play = append(play, p[12:18]...)
|
||||
play = append(play, p[18:23]...)
|
||||
return "file:///" + name, writer.SaveGIF2Path(name, img.MergeGif(7, play))
|
||||
return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(7, play))
|
||||
}
|
||||
|
||||
// pound 捣
|
||||
@@ -669,7 +668,7 @@ func pound(cc *context, value ...string) (string, error) {
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
im, err := img.LoadFirstFrame(cc.headimgsdir[0], 0, 0)
|
||||
im, err := imgfactory.LoadFirstFrame(cc.headimgsdir[0], 0, 0)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
@@ -680,9 +679,9 @@ func pound(cc *context, value ...string) (string, error) {
|
||||
}
|
||||
pound := make([]*image.NRGBA, piclen)
|
||||
for i := 0; i < piclen; i++ {
|
||||
pound[i] = imgs[i].InsertBottom(im.Im, locs[i][2], locs[i][3], locs[i][0], locs[i][1]).Im
|
||||
pound[i] = imgs[i].InsertBottom(im.Image(), locs[i][2], locs[i][3], locs[i][0], locs[i][1]).Image()
|
||||
}
|
||||
return "file:///" + name, writer.SaveGIF2Path(name, img.MergeGif(7, pound))
|
||||
return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(7, pound))
|
||||
}
|
||||
|
||||
// punch 打拳
|
||||
@@ -702,7 +701,7 @@ func punch(cc *context, value ...string) (string, error) {
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
im, err := img.LoadFirstFrame(cc.headimgsdir[0], 260, 260)
|
||||
im, err := imgfactory.LoadFirstFrame(cc.headimgsdir[0], 260, 260)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
@@ -713,9 +712,9 @@ func punch(cc *context, value ...string) (string, error) {
|
||||
}
|
||||
punch := make([]*image.NRGBA, piclen)
|
||||
for i := 0; i < piclen; i++ {
|
||||
punch[i] = imgs[i].InsertBottom(im.Im, 0, 0, locs[i][0], locs[i][1]-15).Im
|
||||
punch[i] = imgs[i].InsertBottom(im.Image(), 0, 0, locs[i][0], locs[i][1]-15).Image()
|
||||
}
|
||||
return "file:///" + name, writer.SaveGIF2Path(name, img.MergeGif(7, punch))
|
||||
return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(7, punch))
|
||||
}
|
||||
|
||||
// roll 滚
|
||||
@@ -735,7 +734,7 @@ func roll(cc *context, value ...string) (string, error) {
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
im, err := img.LoadFirstFrame(cc.headimgsdir[0], 210, 210)
|
||||
im, err := imgfactory.LoadFirstFrame(cc.headimgsdir[0], 210, 210)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
@@ -746,9 +745,9 @@ func roll(cc *context, value ...string) (string, error) {
|
||||
}
|
||||
roll := make([]*image.NRGBA, piclen)
|
||||
for i := 0; i < piclen; i++ {
|
||||
roll[i] = imgs[i].InsertBottomC(img.Rotate(im.Im, float64(locs[i][2]), 0, 0).Im, 0, 0, locs[i][0]+105, locs[i][1]+105).Im
|
||||
roll[i] = imgs[i].InsertBottomC(imgfactory.Rotate(im.Image(), float64(locs[i][2]), 0, 0).Image(), 0, 0, locs[i][0]+105, locs[i][1]+105).Image()
|
||||
}
|
||||
return "file:///" + name, writer.SaveGIF2Path(name, img.MergeGif(7, roll))
|
||||
return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(7, roll))
|
||||
}
|
||||
|
||||
// suck 吸 嗦
|
||||
@@ -768,7 +767,7 @@ func suck(cc *context, value ...string) (string, error) {
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
im, err := img.LoadFirstFrame(cc.headimgsdir[0], 0, 0)
|
||||
im, err := imgfactory.LoadFirstFrame(cc.headimgsdir[0], 0, 0)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
@@ -779,9 +778,9 @@ func suck(cc *context, value ...string) (string, error) {
|
||||
}
|
||||
suck := make([]*image.NRGBA, piclen)
|
||||
for i := 0; i < piclen; i++ {
|
||||
suck[i] = imgs[i].InsertBottom(im.Im, locs[i][2], locs[i][3], locs[i][0], locs[i][1]).Im
|
||||
suck[i] = imgs[i].InsertBottom(im.Image(), locs[i][2], locs[i][3], locs[i][0], locs[i][1]).Image()
|
||||
}
|
||||
return "file:///" + name, writer.SaveGIF2Path(name, img.MergeGif(7, suck))
|
||||
return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(7, suck))
|
||||
}
|
||||
|
||||
// hammer 锤
|
||||
@@ -801,7 +800,7 @@ func hammer(cc *context, value ...string) (string, error) {
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
im, err := img.LoadFirstFrame(cc.headimgsdir[0], 0, 0)
|
||||
im, err := imgfactory.LoadFirstFrame(cc.headimgsdir[0], 0, 0)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
@@ -812,9 +811,9 @@ func hammer(cc *context, value ...string) (string, error) {
|
||||
}
|
||||
hammer := make([]*image.NRGBA, piclen)
|
||||
for i := 0; i < piclen; i++ {
|
||||
hammer[i] = imgs[i].InsertBottom(im.Im, locs[i][2], locs[i][3], locs[i][0], locs[i][1]).Im
|
||||
hammer[i] = imgs[i].InsertBottom(im.Image(), locs[i][2], locs[i][3], locs[i][0], locs[i][1]).Image()
|
||||
}
|
||||
return "file:///" + name, writer.SaveGIF2Path(name, img.MergeGif(7, hammer))
|
||||
return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(7, hammer))
|
||||
}
|
||||
|
||||
// tightly 紧贴 紧紧贴着
|
||||
@@ -834,7 +833,7 @@ func tightly(cc *context, value ...string) (string, error) {
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
im, err := img.LoadFirstFrame(cc.headimgsdir[0], 0, 0)
|
||||
im, err := imgfactory.LoadFirstFrame(cc.headimgsdir[0], 0, 0)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
@@ -845,9 +844,9 @@ func tightly(cc *context, value ...string) (string, error) {
|
||||
}
|
||||
tightly := make([]*image.NRGBA, piclen)
|
||||
for i := 0; i < piclen; i++ {
|
||||
tightly[i] = imgs[i].InsertBottom(im.Im, locs[i][2], locs[i][3], locs[i][0], locs[i][1]).Im
|
||||
tightly[i] = imgs[i].InsertBottom(im.Image(), locs[i][2], locs[i][3], locs[i][0], locs[i][1]).Image()
|
||||
}
|
||||
return "file:///" + name, writer.SaveGIF2Path(name, img.MergeGif(7, tightly))
|
||||
return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(7, tightly))
|
||||
}
|
||||
|
||||
// turn 转
|
||||
@@ -864,9 +863,9 @@ func turn(cc *context, value ...string) (string, error) {
|
||||
canvas.Fill()
|
||||
turn := make([]*image.NRGBA, 36)
|
||||
for i := 0; i < 36; i++ {
|
||||
turn[i] = img.Size(canvas.Image(), 0, 0).InsertUpC(img.Rotate(face, float64(10*i), 250, 250).Im, 0, 0, 125, 125).Im
|
||||
turn[i] = imgfactory.Size(canvas.Image(), 0, 0).InsertUpC(imgfactory.Rotate(face, float64(10*i), 250, 250).Image(), 0, 0, 125, 125).Image()
|
||||
}
|
||||
return "file:///" + name, writer.SaveGIF2Path(name, img.MergeGif(7, turn))
|
||||
return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(7, turn))
|
||||
}
|
||||
|
||||
// taiguan 抬棺
|
||||
@@ -894,28 +893,28 @@ func taiguan(cc *context, value ...string) (string, error) {
|
||||
return "", err
|
||||
}
|
||||
taiguan := []*image.NRGBA{
|
||||
imgs[0].InsertUp(tou, 85, 85, 180, 65).Im,
|
||||
imgs[1].InsertUp(tou, 85, 85, 180, 65).Im,
|
||||
imgs[2].InsertUp(tou, 85, 85, 180, 65).Im,
|
||||
imgs[3].InsertUp(tou, 85, 85, 180, 65).Im,
|
||||
imgs[4].InsertUp(tou, 85, 85, 177, 65).Im,
|
||||
imgs[5].InsertUp(tou, 85, 85, 175, 65).Im,
|
||||
imgs[6].InsertUp(tou, 85, 85, 173, 65).Im,
|
||||
imgs[7].InsertUp(tou, 85, 85, 171, 65).Im,
|
||||
imgs[8].InsertUp(tou, 85, 85, 170, 65).Im,
|
||||
imgs[9].InsertUp(tou, 85, 85, 170, 65).Im,
|
||||
imgs[10].InsertUp(tou, 85, 85, 170, 65).Im,
|
||||
imgs[11].InsertUp(tou, 85, 85, 170, 65).Im,
|
||||
imgs[12].InsertUp(tou, 85, 85, 170, 65).Im,
|
||||
imgs[13].InsertUp(tou, 85, 85, 170, 65).Im,
|
||||
imgs[14].InsertUp(tou, 85, 85, 170, 65).Im,
|
||||
imgs[15].InsertUp(tou, 85, 85, 170, 65).Im,
|
||||
imgs[16].InsertUp(tou, 85, 85, 170, 65).Im,
|
||||
imgs[17].InsertUp(tou, 85, 85, 170, 65).Im,
|
||||
imgs[18].InsertUp(tou, 85, 85, 170, 65).Im,
|
||||
imgs[19].InsertUp(tou, 85, 85, 175, 65).Im,
|
||||
imgs[0].InsertUp(tou, 85, 85, 180, 65).Image(),
|
||||
imgs[1].InsertUp(tou, 85, 85, 180, 65).Image(),
|
||||
imgs[2].InsertUp(tou, 85, 85, 180, 65).Image(),
|
||||
imgs[3].InsertUp(tou, 85, 85, 180, 65).Image(),
|
||||
imgs[4].InsertUp(tou, 85, 85, 177, 65).Image(),
|
||||
imgs[5].InsertUp(tou, 85, 85, 175, 65).Image(),
|
||||
imgs[6].InsertUp(tou, 85, 85, 173, 65).Image(),
|
||||
imgs[7].InsertUp(tou, 85, 85, 171, 65).Image(),
|
||||
imgs[8].InsertUp(tou, 85, 85, 170, 65).Image(),
|
||||
imgs[9].InsertUp(tou, 85, 85, 170, 65).Image(),
|
||||
imgs[10].InsertUp(tou, 85, 85, 170, 65).Image(),
|
||||
imgs[11].InsertUp(tou, 85, 85, 170, 65).Image(),
|
||||
imgs[12].InsertUp(tou, 85, 85, 170, 65).Image(),
|
||||
imgs[13].InsertUp(tou, 85, 85, 170, 65).Image(),
|
||||
imgs[14].InsertUp(tou, 85, 85, 170, 65).Image(),
|
||||
imgs[15].InsertUp(tou, 85, 85, 170, 65).Image(),
|
||||
imgs[16].InsertUp(tou, 85, 85, 170, 65).Image(),
|
||||
imgs[17].InsertUp(tou, 85, 85, 170, 65).Image(),
|
||||
imgs[18].InsertUp(tou, 85, 85, 170, 65).Image(),
|
||||
imgs[19].InsertUp(tou, 85, 85, 175, 65).Image(),
|
||||
}
|
||||
return "file:///" + name, writer.SaveGIF2Path(name, img.MergeGif(7, taiguan))
|
||||
return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(7, taiguan))
|
||||
}
|
||||
|
||||
// zou 揍
|
||||
@@ -947,11 +946,11 @@ func zou(cc *context, value ...string) (string, error) {
|
||||
return "", err
|
||||
}
|
||||
zou := []*image.NRGBA{
|
||||
imgs[0].InsertUp(tou, 40, 40, 98, 138).InsertUp(tou2, 55, 55, 100, 45).Im,
|
||||
imgs[1].InsertUp(tou, 40, 40, 98, 138).InsertUp(tou2, 55, 55, 101, 45).Im,
|
||||
imgs[2].InsertUp(tou, 40, 40, 89, 140).InsertUp(tou2, 55, 55, 99, 40).Im,
|
||||
imgs[0].InsertUp(tou, 40, 40, 98, 138).InsertUp(tou2, 55, 55, 100, 45).Image(),
|
||||
imgs[1].InsertUp(tou, 40, 40, 98, 138).InsertUp(tou2, 55, 55, 101, 45).Image(),
|
||||
imgs[2].InsertUp(tou, 40, 40, 89, 140).InsertUp(tou2, 55, 55, 99, 40).Image(),
|
||||
}
|
||||
return "file:///" + name, writer.SaveGIF2Path(name, img.MergeGif(8, zou))
|
||||
return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(8, zou))
|
||||
}
|
||||
|
||||
// ci 吞
|
||||
@@ -979,34 +978,34 @@ func ci(cc *context, value ...string) (string, error) {
|
||||
return "", err
|
||||
}
|
||||
ci := []*image.NRGBA{
|
||||
imgs[0].InsertBottom(tou, 25, 25, 25, 57).Im,
|
||||
imgs[1].InsertBottom(tou, 25, 25, 27, 58).Im,
|
||||
imgs[2].InsertBottom(tou, 25, 25, 28, 57).Im,
|
||||
imgs[3].InsertBottom(tou, 25, 25, 30, 57).Im,
|
||||
imgs[4].InsertBottom(tou, 25, 25, 30, 58).Im,
|
||||
imgs[5].InsertBottom(tou, 25, 25, 30, 59).Im,
|
||||
imgs[6].Im,
|
||||
imgs[7].Im,
|
||||
imgs[8].Im,
|
||||
imgs[9].Im,
|
||||
imgs[10].Im,
|
||||
imgs[11].Im,
|
||||
imgs[12].Im,
|
||||
imgs[13].Im,
|
||||
imgs[14].Im,
|
||||
imgs[15].Im,
|
||||
imgs[16].Im,
|
||||
imgs[17].Im,
|
||||
imgs[18].Im,
|
||||
imgs[19].Im,
|
||||
imgs[20].Im,
|
||||
imgs[21].Im,
|
||||
imgs[22].Im,
|
||||
imgs[23].Im,
|
||||
imgs[24].Im,
|
||||
imgs[25].Im,
|
||||
imgs[0].InsertBottom(tou, 25, 25, 25, 57).Image(),
|
||||
imgs[1].InsertBottom(tou, 25, 25, 27, 58).Image(),
|
||||
imgs[2].InsertBottom(tou, 25, 25, 28, 57).Image(),
|
||||
imgs[3].InsertBottom(tou, 25, 25, 30, 57).Image(),
|
||||
imgs[4].InsertBottom(tou, 25, 25, 30, 58).Image(),
|
||||
imgs[5].InsertBottom(tou, 25, 25, 30, 59).Image(),
|
||||
imgs[6].Image(),
|
||||
imgs[7].Image(),
|
||||
imgs[8].Image(),
|
||||
imgs[9].Image(),
|
||||
imgs[10].Image(),
|
||||
imgs[11].Image(),
|
||||
imgs[12].Image(),
|
||||
imgs[13].Image(),
|
||||
imgs[14].Image(),
|
||||
imgs[15].Image(),
|
||||
imgs[16].Image(),
|
||||
imgs[17].Image(),
|
||||
imgs[18].Image(),
|
||||
imgs[19].Image(),
|
||||
imgs[20].Image(),
|
||||
imgs[21].Image(),
|
||||
imgs[22].Image(),
|
||||
imgs[23].Image(),
|
||||
imgs[24].Image(),
|
||||
imgs[25].Image(),
|
||||
}
|
||||
return "file:///" + name, writer.SaveGIF2Path(name, img.MergeGif(7, ci))
|
||||
return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(7, ci))
|
||||
}
|
||||
|
||||
// worship 膜拜
|
||||
@@ -1034,17 +1033,17 @@ func worship(cc *context, value ...string) (string, error) {
|
||||
return "", err
|
||||
}
|
||||
worship := []*image.NRGBA{
|
||||
imgs[0].InsertBottom(face, 140, 140, 0, 0).Im,
|
||||
imgs[1].InsertBottom(face, 140, 140, 0, 0).Im,
|
||||
imgs[2].InsertBottom(face, 140, 140, 0, 0).Im,
|
||||
imgs[3].InsertBottom(face, 140, 140, 0, 0).Im,
|
||||
imgs[4].InsertBottom(face, 140, 140, 0, 0).Im,
|
||||
imgs[5].InsertBottom(face, 140, 140, 0, 0).Im,
|
||||
imgs[6].InsertBottom(face, 140, 140, 0, 0).Im,
|
||||
imgs[7].InsertBottom(face, 140, 140, 0, 0).Im,
|
||||
imgs[8].InsertBottom(face, 140, 140, 0, 0).Im,
|
||||
imgs[0].InsertBottom(face, 140, 140, 0, 0).Image(),
|
||||
imgs[1].InsertBottom(face, 140, 140, 0, 0).Image(),
|
||||
imgs[2].InsertBottom(face, 140, 140, 0, 0).Image(),
|
||||
imgs[3].InsertBottom(face, 140, 140, 0, 0).Image(),
|
||||
imgs[4].InsertBottom(face, 140, 140, 0, 0).Image(),
|
||||
imgs[5].InsertBottom(face, 140, 140, 0, 0).Image(),
|
||||
imgs[6].InsertBottom(face, 140, 140, 0, 0).Image(),
|
||||
imgs[7].InsertBottom(face, 140, 140, 0, 0).Image(),
|
||||
imgs[8].InsertBottom(face, 140, 140, 0, 0).Image(),
|
||||
}
|
||||
return "file:///" + name, writer.SaveGIF2Path(name, img.MergeGif(7, worship))
|
||||
return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(7, worship))
|
||||
}
|
||||
|
||||
// 2ceng 2蹭
|
||||
@@ -1072,12 +1071,12 @@ func ceng2(cc *context, value ...string) (string, error) {
|
||||
return "", err
|
||||
}
|
||||
ceng2 := []*image.NRGBA{
|
||||
imgs[0].InsertBottom(tou, 175, 175, 78, 263).Im,
|
||||
imgs[1].InsertBottom(tou, 175, 175, 78, 263).Im,
|
||||
imgs[2].InsertBottom(tou, 175, 175, 78, 263).Im,
|
||||
imgs[3].InsertBottom(tou, 175, 175, 78, 263).Im,
|
||||
imgs[0].InsertBottom(tou, 175, 175, 78, 263).Image(),
|
||||
imgs[1].InsertBottom(tou, 175, 175, 78, 263).Image(),
|
||||
imgs[2].InsertBottom(tou, 175, 175, 78, 263).Image(),
|
||||
imgs[3].InsertBottom(tou, 175, 175, 78, 263).Image(),
|
||||
}
|
||||
return "file:///" + name, writer.SaveGIF2Path(name, img.MergeGif(7, ceng2))
|
||||
return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(7, ceng2))
|
||||
}
|
||||
|
||||
// dun 炖
|
||||
@@ -1105,13 +1104,13 @@ func dun(cc *context, value ...string) (string, error) {
|
||||
return "", err
|
||||
}
|
||||
dun := []*image.NRGBA{
|
||||
imgs[0].InsertBottom(tou, 80, 80, 85, 45).Im,
|
||||
imgs[1].InsertBottom(tou, 80, 80, 85, 45).Im,
|
||||
imgs[2].InsertBottom(tou, 80, 80, 85, 45).Im,
|
||||
imgs[3].InsertBottom(tou, 80, 80, 85, 45).Im,
|
||||
imgs[4].InsertBottom(tou, 80, 80, 85, 45).Im,
|
||||
imgs[0].InsertBottom(tou, 80, 80, 85, 45).Image(),
|
||||
imgs[1].InsertBottom(tou, 80, 80, 85, 45).Image(),
|
||||
imgs[2].InsertBottom(tou, 80, 80, 85, 45).Image(),
|
||||
imgs[3].InsertBottom(tou, 80, 80, 85, 45).Image(),
|
||||
imgs[4].InsertBottom(tou, 80, 80, 85, 45).Image(),
|
||||
}
|
||||
return "file:///" + name, writer.SaveGIF2Path(name, img.MergeGif(7, dun))
|
||||
return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(7, dun))
|
||||
}
|
||||
|
||||
// push 滚高清重置版 过渡
|
||||
@@ -1141,9 +1140,9 @@ func push(cc *context, value ...string) (string, error) {
|
||||
}
|
||||
push := make([]*image.NRGBA, piclen)
|
||||
for i := 0; i < piclen; i++ {
|
||||
push[i] = imgs[i].InsertUpC(img.Rotate(tou, float64(-22*i), 280, 280).Im, 0, 0, 523, 291).Im
|
||||
push[i] = imgs[i].InsertUpC(imgfactory.Rotate(tou, float64(-22*i), 280, 280).Image(), 0, 0, 523, 291).Image()
|
||||
}
|
||||
return "file:///" + name, writer.SaveGIF2Path(name, img.MergeGif(7, push))
|
||||
return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(7, push))
|
||||
}
|
||||
|
||||
// peng 砰
|
||||
@@ -1162,10 +1161,10 @@ func peng(cc *context, value ...string) (string, error) {
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
m1 := img.Rotate(tou, 1, 80, 80)
|
||||
m2 := img.Rotate(tou, 30, 80, 80)
|
||||
m3 := img.Rotate(tou, 45, 85, 85)
|
||||
m4 := img.Rotate(tou, 90, 80, 80)
|
||||
m1 := imgfactory.Rotate(tou, 1, 80, 80)
|
||||
m2 := imgfactory.Rotate(tou, 30, 80, 80)
|
||||
m3 := imgfactory.Rotate(tou, 45, 85, 85)
|
||||
m4 := imgfactory.Rotate(tou, 90, 80, 80)
|
||||
wg.Wait()
|
||||
if errwg != nil {
|
||||
return "", errwg
|
||||
@@ -1175,33 +1174,33 @@ func peng(cc *context, value ...string) (string, error) {
|
||||
return "", err
|
||||
}
|
||||
peng := []*image.NRGBA{
|
||||
imgs[0].Im,
|
||||
imgs[1].Im,
|
||||
imgs[2].Im,
|
||||
imgs[3].Im,
|
||||
imgs[4].Im,
|
||||
imgs[5].Im,
|
||||
imgs[6].Im,
|
||||
imgs[7].InsertUp(m1.Im, 0, 0, 205, 80).Im,
|
||||
imgs[8].InsertUp(m1.Im, 0, 0, 205, 80).Im,
|
||||
imgs[9].InsertUp(m1.Im, 0, 0, 205, 80).Im,
|
||||
imgs[10].InsertUp(m1.Im, 0, 0, 205, 80).Im,
|
||||
imgs[11].InsertUp(m1.Im, 0, 0, 205, 80).Im,
|
||||
imgs[12].InsertUp(m1.Im, 0, 0, 205, 80).Im,
|
||||
imgs[13].InsertUp(m1.Im, 0, 0, 205, 80).Im,
|
||||
imgs[14].InsertUp(m1.Im, 0, 0, 205, 80).Im,
|
||||
imgs[15].InsertUp(m1.Im, 0, 0, 205, 80).Im,
|
||||
imgs[16].InsertUp(m1.Im, 0, 0, 200, 80).Im,
|
||||
imgs[17].InsertUp(m2.Im, 0, 0, 169, 65).Im,
|
||||
imgs[18].InsertUp(m2.Im, 0, 0, 160, 69).Im,
|
||||
imgs[19].InsertUp(m3.Im, 0, 0, 113, 90).Im,
|
||||
imgs[20].InsertUp(m4.Im, 0, 0, 89, 159).Im,
|
||||
imgs[21].InsertUp(m4.Im, 0, 0, 89, 159).Im,
|
||||
imgs[22].InsertUp(m4.Im, 0, 0, 86, 160).Im,
|
||||
imgs[23].InsertUp(m4.Im, 0, 0, 89, 159).Im,
|
||||
imgs[24].InsertUp(m4.Im, 0, 0, 86, 160).Im,
|
||||
imgs[0].Image(),
|
||||
imgs[1].Image(),
|
||||
imgs[2].Image(),
|
||||
imgs[3].Image(),
|
||||
imgs[4].Image(),
|
||||
imgs[5].Image(),
|
||||
imgs[6].Image(),
|
||||
imgs[7].InsertUp(m1.Image(), 0, 0, 205, 80).Image(),
|
||||
imgs[8].InsertUp(m1.Image(), 0, 0, 205, 80).Image(),
|
||||
imgs[9].InsertUp(m1.Image(), 0, 0, 205, 80).Image(),
|
||||
imgs[10].InsertUp(m1.Image(), 0, 0, 205, 80).Image(),
|
||||
imgs[11].InsertUp(m1.Image(), 0, 0, 205, 80).Image(),
|
||||
imgs[12].InsertUp(m1.Image(), 0, 0, 205, 80).Image(),
|
||||
imgs[13].InsertUp(m1.Image(), 0, 0, 205, 80).Image(),
|
||||
imgs[14].InsertUp(m1.Image(), 0, 0, 205, 80).Image(),
|
||||
imgs[15].InsertUp(m1.Image(), 0, 0, 205, 80).Image(),
|
||||
imgs[16].InsertUp(m1.Image(), 0, 0, 200, 80).Image(),
|
||||
imgs[17].InsertUp(m2.Image(), 0, 0, 169, 65).Image(),
|
||||
imgs[18].InsertUp(m2.Image(), 0, 0, 160, 69).Image(),
|
||||
imgs[19].InsertUp(m3.Image(), 0, 0, 113, 90).Image(),
|
||||
imgs[20].InsertUp(m4.Image(), 0, 0, 89, 159).Image(),
|
||||
imgs[21].InsertUp(m4.Image(), 0, 0, 89, 159).Image(),
|
||||
imgs[22].InsertUp(m4.Image(), 0, 0, 86, 160).Image(),
|
||||
imgs[23].InsertUp(m4.Image(), 0, 0, 89, 159).Image(),
|
||||
imgs[24].InsertUp(m4.Image(), 0, 0, 86, 160).Image(),
|
||||
}
|
||||
return "file:///" + name, writer.SaveGIF2Path(name, img.MergeGif(8, peng))
|
||||
return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(8, peng))
|
||||
}
|
||||
|
||||
// klee 可莉吃
|
||||
@@ -1221,7 +1220,7 @@ func klee(cc *context, value ...string) (string, error) {
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
im, err := img.LoadFirstFrame(cc.headimgsdir[0], 82, 83)
|
||||
im, err := imgfactory.LoadFirstFrame(cc.headimgsdir[0], 82, 83)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
@@ -1232,9 +1231,9 @@ func klee(cc *context, value ...string) (string, error) {
|
||||
}
|
||||
klee := make([]*image.NRGBA, piclen)
|
||||
for i := 0; i < piclen; i++ {
|
||||
klee[i] = imgs[i].InsertBottom(im.Im, 0, 0, locs[i][0], locs[i][1]).Im
|
||||
klee[i] = imgs[i].InsertBottom(im.Image(), 0, 0, locs[i][0], locs[i][1]).Image()
|
||||
}
|
||||
return "file:///" + name, writer.SaveGIF2Path(name, img.MergeGif(7, klee))
|
||||
return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(7, klee))
|
||||
}
|
||||
|
||||
// hutaoken 胡桃啃
|
||||
@@ -1262,10 +1261,10 @@ func hutaoken(cc *context, value ...string) (string, error) {
|
||||
return "", err
|
||||
}
|
||||
hutaoken := []*image.NRGBA{
|
||||
imgs[0].InsertBottom(tou, 98, 101, 108, 234).Im,
|
||||
imgs[1].InsertBottom(tou, 96, 100, 108, 237).Im,
|
||||
imgs[0].InsertBottom(tou, 98, 101, 108, 234).Image(),
|
||||
imgs[1].InsertBottom(tou, 96, 100, 108, 237).Image(),
|
||||
}
|
||||
return "file:///" + name, writer.SaveGIF2Path(name, img.MergeGif(8, hutaoken))
|
||||
return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(8, hutaoken))
|
||||
}
|
||||
|
||||
// lick 2舔
|
||||
@@ -1293,10 +1292,10 @@ func lick(cc *context, value ...string) (string, error) {
|
||||
return "", err
|
||||
}
|
||||
lick := []*image.NRGBA{
|
||||
imgs[0].InsertUp(tou, 44, 44, 10, 138).Im,
|
||||
imgs[1].InsertUp(tou, 44, 44, 10, 138).Im,
|
||||
imgs[0].InsertUp(tou, 44, 44, 10, 138).Image(),
|
||||
imgs[1].InsertUp(tou, 44, 44, 10, 138).Image(),
|
||||
}
|
||||
return "file:///" + name, writer.SaveGIF2Path(name, img.MergeGif(8, lick))
|
||||
return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(8, lick))
|
||||
}
|
||||
|
||||
// tiqiu 踢球
|
||||
@@ -1327,9 +1326,9 @@ func tiqiu(cc *context, value ...string) (string, error) {
|
||||
}
|
||||
tiqiu := make([]*image.NRGBA, piclen)
|
||||
for i := 0; i < piclen; i++ {
|
||||
tiqiu[i] = imgs[i].InsertUpC(img.Rotate(tou, float64(-24*i), 0, 0).Im, 0, 0, locs[i][0]+38, locs[i][1]+38).Im
|
||||
tiqiu[i] = imgs[i].InsertUpC(imgfactory.Rotate(tou, float64(-24*i), 0, 0).Image(), 0, 0, locs[i][0]+38, locs[i][1]+38).Image()
|
||||
}
|
||||
return "file:///" + name, writer.SaveGIF2Path(name, img.MergeGif(7, tiqiu))
|
||||
return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(7, tiqiu))
|
||||
}
|
||||
|
||||
// cai 踩
|
||||
@@ -1356,15 +1355,15 @@ func cai(cc *context, value ...string) (string, error) {
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
m1 := img.Rotate(tou, -20, 130, 80)
|
||||
m1 := imgfactory.Rotate(tou, -20, 130, 80)
|
||||
cai := []*image.NRGBA{
|
||||
imgs[0].InsertBottom(m1.Im, 123, 105, 39, 188).Im,
|
||||
imgs[1].InsertBottom(m1.Im, 123, 105, 39, 188).Im,
|
||||
imgs[2].InsertBottom(tou, 90, 71, 50, 209).Im,
|
||||
imgs[3].InsertBottom(tou, 85, 76, 52, 203).Im,
|
||||
imgs[4].InsertBottom(tou, 88, 82, 49, 198).Im,
|
||||
imgs[0].InsertBottom(m1.Image(), 123, 105, 39, 188).Image(),
|
||||
imgs[1].InsertBottom(m1.Image(), 123, 105, 39, 188).Image(),
|
||||
imgs[2].InsertBottom(tou, 90, 71, 50, 209).Image(),
|
||||
imgs[3].InsertBottom(tou, 85, 76, 52, 203).Image(),
|
||||
imgs[4].InsertBottom(tou, 88, 82, 49, 198).Image(),
|
||||
}
|
||||
return "file:///" + name, writer.SaveGIF2Path(name, img.MergeGif(7, cai))
|
||||
return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(7, cai))
|
||||
}
|
||||
|
||||
// whir 2转
|
||||
@@ -1394,34 +1393,34 @@ func whirl(cc *context, value ...string) (string, error) {
|
||||
}
|
||||
whirl := make([]*image.NRGBA, piclen)
|
||||
for i := 0; i < piclen; i++ {
|
||||
whirl[i] = imgs[i].InsertUpC(img.Rotate(tou, float64(-24*i), 145, 145).Im, 0, 0, 115, 89).Im
|
||||
whirl[i] = imgs[i].InsertUpC(imgfactory.Rotate(tou, float64(-24*i), 145, 145).Image(), 0, 0, 115, 89).Image()
|
||||
}
|
||||
return "file:///" + name, writer.SaveGIF2Path(name, img.MergeGif(7, whirl))
|
||||
return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(7, whirl))
|
||||
}
|
||||
|
||||
// always 一直
|
||||
func alwaysDoGif(cc *context, value ...string) (string, error) {
|
||||
_ = value
|
||||
var err error
|
||||
var face []*image.NRGBA
|
||||
var face []*imgfactory.Factory
|
||||
name := cc.usrdir + "AlwaysDo.gif"
|
||||
face, err = img.LoadAllFrames(cc.headimgsdir[0], 500, 500)
|
||||
face, err = imgfactory.LoadAllFrames(cc.headimgsdir[0], 500, 500)
|
||||
if err != nil {
|
||||
// 载入失败尝试载入第一帧
|
||||
face = make([]*image.NRGBA, 0)
|
||||
first, err := img.LoadFirstFrame(cc.headimgsdir[0], 500, 500)
|
||||
face = nil
|
||||
first, err := imgfactory.LoadFirstFrame(cc.headimgsdir[0], 500, 500)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
face = append(face, first.Im)
|
||||
face = append(face, imgfactory.NewFactory(first.Image()))
|
||||
}
|
||||
canvas := gg.NewContext(500, 600)
|
||||
canvas.SetColor(color.Black)
|
||||
_, err = file.GetLazyData(text.BoldFontFile, control.Md5File, true)
|
||||
data, err := file.GetLazyData(text.BoldFontFile, control.Md5File, true)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
err = canvas.LoadFontFace(text.BoldFontFile, 40)
|
||||
err = canvas.ParseFontFace(data, 40)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
@@ -1437,13 +1436,13 @@ func alwaysDoGif(cc *context, value ...string) (string, error) {
|
||||
turn := make([]*image.NRGBA, length)
|
||||
for i, f := range face {
|
||||
canvas := gg.NewContext(500, 600)
|
||||
canvas.DrawImage(f, 0, 0)
|
||||
canvas.DrawImage(f.Image(), 0, 0)
|
||||
canvas.SetColor(color.Black)
|
||||
_ = canvas.LoadFontFace(text.BoldFontFile, 40)
|
||||
// _ = canvas.ParseFontFace(data, 40)
|
||||
canvas.DrawString(arg, 280-l, 560)
|
||||
canvas.DrawImage(img.Size(f, 90, 90).Im, 280, 505)
|
||||
canvas.DrawImage(imgfactory.Size(f.Image(), 90, 90).Image(), 280, 505)
|
||||
canvas.DrawString("吗", 370, 560)
|
||||
turn[i] = img.Size(canvas.Image(), 0, 0).Im
|
||||
turn[i] = imgfactory.Size(canvas.Image(), 0, 0).Image()
|
||||
}
|
||||
return "file:///" + name, writer.SaveGIF2Path(name, img.MergeGif(8, turn))
|
||||
return "file:///" + name, imgfactory.SaveGIF2Path(name, imgfactory.MergeGif(8, turn))
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
|
||||
"github.com/FloatTech/floatbox/file"
|
||||
"github.com/FloatTech/floatbox/process"
|
||||
"github.com/FloatTech/zbputils/img"
|
||||
"github.com/FloatTech/imgfactory"
|
||||
)
|
||||
|
||||
func (cc *context) prepareLogos(s ...string) error {
|
||||
@@ -27,17 +27,17 @@ func (cc *context) prepareLogos(s ...string) error {
|
||||
}
|
||||
|
||||
func (cc *context) getLogo(w int, h int) (*image.NRGBA, error) {
|
||||
frame, err := img.LoadFirstFrame(cc.headimgsdir[0], w, h)
|
||||
frame, err := imgfactory.LoadFirstFrame(cc.headimgsdir[0], w, h)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return frame.Circle(0).Im, nil
|
||||
return frame.Circle(0).Image(), nil
|
||||
}
|
||||
|
||||
func (cc *context) getLogo2(w int, h int) (*image.NRGBA, error) {
|
||||
frame, err := img.LoadFirstFrame(cc.headimgsdir[1], w, h)
|
||||
frame, err := imgfactory.LoadFirstFrame(cc.headimgsdir[1], w, h)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return frame.Circle(0).Im, nil
|
||||
return frame.Circle(0).Image(), nil
|
||||
}
|
||||
|
||||
@@ -9,10 +9,9 @@ import (
|
||||
"sync"
|
||||
|
||||
"github.com/FloatTech/floatbox/file"
|
||||
"github.com/FloatTech/floatbox/img/writer"
|
||||
"github.com/FloatTech/gg"
|
||||
"github.com/FloatTech/imgfactory"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/img"
|
||||
"github.com/FloatTech/zbputils/img/text"
|
||||
)
|
||||
|
||||
@@ -36,11 +35,11 @@ func pa(cc *context, args ...string) (string, error) {
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
imgf, err := img.LoadFirstFrame(f, 0, 0)
|
||||
imgf, err := imgfactory.LoadFirstFrame(f, 0, 0)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return "file:///" + name, writer.SavePNG2Path(name, imgf.InsertUp(tou, 100, 100, 0, 400).Im)
|
||||
return "file:///" + name, imgfactory.SavePNG2Path(name, imgf.InsertUp(tou, 100, 100, 0, 400).Image())
|
||||
}
|
||||
|
||||
// si 撕
|
||||
@@ -51,8 +50,8 @@ func si(cc *context, args ...string) (string, error) {
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
im1 := img.Rotate(tou, 20, 380, 380)
|
||||
im2 := img.Rotate(tou, -12, 380, 380)
|
||||
im1 := imgfactory.Rotate(tou, 20, 380, 380)
|
||||
im2 := imgfactory.Rotate(tou, -12, 380, 380)
|
||||
if file.IsNotExist(datapath + "materials/si") {
|
||||
err = os.MkdirAll(datapath+"materials/si", 0755)
|
||||
if err != nil {
|
||||
@@ -63,11 +62,11 @@ func si(cc *context, args ...string) (string, error) {
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
imgf, err := img.LoadFirstFrame(f, 0, 0)
|
||||
imgf, err := imgfactory.LoadFirstFrame(f, 0, 0)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return "file:///" + name, writer.SavePNG2Path(name, imgf.InsertBottom(im1.Im, im1.W, im1.H, -3, 370).InsertBottom(im2.Im, im2.W, im2.H, 653, 310).Im)
|
||||
return "file:///" + name, imgfactory.SavePNG2Path(name, imgf.InsertBottom(im1.Image(), im1.W(), im1.H(), -3, 370).InsertBottom(im2.Image(), im2.W(), im2.H(), 653, 310).Image())
|
||||
}
|
||||
|
||||
// flipV 上翻,下翻
|
||||
@@ -75,12 +74,12 @@ func flipV(cc *context, args ...string) (string, error) {
|
||||
_ = args
|
||||
name := cc.usrdir + "FlipV.png"
|
||||
// 加载图片
|
||||
im, err := img.LoadFirstFrame(cc.headimgsdir[0], 0, 0)
|
||||
im, err := imgfactory.LoadFirstFrame(cc.headimgsdir[0], 0, 0)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
imgnrgba := im.FlipV().Im
|
||||
return "file:///" + name, writer.SavePNG2Path(name, imgnrgba)
|
||||
imgnrgba := im.FlipV().Image()
|
||||
return "file:///" + name, imgfactory.SavePNG2Path(name, imgnrgba)
|
||||
}
|
||||
|
||||
// flipH 左翻,右翻
|
||||
@@ -88,12 +87,12 @@ func flipH(cc *context, args ...string) (string, error) {
|
||||
_ = args
|
||||
name := cc.usrdir + "FlipH.png"
|
||||
// 加载图片
|
||||
im, err := img.LoadFirstFrame(cc.headimgsdir[0], 0, 0)
|
||||
im, err := imgfactory.LoadFirstFrame(cc.headimgsdir[0], 0, 0)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
imgnrgba := im.FlipH().Im
|
||||
return "file:///" + name, writer.SavePNG2Path(name, imgnrgba)
|
||||
imgnrgba := im.FlipH().Image()
|
||||
return "file:///" + name, imgfactory.SavePNG2Path(name, imgnrgba)
|
||||
}
|
||||
|
||||
// invert 反色
|
||||
@@ -101,12 +100,12 @@ func invert(cc *context, args ...string) (string, error) {
|
||||
_ = args
|
||||
name := cc.usrdir + "Invert.png"
|
||||
// 加载图片
|
||||
im, err := img.LoadFirstFrame(cc.headimgsdir[0], 0, 0)
|
||||
im, err := imgfactory.LoadFirstFrame(cc.headimgsdir[0], 0, 0)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
imgnrgba := im.Invert().Im
|
||||
return "file:///" + name, writer.SavePNG2Path(name, imgnrgba)
|
||||
imgnrgba := im.Invert().Image()
|
||||
return "file:///" + name, imgfactory.SavePNG2Path(name, imgnrgba)
|
||||
}
|
||||
|
||||
// blur 反色
|
||||
@@ -114,12 +113,12 @@ func blur(cc *context, args ...string) (string, error) {
|
||||
_ = args
|
||||
name := cc.usrdir + "Blur.png"
|
||||
// 加载图片
|
||||
im, err := img.LoadFirstFrame(cc.headimgsdir[0], 0, 0)
|
||||
im, err := imgfactory.LoadFirstFrame(cc.headimgsdir[0], 0, 0)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
imgnrgba := im.Blur(10).Im
|
||||
return "file:///" + name, writer.SavePNG2Path(name, imgnrgba)
|
||||
imgnrgba := im.Blur(10).Image()
|
||||
return "file:///" + name, imgfactory.SavePNG2Path(name, imgnrgba)
|
||||
}
|
||||
|
||||
// grayscale 灰度
|
||||
@@ -127,12 +126,12 @@ func grayscale(cc *context, args ...string) (string, error) {
|
||||
_ = args
|
||||
name := cc.usrdir + "Grayscale.png"
|
||||
// 加载图片
|
||||
im, err := img.LoadFirstFrame(cc.headimgsdir[0], 0, 0)
|
||||
im, err := imgfactory.LoadFirstFrame(cc.headimgsdir[0], 0, 0)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
imgnrgba := im.Grayscale().Im
|
||||
return "file:///" + name, writer.SavePNG2Path(name, imgnrgba)
|
||||
imgnrgba := im.Grayscale().Image()
|
||||
return "file:///" + name, imgfactory.SavePNG2Path(name, imgnrgba)
|
||||
}
|
||||
|
||||
// invertAndGrayscale 负片
|
||||
@@ -140,12 +139,12 @@ func invertAndGrayscale(cc *context, args ...string) (string, error) {
|
||||
_ = args
|
||||
name := cc.usrdir + "InvertAndGrayscale.png"
|
||||
// 加载图片
|
||||
im, err := img.LoadFirstFrame(cc.headimgsdir[0], 0, 0)
|
||||
im, err := imgfactory.LoadFirstFrame(cc.headimgsdir[0], 0, 0)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
imgnrgba := im.Invert().Grayscale().Im
|
||||
return "file:///" + name, writer.SavePNG2Path(name, imgnrgba)
|
||||
imgnrgba := im.Invert().Grayscale().Image()
|
||||
return "file:///" + name, imgfactory.SavePNG2Path(name, imgnrgba)
|
||||
}
|
||||
|
||||
// convolve3x3 浮雕
|
||||
@@ -153,32 +152,32 @@ func convolve3x3(cc *context, args ...string) (string, error) {
|
||||
_ = args
|
||||
name := cc.usrdir + "Convolve3x3.png"
|
||||
// 加载图片
|
||||
im, err := img.LoadFirstFrame(cc.headimgsdir[0], 0, 0)
|
||||
im, err := imgfactory.LoadFirstFrame(cc.headimgsdir[0], 0, 0)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
imgnrgba := im.Convolve3x3().Im
|
||||
return "file:///" + name, writer.SavePNG2Path(name, imgnrgba)
|
||||
imgnrgba := im.Relief().Image()
|
||||
return "file:///" + name, imgfactory.SavePNG2Path(name, imgnrgba)
|
||||
}
|
||||
|
||||
// rotate 旋转
|
||||
func rotate(cc *context, args ...string) (string, error) {
|
||||
name := cc.usrdir + "Rotate.png"
|
||||
// 加载图片
|
||||
im, err := img.LoadFirstFrame(cc.headimgsdir[0], 0, 0)
|
||||
im, err := imgfactory.LoadFirstFrame(cc.headimgsdir[0], 0, 0)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
r, _ := strconv.ParseFloat(args[0], 64)
|
||||
imgnrgba := img.Rotate(im.Im, r, 0, 0).Im
|
||||
return "file:///" + name, writer.SavePNG2Path(name, imgnrgba)
|
||||
imgnrgba := imgfactory.Rotate(im.Image(), r, 0, 0).Image()
|
||||
return "file:///" + name, imgfactory.SavePNG2Path(name, imgnrgba)
|
||||
}
|
||||
|
||||
// deformation 变形
|
||||
func deformation(cc *context, args ...string) (string, error) {
|
||||
name := cc.usrdir + "Deformation.png"
|
||||
// 加载图片
|
||||
im, err := img.LoadFirstFrame(cc.headimgsdir[0], 0, 0)
|
||||
im, err := imgfactory.LoadFirstFrame(cc.headimgsdir[0], 0, 0)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
@@ -190,8 +189,8 @@ func deformation(cc *context, args ...string) (string, error) {
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
imgnrgba := img.Size(im.Im, w, h).Im
|
||||
return "file:///" + name, writer.SavePNG2Path(name, imgnrgba)
|
||||
imgnrgba := imgfactory.Size(im.Image(), w, h).Image()
|
||||
return "file:///" + name, imgfactory.SavePNG2Path(name, imgnrgba)
|
||||
}
|
||||
|
||||
// alike 你像个xxx一样
|
||||
@@ -214,12 +213,12 @@ func alike(cc *context, args ...string) (string, error) {
|
||||
return "", err
|
||||
}
|
||||
name := cc.usrdir + "Anyasuki.png"
|
||||
im, err := img.LoadFirstFrame(cc.headimgsdir[0], 82, 69)
|
||||
im, err := imgfactory.LoadFirstFrame(cc.headimgsdir[0], 82, 69)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
imgnrgba := imgs[0].InsertUp(im.Im, 0, 0, 136, 21).Im
|
||||
return "file:///" + name, writer.SavePNG2Path(name, imgnrgba)
|
||||
imgnrgba := imgs[0].InsertUp(im.Image(), 0, 0, 136, 21).Image()
|
||||
return "file:///" + name, imgfactory.SavePNG2Path(name, imgnrgba)
|
||||
}
|
||||
|
||||
// marriage
|
||||
@@ -242,12 +241,12 @@ func marriage(cc *context, args ...string) (string, error) {
|
||||
return "", err
|
||||
}
|
||||
name := cc.usrdir + "Marriage.png"
|
||||
im, err := img.LoadFirstFrame(cc.headimgsdir[0], 1080, 1080)
|
||||
im, err := imgfactory.LoadFirstFrame(cc.headimgsdir[0], 1080, 1080)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
imgnrgba := im.InsertUp(imgs[0].Im, 0, 0, 0, 0).InsertUp(imgs[1].Im, 0, 0, 800, 0).Im
|
||||
return "file:///" + name, writer.SavePNG2Path(name, imgnrgba)
|
||||
imgnrgba := im.InsertUp(imgs[0].Image(), 0, 0, 0, 0).InsertUp(imgs[1].Image(), 0, 0, 800, 0).Image()
|
||||
return "file:///" + name, imgfactory.SavePNG2Path(name, imgnrgba)
|
||||
}
|
||||
|
||||
// anyasuki 阿尼亚喜欢
|
||||
@@ -275,14 +274,14 @@ func anyasuki(cc *context, args ...string) (string, error) {
|
||||
return "", err
|
||||
}
|
||||
canvas := gg.NewContext(475, 540)
|
||||
canvas.DrawImage(img.Size(face, 347, 267).Im, 82, 53)
|
||||
canvas.DrawImage(imgfactory.Size(face, 347, 267).Image(), 82, 53)
|
||||
canvas.DrawImage(back, 0, 0)
|
||||
canvas.SetColor(color.Black)
|
||||
_, err = file.GetLazyData(text.BoldFontFile, control.Md5File, true)
|
||||
data, err := file.GetLazyData(text.BoldFontFile, control.Md5File, true)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
if err = canvas.LoadFontFace(text.BoldFontFile, 30); err != nil {
|
||||
if err = canvas.ParseFontFace(data, 30); err != nil {
|
||||
return "", err
|
||||
}
|
||||
if args[0] == "" {
|
||||
@@ -322,13 +321,13 @@ func alwaysLike(cc *context, args ...string) (string, error) {
|
||||
}
|
||||
canvas := gg.NewContext(830, 599)
|
||||
canvas.DrawImage(back, 0, 0)
|
||||
canvas.DrawImage(img.Size(face, 380, 380).Im, 44, 74)
|
||||
canvas.DrawImage(imgfactory.Size(face, 380, 380).Image(), 44, 74)
|
||||
canvas.SetColor(color.Black)
|
||||
_, err = file.GetLazyData(text.BoldFontFile, control.Md5File, true)
|
||||
data, err := file.GetLazyData(text.BoldFontFile, control.Md5File, true)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
if err = canvas.LoadFontFace(text.BoldFontFile, 56); err != nil {
|
||||
if err = canvas.ParseFontFace(data, 56); err != nil {
|
||||
return "", err
|
||||
}
|
||||
if args[0] == "" {
|
||||
@@ -363,12 +362,12 @@ func decentKiss(cc *context, args ...string) (string, error) {
|
||||
return "", err
|
||||
}
|
||||
name := cc.usrdir + "DecentKiss.png"
|
||||
im, err := img.LoadFirstFrame(cc.headimgsdir[0], 589, 577)
|
||||
im, err := imgfactory.LoadFirstFrame(cc.headimgsdir[0], 589, 577)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
imgnrgba := im.InsertUp(imgs[0].Im, 0, 0, 0, 0).Im
|
||||
return "file:///" + name, writer.SavePNG2Path(name, imgnrgba)
|
||||
imgnrgba := im.InsertUp(imgs[0].Image(), 0, 0, 0, 0).Image()
|
||||
return "file:///" + name, imgfactory.SavePNG2Path(name, imgnrgba)
|
||||
}
|
||||
|
||||
// chinaFlag 国旗
|
||||
@@ -391,12 +390,12 @@ func chinaFlag(cc *context, args ...string) (string, error) {
|
||||
return "", err
|
||||
}
|
||||
name := cc.usrdir + "ChinaFlag.png"
|
||||
im, err := img.LoadFirstFrame(cc.headimgsdir[0], 410, 410)
|
||||
im, err := imgfactory.LoadFirstFrame(cc.headimgsdir[0], 410, 410)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
imgnrgba := im.InsertUp(imgs[0].Im, 0, 0, 0, 0).Im
|
||||
return "file:///" + name, writer.SavePNG2Path(name, imgnrgba)
|
||||
imgnrgba := im.InsertUp(imgs[0].Image(), 0, 0, 0, 0).Image()
|
||||
return "file:///" + name, imgfactory.SavePNG2Path(name, imgnrgba)
|
||||
}
|
||||
|
||||
// dontTouch 不要靠近
|
||||
@@ -419,12 +418,12 @@ func dontTouch(cc *context, args ...string) (string, error) {
|
||||
return "", err
|
||||
}
|
||||
name := cc.usrdir + "DontTouch.png"
|
||||
im, err := img.LoadFirstFrame(cc.headimgsdir[0], 410, 410)
|
||||
im, err := imgfactory.LoadFirstFrame(cc.headimgsdir[0], 410, 410)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
imgnrgba := imgs[0].InsertUp(im.Im, 148, 148, 46, 238).Im
|
||||
return "file:///" + name, writer.SavePNG2Path(name, imgnrgba)
|
||||
imgnrgba := imgs[0].InsertUp(im.Image(), 148, 148, 46, 238).Image()
|
||||
return "file:///" + name, imgfactory.SavePNG2Path(name, imgnrgba)
|
||||
}
|
||||
|
||||
// universal 万能表情 空白表情
|
||||
@@ -436,13 +435,13 @@ func universal(cc *context, args ...string) (string, error) {
|
||||
return "", err
|
||||
}
|
||||
canvas := gg.NewContext(500, 550)
|
||||
canvas.DrawImage(img.Size(face, 500, 500).Im, 0, 0)
|
||||
canvas.DrawImage(imgfactory.Size(face, 500, 500).Image(), 0, 0)
|
||||
canvas.SetColor(color.Black)
|
||||
_, err = file.GetLazyData(text.BoldFontFile, control.Md5File, true)
|
||||
data, err := file.GetLazyData(text.BoldFontFile, control.Md5File, true)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
if err = canvas.LoadFontFace(text.BoldFontFile, 40); err != nil {
|
||||
if err = canvas.ParseFontFace(data, 40); err != nil {
|
||||
return "", err
|
||||
}
|
||||
if args[0] == "" {
|
||||
@@ -485,15 +484,15 @@ func interview(cc *context, args ...string) (string, error) {
|
||||
return "", err
|
||||
}
|
||||
canvas := gg.NewContext(600, 300)
|
||||
canvas.DrawImage(img.Size(face, 124, 124).Im, 100, 50)
|
||||
canvas.DrawImage(imgfactory.Size(face, 124, 124).Image(), 100, 50)
|
||||
canvas.DrawImage(huaji, 376, 50)
|
||||
canvas.DrawImage(microphone, 300, 50)
|
||||
canvas.SetColor(color.Black)
|
||||
_, err = file.GetLazyData(text.BoldFontFile, control.Md5File, true)
|
||||
data, err := file.GetLazyData(text.BoldFontFile, control.Md5File, true)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
if err = canvas.LoadFontFace(text.BoldFontFile, 40); err != nil {
|
||||
if err = canvas.ParseFontFace(data, 40); err != nil {
|
||||
return "", err
|
||||
}
|
||||
if args[0] == "" {
|
||||
@@ -527,12 +526,12 @@ func need(cc *context, args ...string) (string, error) {
|
||||
return "", err
|
||||
}
|
||||
name := cc.usrdir + "Need.png"
|
||||
im, err := img.LoadFirstFrame(cc.headimgsdir[0], 114, 114)
|
||||
im, err := imgfactory.LoadFirstFrame(cc.headimgsdir[0], 114, 114)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
imgnrgba := imgs[0].InsertBottom(im.Im, 0, 0, 327, 232).Im
|
||||
return "file:///" + name, writer.SavePNG2Path(name, imgnrgba)
|
||||
imgnrgba := imgs[0].InsertBottom(im.Image(), 0, 0, 327, 232).Image()
|
||||
return "file:///" + name, imgfactory.SavePNG2Path(name, imgnrgba)
|
||||
}
|
||||
|
||||
// paint 这像画吗
|
||||
@@ -555,12 +554,12 @@ func paint(cc *context, args ...string) (string, error) {
|
||||
return "", err
|
||||
}
|
||||
name := cc.usrdir + "Paint.png"
|
||||
im, err := img.LoadFirstFrame(cc.headimgsdir[0], 117, 135)
|
||||
im, err := imgfactory.LoadFirstFrame(cc.headimgsdir[0], 117, 135)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
imgnrgba := imgs[0].InsertBottom(img.Rotate(im.Im, 4, 0, 0).Im, 0, 0, 95, 107).Im
|
||||
return "file:///" + name, writer.SavePNG2Path(name, imgnrgba)
|
||||
imgnrgba := imgs[0].InsertBottom(imgfactory.Rotate(im.Image(), 4, 0, 0).Image(), 0, 0, 95, 107).Image()
|
||||
return "file:///" + name, imgfactory.SavePNG2Path(name, imgnrgba)
|
||||
}
|
||||
|
||||
// painter 小画家
|
||||
@@ -583,12 +582,12 @@ func painter(cc *context, args ...string) (string, error) {
|
||||
return "", err
|
||||
}
|
||||
name := cc.usrdir + "Painter.png"
|
||||
im, err := img.LoadFirstFrame(cc.headimgsdir[0], 240, 345)
|
||||
im, err := imgfactory.LoadFirstFrame(cc.headimgsdir[0], 240, 345)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
imgnrgba := imgs[0].InsertBottom(im.Im, 0, 0, 125, 91).Im
|
||||
return "file:///" + name, writer.SavePNG2Path(name, imgnrgba)
|
||||
imgnrgba := imgs[0].InsertBottom(im.Image(), 0, 0, 125, 91).Image()
|
||||
return "file:///" + name, imgfactory.SavePNG2Path(name, imgnrgba)
|
||||
}
|
||||
|
||||
// perfect 完美
|
||||
@@ -611,12 +610,12 @@ func perfect(cc *context, args ...string) (string, error) {
|
||||
return "", err
|
||||
}
|
||||
name := cc.usrdir + "Perfect.png"
|
||||
im, err := img.LoadFirstFrame(cc.headimgsdir[0], 310, 460)
|
||||
im, err := imgfactory.LoadFirstFrame(cc.headimgsdir[0], 310, 460)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
imgnrgba := imgs[0].InsertUp(im.Im, 0, 0, 313, 64).Im
|
||||
return "file:///" + name, writer.SavePNG2Path(name, imgnrgba)
|
||||
imgnrgba := imgs[0].InsertUp(im.Image(), 0, 0, 313, 64).Image()
|
||||
return "file:///" + name, imgfactory.SavePNG2Path(name, imgnrgba)
|
||||
}
|
||||
|
||||
// playGame 玩游戏
|
||||
@@ -644,14 +643,14 @@ func playGame(cc *context, args ...string) (string, error) {
|
||||
return "", err
|
||||
}
|
||||
canvas := gg.NewContext(526, 503)
|
||||
canvas.DrawImage(img.Rotate(face, 10, 225, 160).Im, 161, 117)
|
||||
canvas.DrawImage(imgfactory.Rotate(face, 10, 225, 160).Image(), 161, 117)
|
||||
canvas.DrawImage(back, 0, 0)
|
||||
canvas.SetColor(color.Black)
|
||||
_, err = file.GetLazyData(text.BoldFontFile, control.Md5File, true)
|
||||
data, err := file.GetLazyData(text.BoldFontFile, control.Md5File, true)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
if err = canvas.LoadFontFace(text.BoldFontFile, 40); err != nil {
|
||||
if err = canvas.ParseFontFace(data, 40); err != nil {
|
||||
return "", err
|
||||
}
|
||||
if args[0] == "" {
|
||||
@@ -685,12 +684,12 @@ func police(cc *context, args ...string) (string, error) {
|
||||
return "", err
|
||||
}
|
||||
name := cc.usrdir + "Police.png"
|
||||
im, err := img.LoadFirstFrame(cc.headimgsdir[0], 245, 245)
|
||||
im, err := imgfactory.LoadFirstFrame(cc.headimgsdir[0], 245, 245)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
imgnrgba := imgs[0].InsertBottom(im.Im, 0, 0, 224, 46).Im
|
||||
return "file:///" + name, writer.SavePNG2Path(name, imgnrgba)
|
||||
imgnrgba := imgs[0].InsertBottom(im.Image(), 0, 0, 224, 46).Image()
|
||||
return "file:///" + name, imgfactory.SavePNG2Path(name, imgnrgba)
|
||||
}
|
||||
|
||||
// police1 警察
|
||||
@@ -713,12 +712,12 @@ func police1(cc *context, args ...string) (string, error) {
|
||||
return "", err
|
||||
}
|
||||
name := cc.usrdir + "Police1.png"
|
||||
im, err := img.LoadFirstFrame(cc.headimgsdir[0], 60, 75)
|
||||
im, err := imgfactory.LoadFirstFrame(cc.headimgsdir[0], 60, 75)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
imgnrgba := imgs[1].InsertBottom(img.Rotate(im.Im, 16, 0, 0).Im, 0, 0, 37, 291).Im
|
||||
return "file:///" + name, writer.SavePNG2Path(name, imgnrgba)
|
||||
imgnrgba := imgs[1].InsertBottom(imgfactory.Rotate(im.Image(), 16, 0, 0).Image(), 0, 0, 37, 291).Image()
|
||||
return "file:///" + name, imgfactory.SavePNG2Path(name, imgnrgba)
|
||||
}
|
||||
|
||||
// prpr 舔 舔屏 prpr
|
||||
@@ -741,12 +740,12 @@ func prpr(cc *context, args ...string) (string, error) {
|
||||
return "", err
|
||||
}
|
||||
name := cc.usrdir + "Prpr.png"
|
||||
im, err := img.LoadFirstFrame(cc.headimgsdir[0], 330, 330)
|
||||
im, err := imgfactory.LoadFirstFrame(cc.headimgsdir[0], 330, 330)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
imgnrgba := imgs[0].InsertBottom(img.Rotate(im.Im, 8, 0, 0).Im, 0, 0, 46, 264).Im
|
||||
return "file:///" + name, writer.SavePNG2Path(name, imgnrgba)
|
||||
imgnrgba := imgs[0].InsertBottom(imgfactory.Rotate(im.Image(), 8, 0, 0).Image(), 0, 0, 46, 264).Image()
|
||||
return "file:///" + name, imgfactory.SavePNG2Path(name, imgnrgba)
|
||||
}
|
||||
|
||||
// safeSense 安全感
|
||||
@@ -775,13 +774,13 @@ func safeSense(cc *context, args ...string) (string, error) {
|
||||
}
|
||||
canvas := gg.NewContext(430, 478)
|
||||
canvas.DrawImage(back, 0, 0)
|
||||
canvas.DrawImage(img.Size(face, 215, 343).Im, 215, 135)
|
||||
canvas.DrawImage(imgfactory.Size(face, 215, 343).Image(), 215, 135)
|
||||
canvas.SetColor(color.Black)
|
||||
_, err = file.GetLazyData(text.BoldFontFile, control.Md5File, true)
|
||||
data, err := file.GetLazyData(text.BoldFontFile, control.Md5File, true)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
if err = canvas.LoadFontFace(text.BoldFontFile, 30); err != nil {
|
||||
if err = canvas.ParseFontFace(data, 30); err != nil {
|
||||
return "", err
|
||||
}
|
||||
if args[0] == "" {
|
||||
@@ -817,12 +816,12 @@ func support(cc *context, args ...string) (string, error) {
|
||||
return "", err
|
||||
}
|
||||
name := cc.usrdir + "Support.png"
|
||||
im, err := img.LoadFirstFrame(cc.headimgsdir[0], 815, 815)
|
||||
im, err := imgfactory.LoadFirstFrame(cc.headimgsdir[0], 815, 815)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
imgnrgba := imgs[0].InsertBottom(img.Rotate(im.Im, 23, 0, 0).Im, 0, 0, -172, -17).Im
|
||||
return "file:///" + name, writer.SavePNG2Path(name, imgnrgba)
|
||||
imgnrgba := imgs[0].InsertBottom(imgfactory.Rotate(im.Image(), 23, 0, 0).Image(), 0, 0, -172, -17).Image()
|
||||
return "file:///" + name, imgfactory.SavePNG2Path(name, imgnrgba)
|
||||
}
|
||||
|
||||
// thinkwhat 想什么
|
||||
@@ -845,12 +844,12 @@ func thinkwhat(cc *context, args ...string) (string, error) {
|
||||
return "", err
|
||||
}
|
||||
name := cc.usrdir + "Thinkwhat.png"
|
||||
im, err := img.LoadFirstFrame(cc.headimgsdir[0], 534, 493)
|
||||
im, err := imgfactory.LoadFirstFrame(cc.headimgsdir[0], 534, 493)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
imgnrgba := imgs[0].InsertBottom(im.Im, 0, 0, 530, 0).Im
|
||||
return "file:///" + name, writer.SavePNG2Path(name, imgnrgba)
|
||||
imgnrgba := imgs[0].InsertBottom(im.Image(), 0, 0, 530, 0).Image()
|
||||
return "file:///" + name, imgfactory.SavePNG2Path(name, imgnrgba)
|
||||
}
|
||||
|
||||
// wallpaper 墙纸
|
||||
@@ -873,12 +872,12 @@ func wallpaper(cc *context, args ...string) (string, error) {
|
||||
return "", err
|
||||
}
|
||||
name := cc.usrdir + "Wallpaper.png"
|
||||
im, err := img.LoadFirstFrame(cc.headimgsdir[0], 775, 496)
|
||||
im, err := imgfactory.LoadFirstFrame(cc.headimgsdir[0], 775, 496)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
imgnrgba := imgs[0].InsertBottom(im.Im, 0, 0, 260, 580).Im
|
||||
return "file:///" + name, writer.SavePNG2Path(name, imgnrgba)
|
||||
imgnrgba := imgs[0].InsertBottom(im.Image(), 0, 0, 260, 580).Image()
|
||||
return "file:///" + name, imgfactory.SavePNG2Path(name, imgnrgba)
|
||||
}
|
||||
|
||||
// whyatme 为什么at我
|
||||
@@ -901,12 +900,12 @@ func whyatme(cc *context, args ...string) (string, error) {
|
||||
return "", err
|
||||
}
|
||||
name := cc.usrdir + "Whyatme.png"
|
||||
im, err := img.LoadFirstFrame(cc.headimgsdir[0], 265, 265)
|
||||
im, err := imgfactory.LoadFirstFrame(cc.headimgsdir[0], 265, 265)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
imgnrgba := imgs[0].InsertBottom(im.Im, 0, 0, 42, 13).Im
|
||||
return "file:///" + name, writer.SavePNG2Path(name, imgnrgba)
|
||||
imgnrgba := imgs[0].InsertBottom(im.Image(), 0, 0, 42, 13).Image()
|
||||
return "file:///" + name, imgfactory.SavePNG2Path(name, imgnrgba)
|
||||
}
|
||||
|
||||
// makeFriend 交个朋友
|
||||
@@ -934,16 +933,16 @@ func makeFriend(cc *context, args ...string) (string, error) {
|
||||
return "", err
|
||||
}
|
||||
canvas := gg.NewContext(1000, 1000)
|
||||
canvas.DrawImage(img.Size(face, 1000, 1000).Im, 0, 0)
|
||||
canvas.DrawImage(img.Rotate(face, 9, 250, 250).Im, 743, 845)
|
||||
canvas.DrawImage(img.Rotate(face, 9, 55, 55).Im, 836, 722)
|
||||
canvas.DrawImage(imgfactory.Size(face, 1000, 1000).Image(), 0, 0)
|
||||
canvas.DrawImage(imgfactory.Rotate(face, 9, 250, 250).Image(), 743, 845)
|
||||
canvas.DrawImage(imgfactory.Rotate(face, 9, 55, 55).Image(), 836, 722)
|
||||
canvas.DrawImage(back, 0, 0)
|
||||
canvas.SetColor(color.White)
|
||||
_, err = file.GetLazyData(text.BoldFontFile, control.Md5File, true)
|
||||
data, err := file.GetLazyData(text.BoldFontFile, control.Md5File, true)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
if err = canvas.LoadFontFace(text.BoldFontFile, 20); err != nil {
|
||||
if err = canvas.ParseFontFace(data, 20); err != nil {
|
||||
return "", err
|
||||
}
|
||||
if args[0] == "" {
|
||||
@@ -978,12 +977,12 @@ func backToWork(cc *context, args ...string) (string, error) {
|
||||
return "", err
|
||||
}
|
||||
name := cc.usrdir + "BackToWork.png"
|
||||
im, err := img.LoadFirstFrame(cc.headimgsdir[0], 220, 310)
|
||||
im, err := imgfactory.LoadFirstFrame(cc.headimgsdir[0], 220, 310)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
imgnrgba := imgs[0].InsertBottom(img.Rotate(im.Im, 25, 0, 0).Im, 0, 0, 56, 32).Im
|
||||
return "file:///" + name, writer.SavePNG2Path(name, imgnrgba)
|
||||
imgnrgba := imgs[0].InsertBottom(imgfactory.Rotate(im.Image(), 25, 0, 0).Image(), 0, 0, 56, 32).Image()
|
||||
return "file:///" + name, imgfactory.SavePNG2Path(name, imgnrgba)
|
||||
}
|
||||
|
||||
// coupon 兑换券
|
||||
@@ -1016,13 +1015,13 @@ func coupon(cc *context, args ...string) (string, error) {
|
||||
canvas := gg.NewContext(500, 355)
|
||||
canvas.DrawImage(back, 0, 0)
|
||||
canvas.Rotate(gg.Radians(-22))
|
||||
canvas.DrawImage(img.Size(face, 60, 60).Im, 100, 163)
|
||||
canvas.DrawImage(imgfactory.Size(face, 60, 60).Image(), 100, 163)
|
||||
canvas.SetColor(color.Black)
|
||||
_, err = file.GetLazyData(text.BoldFontFile, control.Md5File, true)
|
||||
data, err := file.GetLazyData(text.BoldFontFile, control.Md5File, true)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
if err = canvas.LoadFontFace(text.BoldFontFile, 30); err != nil {
|
||||
if err = canvas.ParseFontFace(data, 30); err != nil {
|
||||
return "", err
|
||||
}
|
||||
if args[0] == "" {
|
||||
@@ -1057,12 +1056,12 @@ func distracted(cc *context, args ...string) (string, error) {
|
||||
return "", err
|
||||
}
|
||||
name := cc.usrdir + "Distracted.png"
|
||||
im, err := img.LoadFirstFrame(cc.headimgsdir[0], 500, 500)
|
||||
im, err := imgfactory.LoadFirstFrame(cc.headimgsdir[0], 500, 500)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
imgnrgba := im.InsertUp(imgs[0].Im, 0, 0, 140, 320).InsertUp(imgs[1].Im, 0, 0, 0, 0).Im
|
||||
return "file:///" + name, writer.SavePNG2Path(name, imgnrgba)
|
||||
imgnrgba := im.InsertUp(imgs[0].Image(), 0, 0, 140, 320).InsertUp(imgs[1].Image(), 0, 0, 0, 0).Image()
|
||||
return "file:///" + name, imgfactory.SavePNG2Path(name, imgnrgba)
|
||||
}
|
||||
|
||||
// throw 扔
|
||||
@@ -1089,8 +1088,8 @@ func throw(cc *context, args ...string) (string, error) {
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
imgnrgba := imgs[0].InsertUpC(img.Rotate(face, float64(rand.Intn(360)), 143, 143).Im, 0, 0, 86, 249).Im
|
||||
return "file:///" + name, writer.SavePNG2Path(name, imgnrgba)
|
||||
imgnrgba := imgs[0].InsertUpC(imgfactory.Rotate(face, float64(rand.Intn(360)), 143, 143).Image(), 0, 0, 86, 249).Image()
|
||||
return "file:///" + name, imgfactory.SavePNG2Path(name, imgnrgba)
|
||||
}
|
||||
|
||||
// 远离
|
||||
@@ -1113,12 +1112,12 @@ func yuanli(cc *context, args ...string) (string, error) {
|
||||
return "", err
|
||||
}
|
||||
name := cc.usrdir + "yuanli.png"
|
||||
im, err := img.LoadFirstFrame(cc.headimgsdir[0], 534, 493)
|
||||
im, err := imgfactory.LoadFirstFrame(cc.headimgsdir[0], 534, 493)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
imgnrgba := imgs[0].InsertBottom(im.Im, 420, 420, 45, 90).Im
|
||||
return "file:///" + name, writer.SavePNG2Path(name, imgnrgba)
|
||||
imgnrgba := imgs[0].InsertBottom(im.Image(), 420, 420, 45, 90).Image()
|
||||
return "file:///" + name, imgfactory.SavePNG2Path(name, imgnrgba)
|
||||
}
|
||||
|
||||
// 不是你老婆
|
||||
@@ -1141,12 +1140,12 @@ func nowife(cc *context, args ...string) (string, error) {
|
||||
return "", err
|
||||
}
|
||||
name := cc.usrdir + "nowife.png"
|
||||
im, err := img.LoadFirstFrame(cc.headimgsdir[0], 534, 493)
|
||||
im, err := imgfactory.LoadFirstFrame(cc.headimgsdir[0], 534, 493)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
imgnrgba := imgs[0].InsertBottom(im.Im, 400, 400, 112, 81).Im
|
||||
return "file:///" + name, writer.SavePNG2Path(name, imgnrgba)
|
||||
imgnrgba := imgs[0].InsertBottom(im.Image(), 400, 400, 112, 81).Image()
|
||||
return "file:///" + name, imgfactory.SavePNG2Path(name, imgnrgba)
|
||||
}
|
||||
|
||||
// youer 你老婆
|
||||
@@ -1175,13 +1174,13 @@ func youer(cc *context, args ...string) (string, error) {
|
||||
}
|
||||
canvas := gg.NewContext(690, 690)
|
||||
canvas.DrawImage(back, 0, 0)
|
||||
canvas.DrawImage(img.Size(tou, 350, 350).Im, 55, 165)
|
||||
canvas.DrawImage(imgfactory.Size(tou, 350, 350).Image(), 55, 165)
|
||||
canvas.SetColor(color.Black)
|
||||
_, err = file.GetLazyData(text.BoldFontFile, control.Md5File, true)
|
||||
data, err := file.GetLazyData(text.BoldFontFile, control.Md5File, true)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
if err = canvas.LoadFontFace(text.BoldFontFile, 56); err != nil {
|
||||
if err = canvas.ParseFontFace(data, 56); err != nil {
|
||||
return "", err
|
||||
}
|
||||
if args[0] == "" {
|
||||
@@ -1222,13 +1221,13 @@ func xiaotianshi(cc *context, args ...string) (string, error) {
|
||||
}
|
||||
canvas := gg.NewContext(522, 665)
|
||||
canvas.DrawImage(back, 0, 0)
|
||||
canvas.DrawImage(img.Size(face, 480, 480).Im, 20, 80)
|
||||
canvas.DrawImage(imgfactory.Size(face, 480, 480).Image(), 20, 80)
|
||||
canvas.SetColor(color.Black)
|
||||
_, err = file.GetLazyData(text.BoldFontFile, control.Md5File, true)
|
||||
data, err := file.GetLazyData(text.BoldFontFile, control.Md5File, true)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
if err = canvas.LoadFontFace(text.BoldFontFile, 35); err != nil {
|
||||
if err = canvas.ParseFontFace(data, 35); err != nil {
|
||||
return "", err
|
||||
}
|
||||
if args[0] == "" {
|
||||
@@ -1263,12 +1262,12 @@ func neko(cc *context, args ...string) (string, error) {
|
||||
return "", err
|
||||
}
|
||||
name := cc.usrdir + "neko.png"
|
||||
im, err := img.LoadFirstFrame(cc.headimgsdir[0], 712, 949)
|
||||
im, err := imgfactory.LoadFirstFrame(cc.headimgsdir[0], 712, 949)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
imgnrgba := imgs[0].InsertBottom(img.Rotate(im.Im, 0, 0, 0).Im, 450, 450, 0, 170).Im
|
||||
return "file:///" + name, writer.SavePNG2Path(name, imgnrgba)
|
||||
imgnrgba := imgs[0].InsertBottom(imgfactory.Rotate(im.Image(), 0, 0, 0).Image(), 450, 450, 0, 170).Image()
|
||||
return "file:///" + name, imgfactory.SavePNG2Path(name, imgnrgba)
|
||||
}
|
||||
|
||||
// 给我变
|
||||
@@ -1292,12 +1291,12 @@ func bian(cc *context, args ...string) (string, error) {
|
||||
return "", err
|
||||
}
|
||||
name := cc.usrdir + "bian.png"
|
||||
im, err := img.LoadFirstFrame(cc.headimgsdir[0], 640, 550)
|
||||
im, err := imgfactory.LoadFirstFrame(cc.headimgsdir[0], 640, 550)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
imgnrgba := imgs[0].InsertBottom(img.Rotate(im.Im, 0, 0, 0).Im, 380, 380, 225, -20).Im
|
||||
return "file:///" + name, writer.SavePNG2Path(name, imgnrgba)
|
||||
imgnrgba := imgs[0].InsertBottom(imgfactory.Rotate(im.Image(), 0, 0, 0).Image(), 380, 380, 225, -20).Image()
|
||||
return "file:///" + name, imgfactory.SavePNG2Path(name, imgnrgba)
|
||||
}
|
||||
|
||||
// van 玩一下
|
||||
@@ -1326,13 +1325,13 @@ func van(cc *context, args ...string) (string, error) {
|
||||
}
|
||||
canvas := gg.NewContext(522, 665)
|
||||
canvas.DrawImage(back, 0, 0)
|
||||
canvas.DrawImage(img.Size(face, 480, 480).Im, 20, 80)
|
||||
canvas.DrawImage(imgfactory.Size(face, 480, 480).Image(), 20, 80)
|
||||
canvas.SetColor(color.Black)
|
||||
_, err = file.GetLazyData(text.BoldFontFile, control.Md5File, true)
|
||||
data, err := file.GetLazyData(text.BoldFontFile, control.Md5File, true)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
if err = canvas.LoadFontFace(text.BoldFontFile, 35); err != nil {
|
||||
if err = canvas.ParseFontFace(data, 35); err != nil {
|
||||
return "", err
|
||||
}
|
||||
if args[0] == "" {
|
||||
@@ -1367,12 +1366,12 @@ func eihei(cc *context, args ...string) (string, error) {
|
||||
return "", err
|
||||
}
|
||||
name := cc.usrdir + "eihei.png"
|
||||
im, err := img.LoadFirstFrame(cc.headimgsdir[0], 690, 690)
|
||||
im, err := imgfactory.LoadFirstFrame(cc.headimgsdir[0], 690, 690)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
imgnrgba := imgs[0].InsertBottom(im.Im, 450, 450, 121, 162).Im
|
||||
return "file:///" + name, writer.SavePNG2Path(name, imgnrgba)
|
||||
imgnrgba := imgs[0].InsertBottom(im.Image(), 450, 450, 121, 162).Image()
|
||||
return "file:///" + name, imgfactory.SavePNG2Path(name, imgnrgba)
|
||||
}
|
||||
|
||||
// fanfa 犯法
|
||||
@@ -1399,9 +1398,9 @@ func fanfa(cc *context, args ...string) (string, error) {
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
m1 := img.Rotate(face, 45, 110, 110)
|
||||
imgnrgba := imgs[0].InsertUp(m1.Im, 0, 0, 125, 360).Im
|
||||
return "file:///" + name, writer.SavePNG2Path(name, imgnrgba)
|
||||
m1 := imgfactory.Rotate(face, 45, 110, 110)
|
||||
imgnrgba := imgs[0].InsertUp(m1.Image(), 0, 0, 125, 360).Image()
|
||||
return "file:///" + name, imgfactory.SavePNG2Path(name, imgnrgba)
|
||||
}
|
||||
|
||||
// huai 怀
|
||||
@@ -1424,12 +1423,12 @@ func huai(cc *context, args ...string) (string, error) {
|
||||
return "", err
|
||||
}
|
||||
name := cc.usrdir + "huai.png"
|
||||
im, err := img.LoadFirstFrame(cc.headimgsdir[0], 640, 640)
|
||||
im, err := imgfactory.LoadFirstFrame(cc.headimgsdir[0], 640, 640)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
imgnrgba := imgs[0].InsertBottom(im.Im, 640, 640, 0, 0).Im
|
||||
return "file:///" + name, writer.SavePNG2Path(name, imgnrgba)
|
||||
imgnrgba := imgs[0].InsertBottom(im.Image(), 640, 640, 0, 0).Image()
|
||||
return "file:///" + name, imgfactory.SavePNG2Path(name, imgnrgba)
|
||||
}
|
||||
|
||||
// haowan 好玩
|
||||
@@ -1456,8 +1455,8 @@ func haowan(cc *context, args ...string) (string, error) {
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
imgnrgba := imgs[0].InsertBottom(face, 90, 90, 321, 172).Im
|
||||
return "file:///" + name, writer.SavePNG2Path(name, imgnrgba)
|
||||
imgnrgba := imgs[0].InsertBottom(face, 90, 90, 321, 172).Image()
|
||||
return "file:///" + name, imgfactory.SavePNG2Path(name, imgnrgba)
|
||||
}
|
||||
|
||||
// mengbi 蒙蔽
|
||||
@@ -1486,14 +1485,14 @@ func mengbi(cc *context, args ...string) (string, error) {
|
||||
}
|
||||
canvas := gg.NewContext(1080, 1080)
|
||||
canvas.DrawImage(back, 0, 0)
|
||||
canvas.DrawImage(img.Size(face, 100, 100).Im, 392, 460)
|
||||
canvas.DrawImage(img.Size(face, 100, 100).Im, 606, 443)
|
||||
canvas.DrawImage(imgfactory.Size(face, 100, 100).Image(), 392, 460)
|
||||
canvas.DrawImage(imgfactory.Size(face, 100, 100).Image(), 606, 443)
|
||||
canvas.SetColor(color.Black)
|
||||
_, err = file.GetLazyData(text.BoldFontFile, control.Md5File, true)
|
||||
data, err := file.GetLazyData(text.BoldFontFile, control.Md5File, true)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
if err = canvas.LoadFontFace(text.BoldFontFile, 80); err != nil {
|
||||
if err = canvas.ParseFontFace(data, 80); err != nil {
|
||||
return "", err
|
||||
}
|
||||
if args[0] == "" {
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
"time"
|
||||
|
||||
wyy "github.com/FloatTech/AnimeAPI/neteasemusic"
|
||||
"github.com/FloatTech/imgfactory"
|
||||
ctrl "github.com/FloatTech/zbpctrl"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/ctxext"
|
||||
@@ -19,7 +20,6 @@ import (
|
||||
|
||||
// 图片输出
|
||||
"github.com/FloatTech/floatbox/file"
|
||||
"github.com/FloatTech/floatbox/img/writer"
|
||||
"github.com/FloatTech/floatbox/process"
|
||||
"github.com/FloatTech/gg"
|
||||
"github.com/FloatTech/zbputils/img/text"
|
||||
@@ -406,18 +406,18 @@ func init() {
|
||||
canvas.SetRGB(1, 1, 1) // 白色
|
||||
canvas.Clear()
|
||||
/***********下载字体,可以注销掉***********/
|
||||
_, err = file.GetLazyData(text.BoldFontFile, control.Md5File, true)
|
||||
boldfd, err := file.GetLazyData(text.BoldFontFile, control.Md5File, true)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text(serviceErr, err))
|
||||
}
|
||||
_, err = file.GetLazyData(text.FontFile, control.Md5File, true)
|
||||
fd, err := file.GetLazyData(text.FontFile, control.Md5File, true)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text(serviceErr, err))
|
||||
}
|
||||
/***********设置字体颜色为黑色***********/
|
||||
canvas.SetRGB(0, 0, 0)
|
||||
/***********设置字体大小,并获取字体高度用来定位***********/
|
||||
if err = canvas.LoadFontFace(text.BoldFontFile, fontSize); err != nil {
|
||||
if err = canvas.ParseFontFace(boldfd, fontSize); err != nil {
|
||||
ctx.SendChain(message.Text(serviceErr, err))
|
||||
return
|
||||
}
|
||||
@@ -426,7 +426,7 @@ func init() {
|
||||
canvas.DrawString("序号\t\t歌单名\t\t歌曲数量\t\t网易云歌单ID", 20, 50-h) // 放置在中间位置
|
||||
canvas.DrawString("——————————————————————", 20, 70-h)
|
||||
/***********设置字体大小,并获取字体高度用来定位***********/
|
||||
if err = canvas.LoadFontFace(text.FontFile, fontSize); err != nil {
|
||||
if err = canvas.ParseFontFace(fd, fontSize); err != nil {
|
||||
ctx.SendChain(message.Text(serviceErr, err))
|
||||
return
|
||||
}
|
||||
@@ -446,11 +446,14 @@ func init() {
|
||||
canvas.DrawString("当前设置的默认歌单为: "+dlist.Name, 80, float64(85+20*j)-h)
|
||||
}
|
||||
}
|
||||
data, cl := writer.ToBytes(canvas.Image())
|
||||
data, err := imgfactory.ToBytes(canvas.Image())
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text(serviceErr, err))
|
||||
return
|
||||
}
|
||||
if id := ctx.SendChain(message.ImageBytes(data)); id.ID() == 0 {
|
||||
ctx.SendChain(message.Text("ERROR: 可能被风控了"))
|
||||
}
|
||||
cl()
|
||||
})
|
||||
engine.OnPrefix("设置猜歌默认歌单", zero.AdminPermission).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
|
||||
@@ -1,121 +0,0 @@
|
||||
// Package jikipedia 小鸡词典
|
||||
// 修改自https://github.com/TeamPGM/PagerMaid_Plugins_Pyro ,非常感谢!!
|
||||
package jikipedia
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/FloatTech/floatbox/binary"
|
||||
ctrl "github.com/FloatTech/zbpctrl"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/ctxext"
|
||||
"github.com/tidwall/gjson"
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
)
|
||||
|
||||
const (
|
||||
url = "https://api.jikipedia.com/go/search_entities"
|
||||
)
|
||||
|
||||
type value struct {
|
||||
Phrase string `json:"phrase"`
|
||||
Page int `json:"page"`
|
||||
Size int `json:"size"`
|
||||
}
|
||||
|
||||
func init() {
|
||||
// 初始化engine
|
||||
engine := control.Register("jikipedia", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Brief: "小鸡词典",
|
||||
Help: "- [查梗|小鸡词典][梗]",
|
||||
},
|
||||
)
|
||||
engine.OnPrefixGroup([]string{"小鸡词典", "查梗"}).Limit(ctxext.LimitByGroup).SetBlock(true).Handle(
|
||||
func(ctx *zero.Ctx) {
|
||||
keyWord := strings.Trim(ctx.State["args"].(string), " ")
|
||||
|
||||
definition, err := parseKeyword(keyWord)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
if definition.String() == "" {
|
||||
ctx.SendChain(message.Text("好像什么都没查到,换个关键词试一试?"))
|
||||
return
|
||||
}
|
||||
imgURL := definition.Get("images.0.scaled.path").String()
|
||||
ctx.SendChain(message.Text("【标题】:", definition.Get("term.title"),
|
||||
"\n【释义】:", definition.Get("plaintext"),
|
||||
"\n【原文】:https://jikipedia.com/definition/", definition.Get("id")),
|
||||
message.Image(imgURL))
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
func parseKeyword(keyWord string) (definition gjson.Result, err error) {
|
||||
client := &http.Client{}
|
||||
|
||||
values := value{Phrase: keyWord, Page: 1, Size: 10}
|
||||
jsonData, err := json.Marshal(values)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
var request *http.Request
|
||||
request, err = http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
request.Header = http.Header{
|
||||
"Accept": {"application/json, text/plain, */*"},
|
||||
"Accept-Encoding": {"gzip, deflate, br"},
|
||||
"Accept-Language": {"zh-CN,zh-TW;q=0.9,zh;q=0.8"},
|
||||
"Client": {"web"},
|
||||
"Client-Version": {"2.7.2g"},
|
||||
"Connection": {"keep-alive"},
|
||||
"Host": {"api.jikipedia.com"},
|
||||
"Origin": {"https://jikipedia.com"},
|
||||
"Referer": {"https://jikipedia.com/"},
|
||||
"Sec-Fetch-Dest": {"empty"},
|
||||
"Sec-Fetch-Mode": {"cors"},
|
||||
"Sec-Fetch-Site": {"same-site"},
|
||||
"Token": {""},
|
||||
"User-Agent": {"Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.0.0 Mobile Safari/537.36"},
|
||||
"XID": {"uNo5bL1nyNCp/Gm7lJAHQ91220HLbMT8jqk9IJYhtHA4ofP+zgxwM6lSDIKiYoppP2k1IW/1Vxc2vOVGxOOVReebsLmWPHhTs7NCRygfDkE="},
|
||||
"sec-ch-ua": {`" Not A;Brand";v="99", "Chromium";v="102", "Google Chrome";v="102"`},
|
||||
"sec-ch-ua-mobile": {"?1"},
|
||||
"sec-ch-ua-platform": {`"Android"`},
|
||||
}
|
||||
request.Header.Set("Content-Type", "application/json;charset=UTF-8")
|
||||
var response *http.Response
|
||||
response, err = client.Do(request)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
defer response.Body.Close()
|
||||
if response.StatusCode != http.StatusOK {
|
||||
extraInfo := ""
|
||||
if response.StatusCode == 423 {
|
||||
extraInfo = "\n调用过多被网站暂时封禁,请等待数个小时后使用该功能~"
|
||||
}
|
||||
s := fmt.Sprintf("status code: %d%s", response.StatusCode, extraInfo)
|
||||
err = errors.New(s)
|
||||
return
|
||||
}
|
||||
data, err := io.ReadAll(response.Body)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
gjson.Get(binary.BytesToString(data), "data").ForEach(func(key, value gjson.Result) bool {
|
||||
definition = value.Get("definitions.0")
|
||||
return definition.String() == ""
|
||||
})
|
||||
return
|
||||
}
|
||||
31
plugin/kfccrazythursday/kfccrazythursday.go
Normal file
31
plugin/kfccrazythursday/kfccrazythursday.go
Normal file
@@ -0,0 +1,31 @@
|
||||
// Package kfccrazythursday 疯狂星期四
|
||||
package kfccrazythursday
|
||||
|
||||
import (
|
||||
"github.com/FloatTech/floatbox/web"
|
||||
ctrl "github.com/FloatTech/zbpctrl"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
"github.com/tidwall/gjson"
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
)
|
||||
|
||||
const (
|
||||
crazyURL = "https://www.iculture.cc/demo/CrazyThursday/api/kfc.php"
|
||||
)
|
||||
|
||||
func init() {
|
||||
engine := control.Register("kfccrazythursday", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Brief: "疯狂星期四",
|
||||
Help: "疯狂星期四\n",
|
||||
})
|
||||
engine.OnFullMatch("疯狂星期四").SetBlock(true).Handle(func(ctx *zero.Ctx) {
|
||||
data, err := web.GetData(crazyURL)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("Error:", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Text(gjson.ParseBytes(data).Get("@this.0.content").String()))
|
||||
})
|
||||
}
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
|
||||
"github.com/FloatTech/AnimeAPI/tts/genshin"
|
||||
ctrl "github.com/FloatTech/zbpctrl"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/ctxext"
|
||||
@@ -16,12 +17,12 @@ import (
|
||||
const (
|
||||
jpapi = "https://moegoe.azurewebsites.net/api/speak?text=%s&id=%d"
|
||||
krapi = "https://moegoe.azurewebsites.net/api/speakkr?text=%s&id=%d"
|
||||
cnapi = "http://267978.proxy.nscc-gz.cn:8888?text=%s&speaker=%s"
|
||||
)
|
||||
|
||||
var speakers = map[string]uint{
|
||||
"宁宁": 0, "爱瑠": 1, "芳乃": 2, "茉子": 3, "丛雨": 4, "小春": 5, "七海": 6,
|
||||
"Sua": 0, "Mimiru": 1, "Arin": 2, "Yeonhwa": 3, "Yuhwa": 4, "Seonbae": 5,
|
||||
"派蒙": 0, "凯亚": 1, "安柏": 2, "丽莎": 3, "琴": 4, "香菱": 5, "枫原万叶": 6, "迪卢克": 7, "温迪": 8, "可莉": 9, "早柚": 10, "托马": 11, "芭芭拉": 12, "优菈": 13, "云堇": 14, "钟离": 15, "魈": 16, "凝光": 17, "雷电将军": 18, "北斗": 19, "甘雨": 20, "七七": 21, "刻晴": 22, "神里绫华": 23, "戴因斯雷布": 24, "雷泽": 25, "神里绫人": 26, "罗莎莉亚": 27, "阿贝多": 28, "八重神子": 29, "宵宫": 30, "荒泷一斗": 31, "九条裟罗": 32, "夜兰": 33, "珊瑚宫心海": 34, "五郎": 35, "散兵": 36, "女士": 37, "达达利亚": 38, "莫娜": 39, "班尼特": 40, "申鹤": 41, "行秋": 42, "烟绯": 43, "久岐忍": 44, "辛焱": 45, "砂糖": 46, "胡桃": 47, "重云": 48, "菲谢尔": 49, "诺艾尔": 50, "迪奥娜": 51, "鹿野院平藏": 52,
|
||||
}
|
||||
|
||||
func init() {
|
||||
@@ -30,7 +31,7 @@ func init() {
|
||||
Brief: "日韩中 VITS 模型拟声",
|
||||
Help: "- 让[宁宁|爱瑠|芳乃|茉子|丛雨|小春|七海]说(日语)\n" +
|
||||
"- 让[Sua|Mimiru|Arin|Yeonhwa|Yuhwa|Seonbae]说(韩语)\n" +
|
||||
"- 让[派蒙|空|荧|阿贝多|枫原万叶|温迪|八重神子|纳西妲|钟离|诺艾尔|凝光|托马|北斗|莫娜|荒泷一斗|提纳里|芭芭拉|艾尔海森|雷电将军|赛诺|琴|班尼特|五郎|神里绫华|迪希雅|夜兰|辛焱|安柏|宵宫|云堇|妮露|烟绯|鹿野院平藏|凯亚|达达利亚|迪卢克|可莉|早柚|香菱|重云|刻晴|久岐忍|珊瑚宫心海|迪奥娜|戴因斯雷布|魈|神里绫人|丽莎|优菈|凯瑟琳|雷泽|菲谢尔|九条裟罗|甘雨|行秋|胡桃|迪娜泽黛|柯莱|申鹤|砂糖|萍姥姥|奥兹|罗莎莉亚|式大将|哲平|坎蒂丝|托克|留云借风真君|昆钧|塞琉斯|多莉|大肉丸|莱依拉|散兵|拉赫曼|杜拉夫|阿守|玛乔丽|纳比尔|海芭夏|九条镰治|阿娜耶|阿晃|阿扎尔|七七|博士|白术|埃洛伊|大慈树王|女士|丽塔|失落迷迭|缭乱星棘|伊甸|伏特加女孩|狂热蓝调|莉莉娅|萝莎莉娅|八重樱|八重霞|卡莲|第六夜想曲|卡萝尔|姬子|极地战刃|布洛妮娅|次生银翼|理之律者|迷城骇兔|希儿|魇夜星渊|黑希儿|帕朵菲莉丝|天元骑英|幽兰黛尔|德丽莎|月下初拥|朔夜观星|暮光骑士|明日香|李素裳|格蕾修|梅比乌斯|渡鸦|人之律者|爱莉希雅|爱衣|天穹游侠|琪亚娜|空之律者|薪炎之律者|云墨丹心|符华|识之律者|维尔薇|芽衣|雷之律者|阿波尼亚]说(中文)",
|
||||
"- 让[派蒙|凯亚|安柏|丽莎|琴|香菱|枫原万叶|迪卢克|温迪|可莉|早柚|托马|芭芭拉|优菈|云堇|钟离|魈|凝光|雷电将军|北斗|甘雨|七七|刻晴|神里绫华|雷泽|神里绫人|罗莎莉亚|阿贝多|八重神子|宵宫|荒泷一斗|九条裟罗|夜兰|珊瑚宫心海|五郎|达达利亚|莫娜|班尼特|申鹤|行秋|烟绯|久岐忍|辛焱|砂糖|胡桃|重云|菲谢尔|诺艾尔|迪奥娜|鹿野院平藏]说(中文)",
|
||||
}).ApplySingle(ctxext.DefaultSingle)
|
||||
en.OnRegex("^让(宁宁|爱瑠|芳乃|茉子|丛雨|小春|七海)说([A-Za-z\\s\\d\u3005\u3040-\u30ff\u4e00-\u9fff\uff11-\uff19\uff21-\uff3a\uff41-\uff5a\uff66-\uff9d\\pP]+)$").Limit(ctxext.LimitByGroup).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
@@ -44,10 +45,23 @@ func init() {
|
||||
id := speakers[ctx.State["regex_matched"].([]string)[1]]
|
||||
ctx.SendChain(message.Record(fmt.Sprintf(krapi, url.QueryEscape(text), id)))
|
||||
})
|
||||
en.OnRegex("^让(派蒙|空|荧|阿贝多|枫原万叶|温迪|八重神子|纳西妲|钟离|诺艾尔|凝光|托马|北斗|莫娜|荒泷一斗|提纳里|芭芭拉|艾尔海森|雷电将军|赛诺|琴|班尼特|五郎|神里绫华|迪希雅|夜兰|辛焱|安柏|宵宫|云堇|妮露|烟绯|鹿野院平藏|凯亚|达达利亚|迪卢克|可莉|早柚|香菱|重云|刻晴|久岐忍|珊瑚宫心海|迪奥娜|戴因斯雷布|魈|神里绫人|丽莎|优菈|凯瑟琳|雷泽|菲谢尔|九条裟罗|甘雨|行秋|胡桃|迪娜泽黛|柯莱|申鹤|砂糖|萍姥姥|奥兹|罗莎莉亚|式大将|哲平|坎蒂丝|托克|留云借风真君|昆钧|塞琉斯|多莉|大肉丸|莱依拉|散兵|拉赫曼|杜拉夫|阿守|玛乔丽|纳比尔|海芭夏|九条镰治|阿娜耶|阿晃|阿扎尔|七七|博士|白术|埃洛伊|大慈树王|女士|丽塔|失落迷迭|缭乱星棘|伊甸|伏特加女孩|狂热蓝调|莉莉娅|萝莎莉娅|八重樱|八重霞|卡莲|第六夜想曲|卡萝尔|姬子|极地战刃|布洛妮娅|次生银翼|理之律者|迷城骇兔|希儿|魇夜星渊|黑希儿|帕朵菲莉丝|天元骑英|幽兰黛尔|德丽莎|月下初拥|朔夜观星|暮光骑士|明日香|李素裳|格蕾修|梅比乌斯|渡鸦|人之律者|爱莉希雅|爱衣|天穹游侠|琪亚娜|空之律者|薪炎之律者|云墨丹心|符华|识之律者|维尔薇|芽衣|雷之律者|阿波尼亚)说([\\s\u4e00-\u9fa5\\pP]+)$").Limit(ctxext.LimitByGroup).SetBlock(true).
|
||||
en.OnRegex("^让(派蒙|凯亚|安柏|丽莎|琴|香菱|枫原万叶|迪卢克|温迪|可莉|早柚|托马|芭芭拉|优菈|云堇|钟离|魈|凝光|雷电将军|北斗|甘雨|七七|刻晴|神里绫华|雷泽|神里绫人|罗莎莉亚|阿贝多|八重神子|宵宫|荒泷一斗|九条裟罗|夜兰|珊瑚宫心海|五郎|达达利亚|莫娜|班尼特|申鹤|行秋|烟绯|久岐忍|辛焱|砂糖|胡桃|重云|菲谢尔|诺艾尔|迪奥娜|鹿野院平藏)说([\\s\u4e00-\u9fa5\\pP]+)$").Limit(ctxext.LimitByGroup).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
text := ctx.State["regex_matched"].([]string)[2]
|
||||
speaker := ctx.State["regex_matched"].([]string)[1]
|
||||
ctx.SendChain(message.Record(fmt.Sprintf(cnapi, url.QueryEscape(text), speaker)))
|
||||
id := speakers[ctx.State["regex_matched"].([]string)[1]]
|
||||
c, ok := control.Lookup("tts")
|
||||
if !ok {
|
||||
ctx.SendChain(message.Text("ERROR: plugin tts not found"))
|
||||
return
|
||||
}
|
||||
var key struct {
|
||||
APIKey string
|
||||
}
|
||||
err := c.Manager.GetExtra(-1, &key)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Record(fmt.Sprintf(genshin.CNAPI, id, url.QueryEscape(text), url.QueryEscape(key.APIKey))))
|
||||
})
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/FloatTech/floatbox/math"
|
||||
"github.com/FloatTech/imgfactory"
|
||||
ctrl "github.com/FloatTech/zbpctrl"
|
||||
control "github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/ctxext"
|
||||
@@ -23,7 +24,6 @@ import (
|
||||
// 画图
|
||||
fcext "github.com/FloatTech/floatbox/ctxext"
|
||||
"github.com/FloatTech/floatbox/file"
|
||||
"github.com/FloatTech/floatbox/img/writer"
|
||||
"github.com/FloatTech/gg"
|
||||
"github.com/FloatTech/zbputils/img/text"
|
||||
)
|
||||
@@ -235,14 +235,14 @@ func init() {
|
||||
canvas.SetRGB(1, 1, 1) // 白色
|
||||
canvas.Clear()
|
||||
/***********下载字体,可以注销掉***********/
|
||||
_, err = file.GetLazyData(text.BoldFontFile, control.Md5File, true)
|
||||
data, err := file.GetLazyData(text.BoldFontFile, control.Md5File, true)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("[qqwife]ERROR: ", err))
|
||||
}
|
||||
/***********设置字体颜色为黑色***********/
|
||||
canvas.SetRGB(0, 0, 0)
|
||||
/***********设置字体大小,并获取字体高度用来定位***********/
|
||||
if err = canvas.LoadFontFace(text.BoldFontFile, fontSize*2); err != nil {
|
||||
if err = canvas.ParseFontFace(data, fontSize*2); err != nil {
|
||||
ctx.SendChain(message.Text("[qqwife]ERROR: ", err))
|
||||
return
|
||||
}
|
||||
@@ -251,7 +251,7 @@ func init() {
|
||||
canvas.DrawString("群老婆列表", (1500-sl)/2, 160-h) // 放置在中间位置
|
||||
canvas.DrawString("————————————————————", 0, 250-h)
|
||||
/***********设置字体大小,并获取字体高度用来定位***********/
|
||||
if err = canvas.LoadFontFace(text.BoldFontFile, fontSize); err != nil {
|
||||
if err = canvas.ParseFontFace(data, fontSize); err != nil {
|
||||
ctx.SendChain(message.Text("[qqwife]ERROR: ", err))
|
||||
return
|
||||
}
|
||||
@@ -263,9 +263,12 @@ func init() {
|
||||
canvas.DrawString(slicename(info[2], canvas), 800, float64(260+50*i)-h)
|
||||
canvas.DrawString("("+info[3]+")", 1150, float64(260+50*i)-h)
|
||||
}
|
||||
data, cl := writer.ToBytes(canvas.Image())
|
||||
data, err = imgfactory.ToBytes(canvas.Image())
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("[qqwife]ERROR: ", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.ImageBytes(data))
|
||||
cl()
|
||||
})
|
||||
engine.OnRegex(`^重置(所有|本群|/d+)?花名册$`, zero.SuperUserPermission, getdb).SetBlock(true).Limit(ctxext.LimitByUser).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/FloatTech/floatbox/math"
|
||||
"github.com/FloatTech/imgfactory"
|
||||
control "github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/ctxext"
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
@@ -15,7 +16,6 @@ import (
|
||||
|
||||
// 画图
|
||||
"github.com/FloatTech/floatbox/file"
|
||||
"github.com/FloatTech/floatbox/img/writer"
|
||||
"github.com/FloatTech/gg"
|
||||
"github.com/FloatTech/zbputils/img/text"
|
||||
|
||||
@@ -140,14 +140,14 @@ func init() {
|
||||
canvas.SetRGB(1, 1, 1) // 白色
|
||||
canvas.Clear()
|
||||
/***********下载字体***********/
|
||||
_, err = file.GetLazyData(text.BoldFontFile, control.Md5File, true)
|
||||
data, err := file.GetLazyData(text.BoldFontFile, control.Md5File, true)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("[ERROR]:ERROR: ", err))
|
||||
}
|
||||
/***********设置字体颜色为黑色***********/
|
||||
canvas.SetRGB(0, 0, 0)
|
||||
/***********设置字体大小,并获取字体高度用来定位***********/
|
||||
if err = canvas.LoadFontFace(text.BoldFontFile, fontSize*2); err != nil {
|
||||
if err = canvas.ParseFontFace(data, fontSize*2); err != nil {
|
||||
ctx.SendChain(message.Text("[ERROR]:ERROR: ", err))
|
||||
return
|
||||
}
|
||||
@@ -156,7 +156,7 @@ func init() {
|
||||
canvas.DrawString("你的好感度排行列表", (1100-sl)/2, 100) // 放置在中间位置
|
||||
canvas.DrawString("————————————————————", 0, 160)
|
||||
/***********设置字体大小,并获取字体高度用来定位***********/
|
||||
if err = canvas.LoadFontFace(text.BoldFontFile, fontSize); err != nil {
|
||||
if err = canvas.ParseFontFace(data, fontSize); err != nil {
|
||||
ctx.SendChain(message.Text("[ERROR]:ERROR: ", err))
|
||||
return
|
||||
}
|
||||
@@ -189,9 +189,12 @@ func init() {
|
||||
canvas.Fill()
|
||||
i++
|
||||
}
|
||||
data, cl := writer.ToBytes(canvas.Image())
|
||||
data, err = imgfactory.ToBytes(canvas.Image())
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("[qqwife]ERROR: ", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.ImageBytes(data))
|
||||
cl()
|
||||
})
|
||||
|
||||
engine.OnFullMatch("好感度数据整理", zero.SuperUserPermission, getdb).SetBlock(true).Limit(ctxext.LimitByUser).
|
||||
|
||||
@@ -14,13 +14,12 @@ import (
|
||||
|
||||
"github.com/FloatTech/AnimeAPI/qzone"
|
||||
"github.com/FloatTech/floatbox/binary"
|
||||
"github.com/FloatTech/floatbox/img/writer"
|
||||
"github.com/FloatTech/floatbox/web"
|
||||
"github.com/FloatTech/gg"
|
||||
"github.com/FloatTech/imgfactory"
|
||||
ctrl "github.com/FloatTech/zbpctrl"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/ctxext"
|
||||
"github.com/FloatTech/zbputils/img"
|
||||
"github.com/FloatTech/zbputils/img/text"
|
||||
"github.com/jinzhu/gorm"
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
@@ -324,7 +323,7 @@ func renderForwardMsg(qq int64, raw string) (base64Bytes []byte, err error) {
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
back := img.Size(faceImg, backX, backY).Circle(0).Im
|
||||
back := imgfactory.Size(faceImg, backX, backY).Circle(0).Image()
|
||||
m := message.ParseMessageFromString(raw)
|
||||
maxHeight += margin
|
||||
|
||||
@@ -349,7 +348,7 @@ func renderForwardMsg(qq int64, raw string) (base64Bytes []byte, err error) {
|
||||
}
|
||||
canvas.DrawImage(back, margin, maxHeight)
|
||||
if msgImg.Bounds().Dx() > 500 {
|
||||
msgImg = img.Size(msgImg, 500, msgImg.Bounds().Dy()*500/msgImg.Bounds().Dx()).Im
|
||||
msgImg = imgfactory.Size(msgImg, 500, msgImg.Bounds().Dy()*500/msgImg.Bounds().Dx()).Image()
|
||||
}
|
||||
canvas.DrawImage(msgImg, 2*margin+backX, maxHeight)
|
||||
if 3*margin+backX+msgImg.Bounds().Dx() > maxWidth {
|
||||
@@ -363,5 +362,5 @@ func renderForwardMsg(qq int64, raw string) (base64Bytes []byte, err error) {
|
||||
}
|
||||
im := canvas.Image().(*image.RGBA)
|
||||
nim := im.SubImage(image.Rect(0, 0, maxWidth, maxHeight))
|
||||
return writer.ToBase64(nim)
|
||||
return imgfactory.ToBase64(nim)
|
||||
}
|
||||
|
||||
@@ -20,15 +20,14 @@ import (
|
||||
|
||||
"github.com/FloatTech/AnimeAPI/nsfw"
|
||||
"github.com/FloatTech/AnimeAPI/scale"
|
||||
"github.com/FloatTech/imgfactory"
|
||||
|
||||
"github.com/FloatTech/floatbox/binary"
|
||||
"github.com/FloatTech/floatbox/file"
|
||||
"github.com/FloatTech/floatbox/img/writer"
|
||||
"github.com/FloatTech/floatbox/web"
|
||||
ctrl "github.com/FloatTech/zbpctrl"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/ctxext"
|
||||
"github.com/FloatTech/zbputils/img"
|
||||
)
|
||||
|
||||
func init() {
|
||||
@@ -81,10 +80,10 @@ func init() {
|
||||
x := im.Bounds().Size().X * 512 / px
|
||||
y := im.Bounds().Size().Y * 512 / px
|
||||
ctx.SendChain(message.Text("图片", im.Bounds().Size().X, "x", im.Bounds().Size().Y, "过大,调整图片至", x, "x", y))
|
||||
im = img.Size(im, x, y).Im
|
||||
im = imgfactory.Size(im, x, y).Image()
|
||||
w := binary.SelectWriter()
|
||||
defer binary.PutWriter(w)
|
||||
_, err = writer.WriteTo(im, w)
|
||||
_, err = imgfactory.WriteTo(im, w)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
|
||||
@@ -2,27 +2,31 @@
|
||||
package score
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"bytes"
|
||||
"image"
|
||||
"image/color"
|
||||
"math"
|
||||
"math/rand"
|
||||
"os"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/disintegration/imaging"
|
||||
|
||||
"github.com/FloatTech/ZeroBot-Plugin/kanban/banner"
|
||||
|
||||
"github.com/FloatTech/AnimeAPI/bilibili"
|
||||
"github.com/FloatTech/AnimeAPI/wallet"
|
||||
"github.com/FloatTech/floatbox/file"
|
||||
"github.com/FloatTech/floatbox/img/writer"
|
||||
"github.com/FloatTech/floatbox/process"
|
||||
"github.com/FloatTech/floatbox/web"
|
||||
"github.com/FloatTech/gg"
|
||||
"github.com/FloatTech/imgfactory"
|
||||
ctrl "github.com/FloatTech/zbpctrl"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/ctxext"
|
||||
"github.com/FloatTech/zbputils/img"
|
||||
"github.com/FloatTech/zbputils/img/text"
|
||||
"github.com/golang/freetype"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"github.com/wcharczuk/go-chart/v2"
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
@@ -110,7 +114,7 @@ func init() {
|
||||
}
|
||||
score := wallet.GetWalletOf(uid)
|
||||
// 绘图
|
||||
err = initPic(picFile)
|
||||
getAvatar, err := initPic(picFile, uid)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
@@ -121,62 +125,113 @@ func init() {
|
||||
return
|
||||
}
|
||||
// 避免图片过大,最大 1280*720
|
||||
back = img.Limit(back, 1280, 720)
|
||||
canvas := gg.NewContext(back.Bounds().Size().X, int(float64(back.Bounds().Size().Y)*1.7))
|
||||
canvas.SetRGB(1, 1, 1)
|
||||
canvas.Clear()
|
||||
back = imgfactory.Limit(back, 1280, 720)
|
||||
imgDX := back.Bounds().Dx()
|
||||
imgDY := back.Bounds().Dy()
|
||||
canvas := gg.NewContext(imgDX, imgDY)
|
||||
// draw Aero Style
|
||||
aeroStyle := gg.NewContext(imgDX-202, imgDY-202)
|
||||
aeroStyle.DrawImage(imaging.Blur(back, 2.5), -100, -100)
|
||||
// aero draw image.
|
||||
aeroStyle.DrawRoundedRectangle(0, 0, float64(imgDX-200), float64(imgDY-200), 16)
|
||||
// SideLine
|
||||
aeroStyle.SetLineWidth(3)
|
||||
aeroStyle.SetRGBA255(255, 255, 255, 100)
|
||||
aeroStyle.StrokePreserve()
|
||||
aeroStyle.SetRGBA255(255, 255, 255, 140)
|
||||
// fill
|
||||
aeroStyle.Fill()
|
||||
// draw background
|
||||
canvas.DrawImage(back, 0, 0)
|
||||
monthWord := now.Format("01/02")
|
||||
hourWord := getHourWord(now)
|
||||
_, err = file.GetLazyData(text.BoldFontFile, control.Md5File, true)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
if err = canvas.LoadFontFace(text.BoldFontFile, float64(back.Bounds().Size().X)*0.1); err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
canvas.SetRGB(0, 0, 0)
|
||||
canvas.DrawString(hourWord, float64(back.Bounds().Size().X)*0.1, float64(back.Bounds().Size().Y)*1.2)
|
||||
canvas.DrawString(monthWord, float64(back.Bounds().Size().X)*0.6, float64(back.Bounds().Size().Y)*1.2)
|
||||
nickName := ctx.CardOrNickName(uid)
|
||||
_, err = file.GetLazyData(text.FontFile, control.Md5File, true)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
if err = canvas.LoadFontFace(text.FontFile, float64(back.Bounds().Size().X)*0.04); err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
canvas.DrawString(nickName+fmt.Sprintf(" ATRI币+%d", add), float64(back.Bounds().Size().X)*0.1, float64(back.Bounds().Size().Y)*1.3)
|
||||
canvas.DrawString("当前ATRI币:"+strconv.FormatInt(int64(score), 10), float64(back.Bounds().Size().X)*0.1, float64(back.Bounds().Size().Y)*1.4)
|
||||
canvas.DrawString("LEVEL:"+strconv.FormatInt(int64(rank), 10), float64(back.Bounds().Size().X)*0.1, float64(back.Bounds().Size().Y)*1.5)
|
||||
canvas.DrawRectangle(float64(back.Bounds().Size().X)*0.1, float64(back.Bounds().Size().Y)*1.55, float64(back.Bounds().Size().X)*0.6, float64(back.Bounds().Size().Y)*0.1)
|
||||
canvas.SetRGB255(150, 150, 150)
|
||||
// Aero style combine
|
||||
canvas.DrawImage(aeroStyle.Image(), 100, 100)
|
||||
canvas.Fill()
|
||||
hourWord := getHourWord(now)
|
||||
avatar, _, err := image.Decode(bytes.NewReader(getAvatar))
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
avatarf := imgfactory.Size(avatar, 200, 200)
|
||||
canvas.DrawImage(avatarf.Circle(0).Image(), 120, 120)
|
||||
// draw info(name,coin,etc)
|
||||
canvas.SetRGB255(0, 0, 0)
|
||||
data, err := file.GetLazyData(text.BoldFontFile, control.Md5File, true)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
if err = canvas.ParseFontFace(data, 50); err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
// draw head
|
||||
nickName := ctx.CardOrNickName(uid)
|
||||
canvas.DrawStringWrapped(nickName, 350, 180, 0.5, 0.5, 0.5, 0.5, gg.AlignLeft)
|
||||
canvas.Fill()
|
||||
// main draw
|
||||
data, err = file.GetLazyData(text.FontFile, control.Md5File, true)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
if err = canvas.ParseFontFace(data, 30); err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
canvas.DrawStringAnchored(hourWord, 350, 280, 0, 0)
|
||||
canvas.DrawStringAnchored("ATRI币 + "+strconv.Itoa(add), 350, 350, 0, 0)
|
||||
canvas.DrawStringAnchored("当前ATRI币:"+strconv.Itoa(score), 350, 400, 0, 0)
|
||||
canvas.DrawStringAnchored("LEVEL: "+strconv.Itoa(getrank(level)), 350, 450, 0, 0)
|
||||
// draw Info(Time,etc.)
|
||||
getTime := time.Now().Format("2006-01-02 15:04:05")
|
||||
getTimeLengthWidth, getTimeLengthHight := canvas.MeasureString(getTime)
|
||||
canvas.DrawStringAnchored(getTime, float64(imgDX)-100-20-getTimeLengthWidth/2, float64(imgDY)-100-getTimeLengthHight, 0.5, 0.5) // time
|
||||
var nextrankScore int
|
||||
if rank < 10 {
|
||||
nextrankScore = rankArray[rank+1]
|
||||
} else {
|
||||
nextrankScore = SCOREMAX
|
||||
}
|
||||
canvas.SetRGB255(0, 0, 0)
|
||||
canvas.DrawRectangle(float64(back.Bounds().Size().X)*0.1, float64(back.Bounds().Size().Y)*1.55, float64(back.Bounds().Size().X)*0.6*float64(level)/float64(nextrankScore), float64(back.Bounds().Size().Y)*0.1)
|
||||
canvas.SetRGB255(102, 102, 102)
|
||||
nextLevelStyle := strconv.Itoa(level) + "/" + strconv.Itoa(nextrankScore)
|
||||
getLevelLength, _ := canvas.MeasureString(nextLevelStyle)
|
||||
canvas.DrawStringAnchored(nextLevelStyle, 100+getLevelLength, float64(imgDY)-100-getTimeLengthHight, 0.5, 0.5) // time
|
||||
canvas.Fill()
|
||||
canvas.DrawString(fmt.Sprintf("%d/%d", level, nextrankScore), float64(back.Bounds().Size().X)*0.75, float64(back.Bounds().Size().Y)*1.62)
|
||||
|
||||
f, err := os.Create(drawedFile)
|
||||
if err != nil {
|
||||
log.Errorln("[score]", err)
|
||||
data, cl := writer.ToBytes(canvas.Image())
|
||||
ctx.SendChain(message.ImageBytes(data))
|
||||
cl()
|
||||
canvas.SetRGB255(255, 255, 255)
|
||||
if err = canvas.ParseFontFace(data, 20); err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
_, err = writer.WriteTo(canvas.Image(), f)
|
||||
canvas.DrawStringAnchored("Created By Zerobot-Plugin "+banner.Version, float64(imgDX)/2, float64(imgDY)-20, 0.5, 0.5) // zbp
|
||||
canvas.SetRGB255(0, 0, 0)
|
||||
canvas.DrawStringAnchored("Created By Zerobot-Plugin "+banner.Version, float64(imgDX)/2-3, float64(imgDY)-19, 0.5, 0.5) // zbp
|
||||
canvas.SetRGB255(255, 255, 255)
|
||||
// Gradient
|
||||
grad := gg.NewLinearGradient(20, 320, 400, 20)
|
||||
grad.AddColorStop(0, color.RGBA{G: 255, A: 255})
|
||||
grad.AddColorStop(1, color.RGBA{B: 255, A: 255})
|
||||
grad.AddColorStop(0.5, color.RGBA{R: 255, A: 255})
|
||||
canvas.SetStrokeStyle(grad)
|
||||
canvas.SetLineWidth(4)
|
||||
// level array with rectangle work.
|
||||
gradLineLength := float64(imgDX-120) - 120
|
||||
renderLine := (float64(level) / float64(nextrankScore)) * gradLineLength
|
||||
canvas.MoveTo(120, float64(imgDY)-102)
|
||||
canvas.LineTo(120+renderLine, float64(imgDY)-102)
|
||||
canvas.ClosePath()
|
||||
canvas.Stroke()
|
||||
// done.
|
||||
f, err := os.Create(drawedFile)
|
||||
if err != nil {
|
||||
data, err := imgfactory.ToBytes(canvas.Image())
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.ImageBytes(data))
|
||||
return
|
||||
}
|
||||
_, err = imgfactory.WriteTo(canvas.Image(), f)
|
||||
_ = f.Close()
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
@@ -184,6 +239,7 @@ func init() {
|
||||
}
|
||||
ctx.SendChain(message.Image("file:///" + file.BOTPATH + "/" + drawedFile))
|
||||
})
|
||||
|
||||
engine.OnPrefix("获得签到背景", zero.OnlyGroup).Limit(ctxext.LimitByGroup).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
param := ctx.State["args"].(string)
|
||||
@@ -303,18 +359,22 @@ func getrank(count int) int {
|
||||
return -1
|
||||
}
|
||||
|
||||
func initPic(picFile string) error {
|
||||
func initPic(picFile string, uid int64) (avatar []byte, err error) {
|
||||
if file.IsExist(picFile) {
|
||||
return nil
|
||||
return nil, nil
|
||||
}
|
||||
defer process.SleepAbout1sTo2s()
|
||||
url, err := bilibili.GetRealURL(backgroundURL)
|
||||
if err != nil {
|
||||
return err
|
||||
return nil, err
|
||||
}
|
||||
data, err := web.RequestDataWith(web.NewDefaultClient(), url, "", referer, "", nil)
|
||||
if err != nil {
|
||||
return err
|
||||
return nil, err
|
||||
}
|
||||
return os.WriteFile(picFile, data, 0644)
|
||||
avatar, err = web.GetData("http://q4.qlogo.cn/g?b=qq&nk=" + strconv.FormatInt(uid, 10) + "&s=640")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return avatar, os.WriteFile(picFile, data, 0644)
|
||||
}
|
||||
|
||||
321
plugin/vtbmusic/vtbmusic.go
Normal file
321
plugin/vtbmusic/vtbmusic.go
Normal file
@@ -0,0 +1,321 @@
|
||||
// Package vtbmusic vtb点歌
|
||||
package vtbmusic
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"net/http"
|
||||
"os"
|
||||
"path"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/FloatTech/floatbox/binary"
|
||||
"github.com/FloatTech/floatbox/file"
|
||||
"github.com/FloatTech/floatbox/web"
|
||||
ctrl "github.com/FloatTech/zbpctrl"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/img/text"
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
)
|
||||
|
||||
const (
|
||||
getGroupListURL = "https://aqua.chat/v1/GetGroupsList"
|
||||
getMusicListURL = "https://aqua.chat/v1/GetMusicList"
|
||||
fileURL = "https://cdn.aqua.chat/"
|
||||
musicListBody = `{"search":{"condition":"VocalId","keyword":"%v"},"sortField":"CreateTime","sortType":"desc","pageIndex":1,"pageRows":10000}`
|
||||
)
|
||||
|
||||
type groupsList struct {
|
||||
Total int `json:"Total"`
|
||||
Data []struct {
|
||||
ID string `json:"Id"`
|
||||
CreateTime string `json:"CreateTime"`
|
||||
Name string `json:"Name"`
|
||||
GroupImg string `json:"GroupImg"`
|
||||
VocalList []struct {
|
||||
ID string `json:"Id"`
|
||||
CreateTime string `json:"CreateTime"`
|
||||
ChineseName string `json:"ChineseName"`
|
||||
OriginName string `json:"OriginName"`
|
||||
AvatarImg string `json:"AvatarImg"`
|
||||
} `json:"VocalList"`
|
||||
} `json:"Data"`
|
||||
Success bool `json:"Success"`
|
||||
ErrorCode int `json:"ErrorCode"`
|
||||
Msg interface{} `json:"Msg"`
|
||||
}
|
||||
|
||||
type musicList struct {
|
||||
Total int `json:"Total"`
|
||||
Data []struct {
|
||||
ID string `json:"Id"`
|
||||
CreateTime string `json:"CreateTime"`
|
||||
PublishTime interface{} `json:"PublishTime"`
|
||||
CreatorID interface{} `json:"CreatorId"`
|
||||
CreatorRealName interface{} `json:"CreatorRealName"`
|
||||
Deleted bool `json:"Deleted"`
|
||||
OriginName string `json:"OriginName"`
|
||||
VocalID string `json:"VocalId"`
|
||||
VocalName string `json:"VocalName"`
|
||||
CoverImg string `json:"CoverImg"`
|
||||
Music string `json:"Music"`
|
||||
Lyric interface{} `json:"Lyric"`
|
||||
CDN string `json:"CDN"`
|
||||
BiliBili interface{} `json:"BiliBili"`
|
||||
YouTube interface{} `json:"YouTube"`
|
||||
Twitter interface{} `json:"Twitter"`
|
||||
Likes interface{} `json:"Likes"`
|
||||
Length float64 `json:"Length"`
|
||||
Label interface{} `json:"Label"`
|
||||
IsLike bool `json:"isLike"`
|
||||
Duration float64 `json:"Duration"`
|
||||
Source interface{} `json:"Source"`
|
||||
SourceName interface{} `json:"SourceName"`
|
||||
Statis struct {
|
||||
PlayCount int `json:"PlayCount"`
|
||||
CommentCount int `json:"CommentCount"`
|
||||
LikeCount int `json:"LikeCount"`
|
||||
ShareCount int `json:"ShareCount"`
|
||||
} `json:"Statis"`
|
||||
VocalList []struct {
|
||||
ID string `json:"Id"`
|
||||
Cn string `json:"cn"`
|
||||
Jp string `json:"jp"`
|
||||
En string `json:"en"`
|
||||
Originlang string `json:"originlang"`
|
||||
} `json:"VocalList"`
|
||||
} `json:"Data"`
|
||||
Success bool `json:"Success"`
|
||||
ErrorCode int `json:"ErrorCode"`
|
||||
Msg interface{} `json:"Msg"`
|
||||
}
|
||||
|
||||
func init() { // 插件主体
|
||||
engine := control.Register("vtbmusic", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Brief: "vtbmusic.com点歌",
|
||||
Help: "- vtb点歌\n" +
|
||||
"- vtb随机点歌",
|
||||
PrivateDataFolder: "vtbmusic",
|
||||
})
|
||||
storePath := engine.DataFolder()
|
||||
// 开启
|
||||
engine.OnFullMatch(`vtb点歌`).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
next := zero.NewFutureEvent("message", 999, false, ctx.CheckSession(), zero.RegexRule(`^\d+$`))
|
||||
recv, cancel := next.Repeat()
|
||||
defer cancel()
|
||||
i := 0
|
||||
paras := [3]int{}
|
||||
data, err := web.PostData(getGroupListURL, "application/json", strings.NewReader(`{"PageIndex":1,"PageRows":9999}`))
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
var (
|
||||
gl groupsList
|
||||
ml musicList
|
||||
num int
|
||||
imageBytes []byte
|
||||
)
|
||||
err = json.Unmarshal(data, &gl)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
tex := "请输入群组序号\n"
|
||||
for i, v := range gl.Data {
|
||||
tex += fmt.Sprintf("%d. %s\n", i, v.Name)
|
||||
}
|
||||
imageBytes, err = text.RenderToBase64(tex, text.FontFile, 400, 20)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
if id := ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Image("base64://"+binary.BytesToString(imageBytes))); id.ID() == 0 {
|
||||
ctx.SendChain(message.Text("ERROR: 可能被风控了"))
|
||||
}
|
||||
for {
|
||||
select {
|
||||
case <-time.After(time.Second * 120):
|
||||
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text("vtb点歌超时"))
|
||||
return
|
||||
case c := <-recv:
|
||||
msg := c.Event.Message.ExtractPlainText()
|
||||
num, err = strconv.Atoi(msg)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text("请输入数字!"))
|
||||
continue
|
||||
}
|
||||
switch i {
|
||||
case 0:
|
||||
if num < 0 || num >= len(gl.Data) {
|
||||
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text("序号非法!"))
|
||||
continue
|
||||
}
|
||||
if len(gl.Data[num].VocalList) == 0 {
|
||||
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text("无内容, 点歌失败"))
|
||||
return
|
||||
}
|
||||
paras[0] = num
|
||||
tex = "请输入vtb序号\n"
|
||||
for i, v := range gl.Data[paras[0]].VocalList {
|
||||
tex += fmt.Sprintf("%d. %s\n", i, v.OriginName)
|
||||
}
|
||||
imageBytes, err = text.RenderToBase64(tex, text.FontFile, 400, 20)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
if id := ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Image("base64://"+binary.BytesToString(imageBytes))); id.ID() == 0 {
|
||||
ctx.SendChain(message.Text("ERROR: 可能被风控了"))
|
||||
}
|
||||
case 1:
|
||||
if num < 0 || num >= len(gl.Data[paras[0]].VocalList) {
|
||||
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text("序号非法!"))
|
||||
continue
|
||||
}
|
||||
paras[1] = num
|
||||
data, err := web.PostData(getMusicListURL, "application/json", strings.NewReader(fmt.Sprintf(musicListBody, gl.Data[paras[0]].VocalList[paras[1]].ID)))
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
err = json.Unmarshal(data, &ml)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
if len(ml.Data) == 0 {
|
||||
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text("无内容, 点歌失败"))
|
||||
return
|
||||
}
|
||||
tex = "请输入歌曲序号\n"
|
||||
for i, v := range ml.Data {
|
||||
tex += fmt.Sprintf("%d. %s\n", i, v.OriginName)
|
||||
}
|
||||
imageBytes, err = text.RenderToBase64(tex, text.FontFile, 400, 20)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
if id := ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Image("base64://"+binary.BytesToString(imageBytes))); id.ID() == 0 {
|
||||
ctx.SendChain(message.Text("ERROR: 可能被风控了"))
|
||||
}
|
||||
case 2:
|
||||
if num < 0 || num >= len(ml.Data) {
|
||||
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text("序号非法!"))
|
||||
continue
|
||||
}
|
||||
paras[2] = num
|
||||
// 最后播放歌曲
|
||||
groupName := gl.Data[paras[0]].Name
|
||||
vtbName := gl.Data[paras[0]].VocalList[paras[1]].OriginName
|
||||
musicName := ml.Data[paras[2]].OriginName
|
||||
recURL := fileURL + ml.Data[paras[2]].Music
|
||||
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text("请欣赏", groupName, "-", vtbName, "的《", musicName, "》"))
|
||||
recordFile := storePath + fmt.Sprintf("%d-%d-%d", paras[0], paras[1], paras[2]) + path.Ext(recURL)
|
||||
if file.IsExist(recordFile) {
|
||||
ctx.SendChain(message.Record("file:///" + file.BOTPATH + "/" + recordFile))
|
||||
return
|
||||
}
|
||||
err = dlrec(recordFile, recURL)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Record("file:///" + file.BOTPATH + "/" + recordFile))
|
||||
return
|
||||
}
|
||||
i++
|
||||
}
|
||||
}
|
||||
})
|
||||
engine.OnFullMatch(`vtb随机点歌`).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
var (
|
||||
paras = [3]int{}
|
||||
gl groupsList
|
||||
ml musicList
|
||||
)
|
||||
data, err := web.PostData(getGroupListURL, "application/json", strings.NewReader(`{"PageIndex":1,"PageRows":9999}`))
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
err = json.Unmarshal(data, &gl)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
if len(gl.Data) == 0 {
|
||||
ctx.SendChain(message.Text("ERROR: 数组为空"))
|
||||
return
|
||||
}
|
||||
paras[0] = rand.Intn(len(gl.Data))
|
||||
for len(gl.Data[paras[0]].VocalList) == 0 {
|
||||
paras[0] = rand.Intn(len(gl.Data))
|
||||
}
|
||||
paras[1] = rand.Intn(len(gl.Data[paras[0]].VocalList))
|
||||
data, err = web.PostData(getMusicListURL, "application/json", strings.NewReader(fmt.Sprintf(musicListBody, gl.Data[paras[0]].VocalList[paras[1]].ID)))
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
err = json.Unmarshal(data, &ml)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
for len(ml.Data) == 0 {
|
||||
paras[1] = rand.Intn(len(gl.Data[paras[0]].VocalList))
|
||||
data, err = web.PostData(getMusicListURL, "application/json", strings.NewReader(fmt.Sprintf(musicListBody, gl.Data[paras[0]].VocalList[paras[1]].ID)))
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
err = json.Unmarshal(data, &ml)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
}
|
||||
paras[2] = rand.Intn(len(ml.Data))
|
||||
// 最后播放歌曲
|
||||
groupName := gl.Data[paras[0]].Name
|
||||
vtbName := gl.Data[paras[0]].VocalList[paras[1]].OriginName
|
||||
musicName := ml.Data[paras[2]].OriginName
|
||||
recURL := fileURL + ml.Data[paras[2]].Music
|
||||
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text("请欣赏", groupName, "-", vtbName, "的《", musicName, "》"))
|
||||
recordFile := storePath + fmt.Sprintf("%d-%d-%d", paras[0], paras[1], paras[2]) + path.Ext(recURL)
|
||||
if file.IsExist(recordFile) {
|
||||
ctx.SendChain(message.Record("file:///" + file.BOTPATH + "/" + recordFile))
|
||||
return
|
||||
}
|
||||
err = dlrec(recordFile, recURL)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Record("file:///" + file.BOTPATH + "/" + recordFile))
|
||||
})
|
||||
}
|
||||
|
||||
func dlrec(recordFile, recordURL string) error {
|
||||
if file.IsNotExist(recordFile) {
|
||||
data, err := web.RequestDataWithHeaders(web.NewTLS12Client(), recordURL, "GET", func(r *http.Request) error {
|
||||
r.Header.Set("Content-Type", "application/x-www-form-urlencoded")
|
||||
r.Header.Set("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:6.0) Gecko/20100101 Firefox/6.0")
|
||||
return nil
|
||||
}, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return os.WriteFile(recordFile, data, 0666)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -13,10 +13,10 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/FloatTech/AnimeAPI/tl"
|
||||
"github.com/FloatTech/imgfactory"
|
||||
|
||||
"github.com/FloatTech/floatbox/binary"
|
||||
fcext "github.com/FloatTech/floatbox/ctxext"
|
||||
"github.com/FloatTech/floatbox/img/writer"
|
||||
"github.com/FloatTech/gg"
|
||||
ctrl "github.com/FloatTech/zbpctrl"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
@@ -135,14 +135,13 @@ func init() {
|
||||
return
|
||||
}
|
||||
game := newWordleGame(target)
|
||||
_, img, cl, _ := game("")
|
||||
_, img, _ := game("")
|
||||
ctx.Send(
|
||||
message.ReplyWithMessage(ctx.Event.MessageID,
|
||||
message.ImageBytes(img),
|
||||
message.Text("你有", class+1, "次机会猜出单词,单词长度为", class, ",请发送单词"),
|
||||
),
|
||||
)
|
||||
cl()
|
||||
var next *zero.FutureEvent
|
||||
if ctx.State["regex_matched"].([]string)[1] == "个人" {
|
||||
next = zero.NewFutureEvent("message", 999, false, zero.RegexRule(fmt.Sprintf(`^([A-Z]|[a-z]){%d}$`, class)),
|
||||
@@ -170,7 +169,7 @@ func init() {
|
||||
case c := <-recv:
|
||||
tick.Reset(105 * time.Second)
|
||||
after.Reset(120 * time.Second)
|
||||
win, img, cl, err = game(c.Event.Message.String())
|
||||
win, img, err = game(c.Event.Message.String())
|
||||
switch {
|
||||
case win:
|
||||
tick.Stop()
|
||||
@@ -181,7 +180,6 @@ func init() {
|
||||
message.Text("太棒了,你猜出来了!答案是: ", target, "(", tt, ")"),
|
||||
),
|
||||
)
|
||||
cl()
|
||||
return
|
||||
case err == errTimesRunOut:
|
||||
tick.Stop()
|
||||
@@ -192,7 +190,6 @@ func init() {
|
||||
message.Text("游戏结束...答案是: ", target, "(", tt, ")"),
|
||||
),
|
||||
)
|
||||
cl()
|
||||
return
|
||||
case err == errLengthNotEnough:
|
||||
ctx.Send(
|
||||
@@ -212,17 +209,16 @@ func init() {
|
||||
message.ImageBytes(img),
|
||||
),
|
||||
)
|
||||
cl()
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func newWordleGame(target string) func(string) (bool, []byte, func(), error) {
|
||||
func newWordleGame(target string) func(string) (bool, []byte, error) {
|
||||
var class = len(target)
|
||||
record := make([]string, 0, len(target)+1)
|
||||
return func(s string) (win bool, data []byte, cl func(), err error) {
|
||||
return func(s string) (win bool, data []byte, err error) {
|
||||
if s != "" {
|
||||
s = strings.ToLower(s)
|
||||
if target == s {
|
||||
@@ -241,6 +237,7 @@ func newWordleGame(target string) func(string) (bool, []byte, func(), error) {
|
||||
record = append(record, s)
|
||||
if len(record) >= cap(record) {
|
||||
err = errTimesRunOut
|
||||
return
|
||||
}
|
||||
}
|
||||
var side = 20
|
||||
@@ -271,7 +268,7 @@ func newWordleGame(target string) func(string) (bool, []byte, func(), error) {
|
||||
}
|
||||
}
|
||||
}
|
||||
data, cl = writer.ToBytes(ctx.Image())
|
||||
data, err = imgfactory.ToBytes(ctx.Image())
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
2
run.bat
2
run.bat
@@ -3,5 +3,5 @@ go env -w GOPROXY=https://goproxy.cn,direct
|
||||
go env -w GO111MODULE=auto
|
||||
go mod tidy
|
||||
::go build -ldflags="-s -w" -o ZeroBot-Plugin.exe
|
||||
go run main.go main_win.go
|
||||
go run main.go
|
||||
pause
|
||||
|
||||
2
run.sh
2
run.sh
@@ -3,4 +3,4 @@ go env -w GOPROXY=https://goproxy.cn,direct
|
||||
go env -w GO111MODULE=auto
|
||||
go mod tidy
|
||||
#go build -ldflags="-s -w" -o ZeroBot-Plugin
|
||||
go run main.go
|
||||
go run main.go
|
||||
|
||||
103
winres/gen/json.go
Normal file
103
winres/gen/json.go
Normal file
@@ -0,0 +1,103 @@
|
||||
// Package main generates winres.json
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/FloatTech/ZeroBot-Plugin/kanban/banner"
|
||||
)
|
||||
|
||||
const js = `{
|
||||
"RT_GROUP_ICON": {
|
||||
"APP": {
|
||||
"0000": [
|
||||
"icon.png",
|
||||
"icon16.png"
|
||||
]
|
||||
}
|
||||
},
|
||||
"RT_MANIFEST": {
|
||||
"#1": {
|
||||
"0409": {
|
||||
"identity": {
|
||||
"name": "ZeroBot-Plugin",
|
||||
"version": "%s"
|
||||
},
|
||||
"description": "",
|
||||
"minimum-os": "vista",
|
||||
"execution-level": "as invoker",
|
||||
"ui-access": false,
|
||||
"auto-elevate": false,
|
||||
"dpi-awareness": "system",
|
||||
"disable-theming": false,
|
||||
"disable-window-filtering": false,
|
||||
"high-resolution-scrolling-aware": false,
|
||||
"ultra-high-resolution-scrolling-aware": false,
|
||||
"long-path-aware": false,
|
||||
"printer-driver-isolation": false,
|
||||
"gdi-scaling": false,
|
||||
"segment-heap": false,
|
||||
"use-common-controls-v6": false
|
||||
}
|
||||
}
|
||||
},
|
||||
"RT_VERSION": {
|
||||
"#1": {
|
||||
"0000": {
|
||||
"fixed": {
|
||||
"file_version": "%s",
|
||||
"product_version": "%s",
|
||||
"timestamp": "%s"
|
||||
},
|
||||
"info": {
|
||||
"0409": {
|
||||
"Comments": "OneBot plugins based on ZeroBot",
|
||||
"CompanyName": "FloatTech",
|
||||
"FileDescription": "https://github.com/FloatTech/ZeroBot-Plugin",
|
||||
"FileVersion": "%s",
|
||||
"InternalName": "",
|
||||
"LegalCopyright": "%s",
|
||||
"LegalTrademarks": "",
|
||||
"OriginalFilename": "ZBP.EXE",
|
||||
"PrivateBuild": "",
|
||||
"ProductName": "ZeroBot-Plugin",
|
||||
"ProductVersion": "%s",
|
||||
"SpecialBuild": ""
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}`
|
||||
|
||||
const timeformat = `2006-01-02T15:04:05+08:00`
|
||||
|
||||
func main() {
|
||||
f, err := os.Create("winres.json")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
defer f.Close()
|
||||
i := strings.LastIndex(banner.Version, "-")
|
||||
if i <= 0 {
|
||||
i = len(banner.Version)
|
||||
}
|
||||
commitcnt := strings.Builder{}
|
||||
commitcnt.WriteString(banner.Version[1:i])
|
||||
commitcnt.WriteByte('.')
|
||||
commitcntcmd := exec.Command("git", "rev-list", "--count", "master")
|
||||
commitcntcmd.Stdout = &commitcnt
|
||||
err = commitcntcmd.Run()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
fv := commitcnt.String()[:commitcnt.Len()-1]
|
||||
_, err = fmt.Fprintf(f, js, fv, fv, banner.Version, time.Now().Format(timeformat), fv, banner.Copyright+". All Rights Reserved.", banner.Version)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
BIN
winres/icon.png
Normal file
BIN
winres/icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 31 KiB |
BIN
winres/icon16.png
Normal file
BIN
winres/icon16.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.8 KiB |
4
winres/init.go
Normal file
4
winres/init.go
Normal file
@@ -0,0 +1,4 @@
|
||||
// Package winres 生成windows资源
|
||||
package winres
|
||||
|
||||
//go:generate go run github.com/FloatTech/ZeroBot-Plugin/winres/gen
|
||||
62
winres/winres.json
Normal file
62
winres/winres.json
Normal file
@@ -0,0 +1,62 @@
|
||||
{
|
||||
"RT_GROUP_ICON": {
|
||||
"APP": {
|
||||
"0000": [
|
||||
"icon.png",
|
||||
"icon16.png"
|
||||
]
|
||||
}
|
||||
},
|
||||
"RT_MANIFEST": {
|
||||
"#1": {
|
||||
"0409": {
|
||||
"identity": {
|
||||
"name": "ZeroBot-Plugin",
|
||||
"version": "1.7.0.1721"
|
||||
},
|
||||
"description": "",
|
||||
"minimum-os": "vista",
|
||||
"execution-level": "as invoker",
|
||||
"ui-access": false,
|
||||
"auto-elevate": false,
|
||||
"dpi-awareness": "system",
|
||||
"disable-theming": false,
|
||||
"disable-window-filtering": false,
|
||||
"high-resolution-scrolling-aware": false,
|
||||
"ultra-high-resolution-scrolling-aware": false,
|
||||
"long-path-aware": false,
|
||||
"printer-driver-isolation": false,
|
||||
"gdi-scaling": false,
|
||||
"segment-heap": false,
|
||||
"use-common-controls-v6": false
|
||||
}
|
||||
}
|
||||
},
|
||||
"RT_VERSION": {
|
||||
"#1": {
|
||||
"0000": {
|
||||
"fixed": {
|
||||
"file_version": "1.7.0.1721",
|
||||
"product_version": "v1.7.0-beta1",
|
||||
"timestamp": "2023-03-01T16:16:47+08:00"
|
||||
},
|
||||
"info": {
|
||||
"0409": {
|
||||
"Comments": "OneBot plugins based on ZeroBot",
|
||||
"CompanyName": "FloatTech",
|
||||
"FileDescription": "https://github.com/FloatTech/ZeroBot-Plugin",
|
||||
"FileVersion": "1.7.0.1721",
|
||||
"InternalName": "",
|
||||
"LegalCopyright": "© 2020 - 2023 FloatTech. All Rights Reserved.",
|
||||
"LegalTrademarks": "",
|
||||
"OriginalFilename": "ZBP.EXE",
|
||||
"PrivateBuild": "",
|
||||
"ProductName": "ZeroBot-Plugin",
|
||||
"ProductVersion": "v1.7.0-beta1",
|
||||
"SpecialBuild": ""
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user