Skip to content
This repository has been archived by the owner on Oct 8, 2021. It is now read-only.

Commit

Permalink
🔖 Update to 1.0.6
Browse files Browse the repository at this point in the history
  • Loading branch information
kanrichan committed Dec 14, 2020
1 parent ba41ade commit 0b77e23
Show file tree
Hide file tree
Showing 18 changed files with 554 additions and 223 deletions.
29 changes: 1 addition & 28 deletions client/GO/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ func main() {
Port: ft.Conf.Port,
AccessToken: ft.Conf.AccessToken,
NickName: []string{"ft"},
CommandPrefix: "ft",
CommandPrefix: "",
SuperUsers: []string{ft.Conf.Master},
})
select {}
Expand All @@ -20,30 +20,3 @@ func main() {
func init() {
ft.Init()
}

/*
// 处理消息
func onGroupMsg(botID int64, messageID int64, groupID int64, userID int64, message string) {
if message == "xqgo -v" || message == "xqgo -version" {
core.SendGroupMsg(botID, groupID, "[XQ-GO] Version 1.0.1 By Kanri", 0)
} else if message == "ft -v" || message == "ft -version" {
core.SendGroupMsg(botID, groupID, "[fortune-运势] Version 1.0.5 By Kanri", 0)
} else if message == "ft -r" || message == "ft -reload" {
ft.Init()
core.SendGroupMsg(botID, groupID, "[fortune-运势] Fortune Reloaded!", 0)
}
ft.App(botID, messageID, groupID, userID, message)
}
func onPrivateMsg(botID int64, messageID int64, userID int64, message string) {
if message == "xqgo -v" || message == "xqgo -version" {
core.SendGroupMsg(botID, userID, "[XQ-GO] Version 1.0.1 By Kanri", 0)
} else if message == "ft -v" || message == "ft -version" {
core.SendGroupMsg(botID, userID, "[fortune-运势] Version 1.0.5 By Kanri", 0)
} else if message == "ft -r" || message == "ft -reload" {
ft.Init()
core.SendGroupMsg(botID, userID, "[fortune-运势] Fortune Reloaded!", 0)
}
//ft.App(botID, messageID, 0, userID, message)
}
*/
4 changes: 2 additions & 2 deletions client/GO/data/config.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
插件版本: "5"
监听地址: 127.0.0.1
监听端口: "8080"
监听端口: "2333"
Token: ""
主人QQ: "0"
主人QQ: "825111790"
运势设置:
- 设置群号: 默认
群聊设置:
Expand Down
Binary file modified client/GO/data/output.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
32 changes: 23 additions & 9 deletions client/GO/fortune/fortune.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ var ApiPort = "10086"
var ApiFortune = "http://" + ApiHost + ":" + ApiPort + "/fortune"
var ApiPic = "http://" + ApiHost + ":" + ApiPort + "/fortune.jpg"

var ClientKey = "233666"
var ClientName = "xq"
var ClientKey = "31415926"
var ClientName = "go"
var ClientVer = "5"

var AppPath = strings.Replace(PathExecute(), ":\\", ":\\\\", -1) + "data\\"
Expand All @@ -27,6 +27,13 @@ var ResultPath = AppPath + "output.txt"
var Conf = &YamlConfig{}

func init() {
OutPutLog(`
====================[fortune-运势]====================
* OneBot + ZeroBot + Golang
* Copyright © 2018-2020 Kanri,All Rights Reserved
* Project: https://github.com/Yiwen-Chan/fortune
=======================================================
`)
a := testPlugin{}
zero.RegisterPlugin(a) // 注册插件
}
Expand All @@ -37,8 +44,8 @@ func (testPlugin) GetPluginInfo() zero.PluginInfo { // 返回插件信息
return zero.PluginInfo{
Author: "kanri",
PluginName: "fortune-运势",
Version: "1.0.5",
Details: "项目地址 https://github.com/Yiwen-Chan/fortune",
Version: "1.0.6",
Details: "",
}
}

Expand All @@ -47,6 +54,15 @@ func (testPlugin) Start() { // 插件主体
Handle(
func(matcher *zero.Matcher, event zero.Event, state zero.State) zero.Response {
App(0, 0, event.GroupID, event.UserID, event.RawMessage)
if event.RawMessage == "ft -v" || event.RawMessage == "ft -version" {
OutPutLog("Fortune-运势 Version 1.0.6 BY Kanri")
AllSendMsg(0, event.GroupID, event.UserID, "Fortune-运势 Version 1.0.6 BY Kanri")
}
if event.RawMessage == "ft -r" || event.RawMessage == "ft -reload" {
Init()
OutPutLog("Setting is already reload!")
AllSendMsg(0, event.GroupID, event.UserID, "Setting is already reload!")
}
return zero.SuccessResponse
},
)
Expand All @@ -65,7 +81,6 @@ func OutPutLog(str string) {
}

func Init() {
OutPutLog("本插件基于 ZeroBot 开发")
err := CreatePath(AppPath)
if err != nil {
OutPutLog("创建应用文件夹时出现错误")
Expand All @@ -82,11 +97,8 @@ func Init() {
OutPutLog("[fortune-运势] 检测到初次运行本插件,已生成默认配置文件")
OutPutLog("[fortune-运势] 特别感谢 fz6m https://github.com/fz6m/nonebot-plugin/tree/master/CQVortune")
OutPutLog("[fortune-运势] 特别感谢 Lostdegree https://github.com/Lostdegree/Portune")
OutPutLog("[fortune-运势] 有需要请按GitHub项目上描述的方法修改配置文件")
OutPutLog("[fortune-运势] 有需要请按 GitHub 项目上描述的方法修改配置文件")
}
OutPutLog("[fortune-运势] 项目地址 https://github.com/Yiwen-Chan/fortune")
OutPutLog("[fortune-运势] 配置文件 XQ/data/app/fortune/config.yml")
OutPutLog("[fortune-运势] 想自定义运势背景并共享可加QQ群 1048452984 ")
}

// 应用函数
Expand All @@ -113,6 +125,7 @@ func App(botID int64, messageID int64, groupID int64, userID int64, message stri
headerParm := getHeader(ClientKey)

// 获得服务器数据
OutPutLog("[fortune-运势] Connect to the fortune server......")
fortuneJson, code := fortune(ApiFortune, fromDataStruct, headerParm)

// 开始处理信息提交方式
Expand Down Expand Up @@ -155,6 +168,7 @@ func App(botID int64, messageID int64, groupID int64, userID int64, message stri
text += "[CQ:image,file=file:///" + PicPath + "]"
AllSendMsg(botID, groupID, userID, text)
}
OutPutLog("[fortune-运势] Task complete......")
}
}

Expand Down
61 changes: 15 additions & 46 deletions client/XQ/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,63 +4,32 @@ import (
"encoding/json"

ft "fortune/fortune"
"github.com/Yiwen-Chan/xq-go/core"
)

type info struct {
Name string `json:"name"`
Pver string `json:"pver"`
Sver int `json:"sver"`
Author string `json:"author"`
Desc string `json:"desc"`
// 插件信息
type AppInfo struct {
Name string `json:"name"` // 插件名字
Pver string `json:"pver"` // 插件版本
Sver int `json:"sver"` // 框架版本
Author string `json:"author"` // 作者名字
Desc string `json:"desc"` // 插件说明
}

func appinfo() *info {
return &info{
func newAppInfo() *AppInfo {
return &AppInfo{
Name: "fortune-运势",
Pver: "1.0.5",
Pver: "1.0.6",
Sver: 3,
Author: "kanri",
Desc: "项目地址 https://github.com/Yiwen-Chan/fortune",
Desc: "The best of luck! 项目地址 https://github.com/Yiwen-Chan/fortune",
}
}

// 连接 core
func main() { core.Main() }
func init() {
data, _ := json.Marshal(appinfo())
core.InfoJson = string(data)
core.OnEnable = onEnable
core.OnGroupMsg = onGroupMsg
core.OnPrivateMsg = onPrivateMsg
}

// 插件初始化
func onEnable() {
ft.Init()
}

// 处理消息
func onGroupMsg(botID int64, messageID int64, groupID int64, userID int64, message string) {
if message == "xqgo -v" || message == "xqgo -version" {
core.SendGroupMsg(botID, groupID, "[XQ-GO] Version 1.0.1 By Kanri", 0)
} else if message == "ft -v" || message == "ft -version" {
core.SendGroupMsg(botID, groupID, "[fortune-运势] Version 1.0.5 By Kanri", 0)
} else if message == "ft -r" || message == "ft -reload" {
ft.Init()
core.SendGroupMsg(botID, groupID, "[fortune-运势] Fortune Reloaded!", 0)
}
ft.App(botID, messageID, groupID, userID, message)
func init() {
data, _ := json.Marshal(newAppInfo())
ft.AppInfoJson = string(data)
}

func onPrivateMsg(botID int64, messageID int64, userID int64, message string) {
if message == "xqgo -v" || message == "xqgo -version" {
core.SendGroupMsg(botID, userID, "[XQ-GO] Version 1.0.1 By Kanri", 0)
} else if message == "ft -v" || message == "ft -version" {
core.SendGroupMsg(botID, userID, "[fortune-运势] Version 1.0.5 By Kanri", 0)
} else if message == "ft -r" || message == "ft -reload" {
ft.Init()
core.SendGroupMsg(botID, userID, "[fortune-运势] Fortune Reloaded!", 0)
}
//ft.App(botID, messageID, 0, userID, message)
}
func main() { ft.Main() }
3 changes: 2 additions & 1 deletion client/XQ/build.bat
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
SET CGO_LDFLAGS=-Wl,--kill-at
SET CGO_LDFLAGS_ALLOW=-Wl,--kill-at
SET CGO_ENABLED=1
SET GOOS=windows
SET GOARCH=386
go build -ldflags "-s -w" -buildmode=c-shared -o fortune-ÔËÊÆ.XQ.dll
go build -ldflags="-s -w -extldflags '-static' -O4" -buildmode=c-shared -o fortune-ÔËÊÆ.XQ.dll
pause
Binary file removed client/XQ/fortune-XQ-v1.0.5.zip
Binary file not shown.
Binary file removed client/XQ/fortune-运势.XQ.dll
Binary file not shown.
33 changes: 33 additions & 0 deletions client/XQ/fortune/api.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package fortune

import (
"fmt"

"yaya/core"
)

func sendPicture(botID int64, type_ int64, groupID int64, userID int64, path string) {
core.SendMsgEX_V2(
botID,
type_,
groupID,
userID,
fmt.Sprintf("[pic=%s]", path),
0,
false,
"",
)
}

func sendMessage(botID int64, type_ int64, groupID int64, userID int64, message string) {
core.SendMsgEX_V2(
botID,
type_,
groupID,
userID,
message,
0,
false,
"",
)
}
77 changes: 77 additions & 0 deletions client/XQ/fortune/event.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
package fortune

import (
"yaya/core"
)

func init() {
core.Create = XQCreate
core.Event = XQEvent
core.DestroyPlugin = XQDestroyPlugin
core.SetUp = XQSetUp
}

func XQCreate(version string) string {
return AppInfoJson
}

func XQEvent(selfID int64, mseeageType int64, subType int64, groupID int64, userID int64, noticID int64, message string, messageNum int64, messageID int64, rawMessage []byte, time int64, ret int64) int64 {
switch mseeageType {
case 12001:
go ProtectRun(func() { onStart() }, "onStart()")
// 消息事件
// 0:临时会话 1:好友会话 4:群临时会话 7:好友验证会话
case 0, 1, 4, 5, 7:
go ProtectRun(func() { onPrivateMessage(selfID, mseeageType, groupID, userID, message) }, "onPrivateMessage()")
// 2:群聊信息
case 2, 3:
go ProtectRun(func() { onGroupMessage(selfID, mseeageType, groupID, userID, message) }, "onGroupMessage()")
default:
//
}
return 0
}

func XQDestroyPlugin() int64 {
return 0
}

func XQSetUp() int64 {
return 0
}

func onPrivateMessage(botID int64, type_ int64, groupID int64, userID int64, message string) {
switch message {
case "ft -v", "ft -version":
sendMessage(botID, type_, groupID, userID, "Fortune-运势 Version 1.0.6 BY Kanri")
case "ft -r", "ft -reload":
Conf = Load(AppPath + "config.yml")
if Conf != nil {
sendMessage(botID, type_, groupID, userID, "Setting is already reload!")
} else {
sendMessage(botID, type_, groupID, userID, "Setting ERROR!")
}
case "ft -c", "ft -core":
sendMessage(botID, type_, groupID, userID, "OneBot-YaYa Version 1.1.3 Beta BY Kanri Using only core")
default:
}
}

func onGroupMessage(botID int64, type_ int64, groupID int64, userID int64, message string) {
App(botID, type_, groupID, userID, message)
switch message {
case "ft -v", "ft -version":
sendMessage(botID, type_, groupID, userID, "Fortune-运势 Version 1.0.6 BY Kanri")
case "ft -r", "ft -reload":
Conf = Load(AppPath + "config.yml")
if Conf != nil {
sendMessage(botID, type_, groupID, userID, "Setting is already reload!")
} else {
sendMessage(botID, type_, groupID, userID, "Setting ERROR!")
}
case "ft -c", "ft -core":
sendMessage(botID, type_, groupID, userID, "OneBot-YaYa Version 1.1.3 Beta BY Kanri Using only core")
default:
}

}
Loading

0 comments on commit 0b77e23

Please sign in to comment.