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]
|
||||
soutujson := soutuapi(keyword)
|
||||
pom1 := "https://i.pixiv.re"
|
||||
rannum := rintn(len(soutujson.Illusts))
|
||||
rannum := randintn(len(soutujson.Illusts))
|
||||
pom2 := soutujson.Illusts[rannum].ImageUrls.Medium[19:]
|
||||
ctx.SendChain(message.Image(pom1 + pom2))
|
||||
})
|
||||
@ -102,8 +102,8 @@ func soutuapi(keyword string) *resultjson {
|
||||
return result
|
||||
}
|
||||
|
||||
// rintn 从json里的30条数据中随机获取一条返回
|
||||
func rintn(len int) int {
|
||||
// randintn 从json里的30条数据中随机获取一条返回
|
||||
func randintn(n int) int {
|
||||
rand.Seed(time.Now().UnixNano())
|
||||
return rand.Intn(len)
|
||||
return rand.Intn(n)
|
||||
}
|
||||
|
||||
@ -46,7 +46,7 @@ func GetHoliday(name string) *Holiday {
|
||||
return h
|
||||
}
|
||||
|
||||
// 获取两个时间相差
|
||||
// String 获取两个时间相差
|
||||
func (h *Holiday) String() string {
|
||||
d := time.Until(h.date)
|
||||
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()
|
||||
}
|
||||
@ -16,14 +16,14 @@ const (
|
||||
yduanziURL = "http://www.yduanzi.com/duanzi/getduanzi"
|
||||
chayiURL = "https://api.lovelive.tools/api/SweetNothings/Web/0"
|
||||
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"
|
||||
chpReferer = "https://chp.shadiao.app/"
|
||||
duReferer = "https://du.shadiao.app/"
|
||||
pyqReferer = "https://pyq.shadiao.app/"
|
||||
yduanziReferer = "http://www.yduanzi.com/?utm_source=shadiao.app"
|
||||
loveliveReferer = "https://lovelive.tools/"
|
||||
zuanReferer = "https://zuanbot.com/"
|
||||
// zuanReferer = "https://zuanbot.com/"
|
||||
prio = 10
|
||||
)
|
||||
|
||||
|
||||
@ -37,9 +37,8 @@ func Open(dbpath string) (*SleepDB, error) {
|
||||
db, err := gorm.Open("sqlite3", dbpath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return (*SleepDB)(db), nil
|
||||
}
|
||||
return (*SleepDB)(db), nil
|
||||
}
|
||||
|
||||
// Close 关闭
|
||||
|
||||
@ -10,13 +10,15 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/jinzhu/gorm"
|
||||
_ "github.com/logoove/sqlite"
|
||||
_ "github.com/logoove/sqlite" // import sql
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/tidwall/gjson"
|
||||
)
|
||||
|
||||
// VtbDB vtb 数据库
|
||||
type VtbDB gorm.DB
|
||||
|
||||
// Initialize ...
|
||||
func Initialize(dbpath string) *VtbDB {
|
||||
var err error
|
||||
if _, err = os.Stat(dbpath); err != nil || os.IsNotExist(err) {
|
||||
@ -35,6 +37,7 @@ func Initialize(dbpath string) *VtbDB {
|
||||
return (*VtbDB)(gdb)
|
||||
}
|
||||
|
||||
// Open ...
|
||||
func Open(dbpath string) (*VtbDB, error) {
|
||||
db, err := gorm.Open("sqlite3", dbpath)
|
||||
if err != nil {
|
||||
@ -54,6 +57,7 @@ type FirstCategory struct {
|
||||
FirstCategoryIconPath string `gorm:"column:first_category_icon_path"`
|
||||
}
|
||||
|
||||
// TableName ...
|
||||
func (FirstCategory) TableName() string {
|
||||
return "first_category"
|
||||
}
|
||||
@ -68,6 +72,7 @@ type SecondCategory struct {
|
||||
SecondCategoryDescription string `gorm:"column:second_category_description"`
|
||||
}
|
||||
|
||||
// TableName ...
|
||||
func (SecondCategory) TableName() string {
|
||||
return "second_category"
|
||||
}
|
||||
@ -84,6 +89,7 @@ type ThirdCategory struct {
|
||||
ThirdCategoryDescription string `gorm:"column:third_category_description"`
|
||||
}
|
||||
|
||||
// TableName ...
|
||||
func (ThirdCategory) TableName() string {
|
||||
return "third_category"
|
||||
}
|
||||
@ -163,7 +169,7 @@ func (vdb *VtbDB) GetAllThirdCategoryMessageByFirstIndexAndSecondIndex(firstInde
|
||||
return ThirdStepMessage
|
||||
}
|
||||
|
||||
// GetThirdCategory
|
||||
// GetThirdCategory ...
|
||||
func (vdb *VtbDB) GetThirdCategory(firstIndex, secondIndex, thirdIndex int) ThirdCategory {
|
||||
db := (*gorm.DB)(vdb)
|
||||
var fc FirstCategory
|
||||
@ -173,6 +179,7 @@ func (vdb *VtbDB) GetThirdCategory(firstIndex, secondIndex, thirdIndex int) Thir
|
||||
return tc
|
||||
}
|
||||
|
||||
// RandomVtb ...
|
||||
func (vdb *VtbDB) RandomVtb() ThirdCategory {
|
||||
db := (*gorm.DB)(vdb)
|
||||
rand.Seed(time.Now().UnixNano())
|
||||
@ -185,6 +192,7 @@ func (vdb *VtbDB) RandomVtb() ThirdCategory {
|
||||
return tc
|
||||
}
|
||||
|
||||
// GetFirstCategoryByFirstUid ...
|
||||
func (vdb *VtbDB) GetFirstCategoryByFirstUid(firstUid string) FirstCategory {
|
||||
db := (*gorm.DB)(vdb)
|
||||
var fc FirstCategory
|
||||
@ -193,6 +201,7 @@ func (vdb *VtbDB) GetFirstCategoryByFirstUid(firstUid string) FirstCategory {
|
||||
return fc
|
||||
}
|
||||
|
||||
// Close ...
|
||||
func (vdb *VtbDB) Close() error {
|
||||
db := (*gorm.DB)(vdb)
|
||||
return db.Close()
|
||||
@ -200,6 +209,7 @@ func (vdb *VtbDB) Close() error {
|
||||
|
||||
const vtbUrl = "https://vtbkeyboard.moe/api/get_vtb_list"
|
||||
|
||||
// GetVtbList ...
|
||||
func (vdb *VtbDB) GetVtbList() (uidList []string) {
|
||||
db := (*gorm.DB)(vdb)
|
||||
client := &http.Client{}
|
||||
@ -261,6 +271,7 @@ func (vdb *VtbDB) GetVtbList() (uidList []string) {
|
||||
return uidList
|
||||
}
|
||||
|
||||
// StoreVtb ...
|
||||
func (vdb *VtbDB) StoreVtb(uid string) {
|
||||
db := (*gorm.DB)(vdb)
|
||||
vtbUrl := "https://vtbkeyboard.moe/api/get_vtb_page?uid=" + uid
|
||||
|
||||
@ -2,6 +2,7 @@ package math
|
||||
|
||||
import "strconv"
|
||||
|
||||
// Str2Int64 string to int64
|
||||
func Str2Int64(str string) int64 {
|
||||
val, _ := strconv.ParseInt(str, 10, 64)
|
||||
return val
|
||||
|
||||
Loading…
Reference in New Issue
Block a user