-
Notifications
You must be signed in to change notification settings - Fork 6
/
EEAsst.go
58 lines (46 loc) · 1.51 KB
/
EEAsst.go
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
53
54
55
56
57
58
package EEAsst
import (
"fmt"
"github.com/ssp97/Ka-ineshizuku-Project/pkg/dbManager"
"github.com/ssp97/Ka-ineshizuku-Project/pkg/zero"
ZeroBot "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
)
type Config struct {
Enable bool
}
type ComponentSilk struct {
ID uint64 `json:"id" form:"id" gorm:"primary_key;auto_increment;"`
UserId uint64 `json:"user_id" form:"user_id"`
SilkName string `json:"silk_name" form:"silk_name"`
PdfUrl string `json:"pdf_url" form:"pdf_url"`
}
var db *dbManager.ORM
func Resistance(str string)(string, error){
return "", nil
}
func Init(c Config){
if c.Enable == false{
return
}
db = dbManager.GetDb(dbManager.DEFAULT_DB_NAME)
db.DB.AutoMigrate(ComponentSilk{})
zero.Default().OnRegex("^电阻(.*?)$").SetBlock(true).SetPriority(20).Handle(func(ctx *ZeroBot.Ctx) {
code := ctx.State["regex_matched"].([]string)[1]
result, err := getEIA96Res(code)
if err != nil {
//ctx.SendChain(message.Text(fmt.Sprintf("%s对应的尺寸是:%s",code,result)))
}else{
ctx.SendChain(message.Text(fmt.Sprintf("%s对应的电阻是:%sΩ",code,result)))
}
})
zero.Default().OnRegex("^尺寸(.*?)$").SetBlock(true).SetPriority(20).Handle(func(ctx *ZeroBot.Ctx) {
code := ctx.State["regex_matched"].([]string)[1]
result, err := getEIASize(code)
if err != nil {
//ctx.SendChain(message.Text(fmt.Sprintf("%s对应的尺寸是:%s",code,result)))
}else{
ctx.SendChain(message.Text(fmt.Sprintf("%s对应的尺寸是:%s",code,result)))
}
})
}