mirror of
https://github.com/FloatTech/ZeroBot-Plugin.git
synced 2025-12-19 13:59:39 +08:00
make lint happy
This commit is contained in:
parent
16624a9596
commit
3939e0760f
@ -70,7 +70,7 @@ func init() {
|
|||||||
keyword := ctx.State["regex_matched"].([]string)[1]
|
keyword := ctx.State["regex_matched"].([]string)[1]
|
||||||
soutujson := soutuapi(keyword)
|
soutujson := soutuapi(keyword)
|
||||||
pom1 := "https://i.pixiv.re"
|
pom1 := "https://i.pixiv.re"
|
||||||
rannum := rintn(len(soutujson.Illusts))
|
rannum := randintn(len(soutujson.Illusts))
|
||||||
pom2 := soutujson.Illusts[rannum].ImageUrls.Medium[19:]
|
pom2 := soutujson.Illusts[rannum].ImageUrls.Medium[19:]
|
||||||
ctx.SendChain(message.Image(pom1 + pom2))
|
ctx.SendChain(message.Image(pom1 + pom2))
|
||||||
})
|
})
|
||||||
@ -102,8 +102,8 @@ func soutuapi(keyword string) *resultjson {
|
|||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
// rintn 从json里的30条数据中随机获取一条返回
|
// randintn 从json里的30条数据中随机获取一条返回
|
||||||
func rintn(len int) int {
|
func randintn(n int) int {
|
||||||
rand.Seed(time.Now().UnixNano())
|
rand.Seed(time.Now().UnixNano())
|
||||||
return rand.Intn(len)
|
return rand.Intn(n)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -46,7 +46,7 @@ func GetHoliday(name string) *Holiday {
|
|||||||
return h
|
return h
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取两个时间相差
|
// String 获取两个时间相差
|
||||||
func (h *Holiday) String() string {
|
func (h *Holiday) String() string {
|
||||||
d := time.Until(h.date)
|
d := time.Until(h.date)
|
||||||
switch {
|
switch {
|
||||||
|
|||||||
@ -1,46 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
"strconv"
|
|
||||||
|
|
||||||
"github.com/FloatTech/ZeroBot-Plugin/utils/sql"
|
|
||||||
)
|
|
||||||
|
|
||||||
type signature struct {
|
|
||||||
Id uint64 `db:"id"`
|
|
||||||
Text string `db:"text"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type kuji struct {
|
|
||||||
Id uint8 `db:"id"`
|
|
||||||
Text string `db:"text"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
db := &sql.Sqlite{DBPath: os.Args[1]}
|
|
||||||
newdb := &sql.Sqlite{DBPath: os.Args[2]}
|
|
||||||
err := newdb.Create("kuji", &kuji{})
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
err = db.Create("signature", &signature{})
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
fmt.Println(db.Count("signature"))
|
|
||||||
s := &signature{}
|
|
||||||
k := &kuji{}
|
|
||||||
for i := 1; i <= 100; i++ {
|
|
||||||
db.Find("signature", s, "where id = "+strconv.Itoa(i))
|
|
||||||
fmt.Println("insert: ", s.Text[:57])
|
|
||||||
k.Id = uint8(i)
|
|
||||||
k.Text = s.Text
|
|
||||||
newdb.Insert("kuji", k)
|
|
||||||
}
|
|
||||||
|
|
||||||
db.Close()
|
|
||||||
newdb.Close()
|
|
||||||
}
|
|
||||||
@ -10,21 +10,21 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
chpURL = "https://chp.shadiao.app/api.php"
|
chpURL = "https://chp.shadiao.app/api.php"
|
||||||
duURL = "https://du.shadiao.app/api.php"
|
duURL = "https://du.shadiao.app/api.php"
|
||||||
pyqURL = "https://pyq.shadiao.app/api.php"
|
pyqURL = "https://pyq.shadiao.app/api.php"
|
||||||
yduanziURL = "http://www.yduanzi.com/duanzi/getduanzi"
|
yduanziURL = "http://www.yduanzi.com/duanzi/getduanzi"
|
||||||
chayiURL = "https://api.lovelive.tools/api/SweetNothings/Web/0"
|
chayiURL = "https://api.lovelive.tools/api/SweetNothings/Web/0"
|
||||||
ganhaiURL = "https://api.lovelive.tools/api/SweetNothings/Web/1"
|
ganhaiURL = "https://api.lovelive.tools/api/SweetNothings/Web/1"
|
||||||
zuanURL = "https://zuanbot.com/api.php?level=min&lang=zh_cn"
|
// zuanURL = "https://zuanbot.com/api.php?level=min&lang=zh_cn"
|
||||||
ua = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36"
|
ua = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36"
|
||||||
chpReferer = "https://chp.shadiao.app/"
|
chpReferer = "https://chp.shadiao.app/"
|
||||||
duReferer = "https://du.shadiao.app/"
|
duReferer = "https://du.shadiao.app/"
|
||||||
pyqReferer = "https://pyq.shadiao.app/"
|
pyqReferer = "https://pyq.shadiao.app/"
|
||||||
yduanziReferer = "http://www.yduanzi.com/?utm_source=shadiao.app"
|
yduanziReferer = "http://www.yduanzi.com/?utm_source=shadiao.app"
|
||||||
loveliveReferer = "https://lovelive.tools/"
|
loveliveReferer = "https://lovelive.tools/"
|
||||||
zuanReferer = "https://zuanbot.com/"
|
// zuanReferer = "https://zuanbot.com/"
|
||||||
prio = 10
|
prio = 10
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|||||||
@ -37,9 +37,8 @@ func Open(dbpath string) (*SleepDB, error) {
|
|||||||
db, err := gorm.Open("sqlite3", dbpath)
|
db, err := gorm.Open("sqlite3", dbpath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
} else {
|
|
||||||
return (*SleepDB)(db), nil
|
|
||||||
}
|
}
|
||||||
|
return (*SleepDB)(db), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Close 关闭
|
// Close 关闭
|
||||||
|
|||||||
@ -10,13 +10,15 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/jinzhu/gorm"
|
"github.com/jinzhu/gorm"
|
||||||
_ "github.com/logoove/sqlite"
|
_ "github.com/logoove/sqlite" // import sql
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
"github.com/tidwall/gjson"
|
"github.com/tidwall/gjson"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// VtbDB vtb 数据库
|
||||||
type VtbDB gorm.DB
|
type VtbDB gorm.DB
|
||||||
|
|
||||||
|
// Initialize ...
|
||||||
func Initialize(dbpath string) *VtbDB {
|
func Initialize(dbpath string) *VtbDB {
|
||||||
var err error
|
var err error
|
||||||
if _, err = os.Stat(dbpath); err != nil || os.IsNotExist(err) {
|
if _, err = os.Stat(dbpath); err != nil || os.IsNotExist(err) {
|
||||||
@ -35,6 +37,7 @@ func Initialize(dbpath string) *VtbDB {
|
|||||||
return (*VtbDB)(gdb)
|
return (*VtbDB)(gdb)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Open ...
|
||||||
func Open(dbpath string) (*VtbDB, error) {
|
func Open(dbpath string) (*VtbDB, error) {
|
||||||
db, err := gorm.Open("sqlite3", dbpath)
|
db, err := gorm.Open("sqlite3", dbpath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -54,6 +57,7 @@ type FirstCategory struct {
|
|||||||
FirstCategoryIconPath string `gorm:"column:first_category_icon_path"`
|
FirstCategoryIconPath string `gorm:"column:first_category_icon_path"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TableName ...
|
||||||
func (FirstCategory) TableName() string {
|
func (FirstCategory) TableName() string {
|
||||||
return "first_category"
|
return "first_category"
|
||||||
}
|
}
|
||||||
@ -68,6 +72,7 @@ type SecondCategory struct {
|
|||||||
SecondCategoryDescription string `gorm:"column:second_category_description"`
|
SecondCategoryDescription string `gorm:"column:second_category_description"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TableName ...
|
||||||
func (SecondCategory) TableName() string {
|
func (SecondCategory) TableName() string {
|
||||||
return "second_category"
|
return "second_category"
|
||||||
}
|
}
|
||||||
@ -84,6 +89,7 @@ type ThirdCategory struct {
|
|||||||
ThirdCategoryDescription string `gorm:"column:third_category_description"`
|
ThirdCategoryDescription string `gorm:"column:third_category_description"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TableName ...
|
||||||
func (ThirdCategory) TableName() string {
|
func (ThirdCategory) TableName() string {
|
||||||
return "third_category"
|
return "third_category"
|
||||||
}
|
}
|
||||||
@ -163,7 +169,7 @@ func (vdb *VtbDB) GetAllThirdCategoryMessageByFirstIndexAndSecondIndex(firstInde
|
|||||||
return ThirdStepMessage
|
return ThirdStepMessage
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetThirdCategory
|
// GetThirdCategory ...
|
||||||
func (vdb *VtbDB) GetThirdCategory(firstIndex, secondIndex, thirdIndex int) ThirdCategory {
|
func (vdb *VtbDB) GetThirdCategory(firstIndex, secondIndex, thirdIndex int) ThirdCategory {
|
||||||
db := (*gorm.DB)(vdb)
|
db := (*gorm.DB)(vdb)
|
||||||
var fc FirstCategory
|
var fc FirstCategory
|
||||||
@ -173,6 +179,7 @@ func (vdb *VtbDB) GetThirdCategory(firstIndex, secondIndex, thirdIndex int) Thir
|
|||||||
return tc
|
return tc
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// RandomVtb ...
|
||||||
func (vdb *VtbDB) RandomVtb() ThirdCategory {
|
func (vdb *VtbDB) RandomVtb() ThirdCategory {
|
||||||
db := (*gorm.DB)(vdb)
|
db := (*gorm.DB)(vdb)
|
||||||
rand.Seed(time.Now().UnixNano())
|
rand.Seed(time.Now().UnixNano())
|
||||||
@ -185,6 +192,7 @@ func (vdb *VtbDB) RandomVtb() ThirdCategory {
|
|||||||
return tc
|
return tc
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetFirstCategoryByFirstUid ...
|
||||||
func (vdb *VtbDB) GetFirstCategoryByFirstUid(firstUid string) FirstCategory {
|
func (vdb *VtbDB) GetFirstCategoryByFirstUid(firstUid string) FirstCategory {
|
||||||
db := (*gorm.DB)(vdb)
|
db := (*gorm.DB)(vdb)
|
||||||
var fc FirstCategory
|
var fc FirstCategory
|
||||||
@ -193,6 +201,7 @@ func (vdb *VtbDB) GetFirstCategoryByFirstUid(firstUid string) FirstCategory {
|
|||||||
return fc
|
return fc
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Close ...
|
||||||
func (vdb *VtbDB) Close() error {
|
func (vdb *VtbDB) Close() error {
|
||||||
db := (*gorm.DB)(vdb)
|
db := (*gorm.DB)(vdb)
|
||||||
return db.Close()
|
return db.Close()
|
||||||
@ -200,6 +209,7 @@ func (vdb *VtbDB) Close() error {
|
|||||||
|
|
||||||
const vtbUrl = "https://vtbkeyboard.moe/api/get_vtb_list"
|
const vtbUrl = "https://vtbkeyboard.moe/api/get_vtb_list"
|
||||||
|
|
||||||
|
// GetVtbList ...
|
||||||
func (vdb *VtbDB) GetVtbList() (uidList []string) {
|
func (vdb *VtbDB) GetVtbList() (uidList []string) {
|
||||||
db := (*gorm.DB)(vdb)
|
db := (*gorm.DB)(vdb)
|
||||||
client := &http.Client{}
|
client := &http.Client{}
|
||||||
@ -261,6 +271,7 @@ func (vdb *VtbDB) GetVtbList() (uidList []string) {
|
|||||||
return uidList
|
return uidList
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// StoreVtb ...
|
||||||
func (vdb *VtbDB) StoreVtb(uid string) {
|
func (vdb *VtbDB) StoreVtb(uid string) {
|
||||||
db := (*gorm.DB)(vdb)
|
db := (*gorm.DB)(vdb)
|
||||||
vtbUrl := "https://vtbkeyboard.moe/api/get_vtb_page?uid=" + uid
|
vtbUrl := "https://vtbkeyboard.moe/api/get_vtb_page?uid=" + uid
|
||||||
|
|||||||
@ -2,6 +2,7 @@ package math
|
|||||||
|
|
||||||
import "strconv"
|
import "strconv"
|
||||||
|
|
||||||
|
// Str2Int64 string to int64
|
||||||
func Str2Int64(str string) int64 {
|
func Str2Int64(str string) int64 {
|
||||||
val, _ := strconv.ParseInt(str, 10, 64)
|
val, _ := strconv.ParseInt(str, 10, 64)
|
||||||
return val
|
return val
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user