Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add WarframeAPI #541

Merged
merged 24 commits into from
Jan 31, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1273,6 +1273,31 @@ print("run[CQ:image,file="+j["img"]+"]")

- [x] 来份网易云热评

</details>
<details>
<summary>WarframeAPI</summary>

`import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/warframeapi"`

- [x] wf数据更新

- [x] [金星|地球|火卫二]平原状态

- [x] 订阅[金星|地球|火卫二]平原[白天|夜晚]

- [x] 取消订阅[金星|地球|火卫二]平原[白天|夜晚]

- [x] .wm [物品名称]

- [x] 取外号 [原名称] [外号]

- [x] [金星/地球/火卫二]平原状态

- [x] 仲裁

- [x] 警报

- [x] 每日特惠
</details>
<details>
<summary>天气/拼音查询-名言</summary>
Expand Down
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ require (
github.com/RomiChan/websocket v1.4.3-0.20220227141055-9b2c6168c9c5
github.com/antchfx/htmlquery v1.2.5
github.com/corona10/goimagehash v1.1.0
github.com/davidscholberg/go-durationfmt v0.0.0-20170122144659-64843a2083d3
github.com/fumiama/ahsai v0.1.0
github.com/fumiama/cron v1.3.0
github.com/fumiama/go-base16384 v1.6.1
Expand All @@ -25,6 +26,7 @@ require (
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0
github.com/jinzhu/gorm v1.9.16
github.com/jozsefsallai/gophersauce v1.0.1
github.com/lithammer/fuzzysearch v1.1.5
github.com/lucas-clemente/quic-go v0.31.1
github.com/mroth/weightedrand v1.0.0
github.com/pkg/errors v0.9.1
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ github.com/d4l3k/messagediff v1.2.2-0.20190829033028-7e0a312ae40b/go.mod h1:Oozb
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davidscholberg/go-durationfmt v0.0.0-20170122144659-64843a2083d3 h1:qshMBFxVjYjzI+kwvWvgoByF3uMCvnJiaK8KslWAbr8=
github.com/davidscholberg/go-durationfmt v0.0.0-20170122144659-64843a2083d3/go.mod h1:M9fx6rAdHSYLKxXPgUXGgblb586CA7ceNrpu4DEc2No=
github.com/denisenkom/go-mssqldb v0.0.0-20191124224453-732737034ffd h1:83Wprp6ROGeiHFAP8WJdI2RoxALQYgdllERc3N5N2DM=
github.com/denisenkom/go-mssqldb v0.0.0-20191124224453-732737034ffd/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU=
github.com/disintegration/imaging v1.6.2 h1:w1LecBlG2Lnp8B3jk5zSuNqd7b4DXhcjwek1ei82L+c=
Expand Down Expand Up @@ -126,6 +128,8 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/lib/pq v1.1.1 h1:sJZmqHoEaY7f+NPP8pgLB/WxulyR3fewgCM2qaSlBb4=
github.com/lib/pq v1.1.1/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
github.com/lithammer/fuzzysearch v1.1.5 h1:Ag7aKU08wp0R9QCfF4GoGST9HbmAIeLP7xwMrOBEp1c=
github.com/lithammer/fuzzysearch v1.1.5/go.mod h1:1R1LRNk7yKid1BaQkmuLQaHruxcC4HmAH30Dh61Ih1Q=
github.com/lucas-clemente/quic-go v0.31.1 h1:O8Od7hfioqq0PMYHDyBkxU2aA7iZ2W9pjbrWuja2YR4=
github.com/lucas-clemente/quic-go v0.31.1/go.mod h1:0wFbizLgYzqHqtlyxyCaJKlE7bYgE6JQ+54TLd/Dq2g=
github.com/lucasb-eyer/go-colorful v1.0.2/go.mod h1:0MS4r+7BZKSJ5mw4/S5MPN+qHFF1fYclkSPilDOKW0s=
Expand Down
13 changes: 7 additions & 6 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,13 @@ import (
_ "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/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/warframeapi"
GenesisAN marked this conversation as resolved.
Show resolved Hide resolved
_ "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/wtf" // 鬼东西

Expand Down
156 changes: 156 additions & 0 deletions plugin/warframeapi/gametime.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
package warframeapi

import (
"fmt"
"time"

"github.com/davidscholberg/go-durationfmt"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
)

var (
gameTimes []gameTime
fumiama marked this conversation as resolved.
Show resolved Hide resolved
)

func (t gameTime) getStatus() string {
fumiama marked this conversation as resolved.
Show resolved Hide resolved
if t.Status {
return t.StatusTrueDes
}
return t.StatusFalseDes
}
func (t gameTime) getTime() string {
d := time.Until(t.NextTime)
durStr, _ := durationfmt.Format(d, "%m分%s秒后")
return durStr
}

// 游戏时间模拟初始化
func gameTimeInit() {
//updateWM()
loadTime()
go gameRuntime()
}

func gameRuntime() {
GenesisAN marked this conversation as resolved.
Show resolved Hide resolved
for {
fumiama marked this conversation as resolved.
Show resolved Hide resolved
time.Sleep(10 * time.Second)
timeDet()
}

}

func loadTime() {
fumiama marked this conversation as resolved.
Show resolved Hide resolved
//updateWM()
var isfass bool
if wfapi.CambionCycle.Active == "fass" {
isfass = false
fumiama marked this conversation as resolved.
Show resolved Hide resolved
}
gameTimes = []gameTime{
{"地球平原", wfapi.CetusCycle.Expiry.Local(), wfapi.CetusCycle.IsDay, "白天", "夜晚", 100 * 60, 50 * 60},
{"金星平原", wfapi.VallisCycle.Expiry.Local(), wfapi.VallisCycle.IsWarm, "温暖", "寒冷", 400, 20 * 60},
{"火卫二平原", wfapi.CambionCycle.Expiry.Local(), isfass, "fass", "vome", 100 * 60, 50 * 60},
}

}

func timeDet() {
for i, v := range gameTimes {
nt := time.Until(v.NextTime).Seconds()
switch {
case nt < 0:
if v.Status {
gameTimes[i].NextTime = v.NextTime.Add(time.Duration(v.NightTime) * time.Second)
} else {
gameTimes[i].NextTime = v.NextTime.Add(time.Duration(v.DayTime) * time.Second)
}
gameTimes[i].Status = !gameTimes[i].Status
callUser(i, gameTimes[i].Status, 0)
case nt < float64(5)*60:
callUser(i, !gameTimes[i].Status, 5)
case nt < float64(15)*60:
if i == 2 && !v.Status {
return
}
callUser(i, !gameTimes[i].Status, 15)
}
}
}

func callUser(i int, s bool, time int) {
fumiama marked this conversation as resolved.
Show resolved Hide resolved
for group, sl := range sublist {
msg := []message.MessageSegment{}

switch {
case !sl.Min15Tips && !sl.Min5Tips && time == 15:
sublist[group].Min15Tips = true
case sl.Min15Tips && !sl.Min5Tips && time == 5:
sublist[group].Min5Tips = true
case sl.Min15Tips && sl.Min5Tips && time == 0:
sublist[group].Min15Tips = false
sublist[group].Min5Tips = false
default:
return
}

//if !sl.Min15Tips && !sl.Min5Tips && time == 15 {
// sublist[group].Min15Tips = true
//} else if sl.Min15Tips && !sl.Min5Tips && time == 5 {
// sublist[group].Min5Tips = true
//} else if sl.Min15Tips && sl.Min5Tips && time == 0 {
// sublist[group].Min15Tips = false
// sublist[group].Min5Tips = false
//} else {
// return
//}

for qq, st := range sl.SubUser {
if st.SubType[i] != nil {
if *st.SubType[i] == s {
msg = append(msg, message.At(qq))
}
}
}
if len(msg) == 0 {
continue
}
if time <= 0 {
if s {
msg = append(msg, message.Text(fmt.Sprintf("\n%s白天(%s)到了", gameTimes[i].Name, gameTimes[i].StatusTrueDes)))
} else {
msg = append(msg, message.Text(fmt.Sprintf("\n%s夜晚(%s)到了", gameTimes[i].Name, gameTimes[i].StatusFalseDes)))
}
} else {
if s {
msg = append(msg, message.Text(fmt.Sprintf("\n%s距离白天(%s)还剩下%d分钟", gameTimes[i].Name, gameTimes[i].StatusTrueDes, time)))
} else {
msg = append(msg, message.Text(fmt.Sprintf("\n%s距离夜晚(%s)还剩下%d分钟", gameTimes[i].Name, gameTimes[i].StatusFalseDes, time)))
}
}

zero.GetBot(2429160662).SendGroupMessage(group, msg)
fumiama marked this conversation as resolved.
Show resolved Hide resolved
}

}

// 游戏时间模拟
type gameTime struct {
Name string `json:"name"` //时间名称
NextTime time.Time `json:"time"` //下次更新时间
Status bool `json:"status"` //状态
StatusTrueDes string `json:"true_des"` //状态说明
StatusFalseDes string `json:"false_des"` //状态说明
DayTime int `json:"day"` //白天时长
NightTime int `json:"night"` //夜间时长
}

type subList struct {
SubUser map[int64]subType `json:"qq_sub"`
Min5Tips bool `json:"min5_tips"`
Min15Tips bool `json:"min15_tips"`
}

type subType struct {
SubType map[int]*bool `json:"sub_type"`
SubRaid bool `json:"sub_raid"`
}
Loading