Update
This commit is contained in:
parent
ffedf32a0c
commit
34a1552439
31
handle.go
31
handle.go
@ -42,8 +42,6 @@ func bMy(m *tb.Message) {
|
||||
data := QueryDataByTG(db, m.Chat.ID)
|
||||
var inlineKeys [][]tb.InlineButton
|
||||
for _, u := range data {
|
||||
//uJson := MarshalMSData(u)
|
||||
//fmt.Println(uJson)
|
||||
inlineBtn := tb.InlineButton{
|
||||
Unique: u.msId,
|
||||
Text: gjson.Get(u.other, "alias").String(),
|
||||
@ -54,7 +52,6 @@ func bMy(m *tb.Message) {
|
||||
}
|
||||
bot.Send(m.Chat, "选择一个账户查看具体信息\n\n绑定数: "+strconv.Itoa(GetBindNum(m.Chat.ID))+"/"+strconv.Itoa(BindMaxNum), &tb.ReplyMarkup{InlineKeyboard: inlineKeys})
|
||||
}
|
||||
|
||||
func bMyInlineBtn(c *tb.Callback) {
|
||||
//var inlineKeys [][]tb.InlineButton
|
||||
//bot.Handle(&inlineBtn, bMyinlineBtn)
|
||||
@ -76,6 +73,31 @@ func bBind(m *tb.Message) {
|
||||
}
|
||||
|
||||
}
|
||||
func bUnBind(m *tb.Message) {
|
||||
data := QueryDataByTG(db, m.Chat.ID)
|
||||
var inlineKeys [][]tb.InlineButton
|
||||
for _, u := range data {
|
||||
inlineBtn := tb.InlineButton{
|
||||
Unique: u.msId,
|
||||
Text: gjson.Get(u.other, "alias").String(),
|
||||
Data: u.msId,
|
||||
}
|
||||
bot.Handle(&inlineBtn, bUnBindInlineBtn)
|
||||
inlineKeys = append(inlineKeys, []tb.InlineButton{inlineBtn})
|
||||
}
|
||||
bot.Send(m.Chat, "选择一个账户将其解绑\n\n当前绑定数: "+strconv.Itoa(GetBindNum(m.Chat.ID))+"/"+strconv.Itoa(BindMaxNum), &tb.ReplyMarkup{InlineKeyboard: inlineKeys})
|
||||
}
|
||||
func bUnBindInlineBtn(c *tb.Callback) {
|
||||
fmt.Println(c.Data)
|
||||
if ok, _ := DelData(db, c.Data); !ok {
|
||||
fmt.Println(c.Data + " UnBind ERROR")
|
||||
bot.Send(c.Message.Chat, "解绑失败!")
|
||||
return
|
||||
}
|
||||
fmt.Println(c.Data + " UnBind Success")
|
||||
bot.Send(c.Message.Chat, "解绑成功!")
|
||||
bot.Respond(c)
|
||||
}
|
||||
func bAbout(m *tb.Message) {
|
||||
bot.Send(m.Sender, bStartContent)
|
||||
}
|
||||
@ -99,8 +121,7 @@ func bOnText(m *tb.Message) {
|
||||
} else {
|
||||
bot.Send(m.Chat, info)
|
||||
}
|
||||
UserStatus[m.Chat.ID] = USNone
|
||||
}
|
||||
case USBind:
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
20
main.go
20
main.go
@ -3,6 +3,7 @@ package main
|
||||
import (
|
||||
"database/sql"
|
||||
"fmt"
|
||||
"github.com/robfig/cron/v3"
|
||||
"github.com/spf13/viper"
|
||||
"golang.org/x/net/proxy"
|
||||
tb "gopkg.in/tucnak/telebot.v2"
|
||||
@ -56,21 +57,26 @@ func init() {
|
||||
}
|
||||
func main() {
|
||||
BotStart()
|
||||
//b.Handle(tb.OnText, func(m *tb.Message) {
|
||||
// b.Send(m.Sender, "hello world")
|
||||
//})
|
||||
|
||||
//b.Start()
|
||||
}
|
||||
func BotStart() {
|
||||
makeHandle()
|
||||
MakeHandle()
|
||||
TaskLaunch()
|
||||
bot.Start()
|
||||
}
|
||||
func makeHandle() {
|
||||
func MakeHandle() {
|
||||
bot.Handle("/start", bStart)
|
||||
bot.Handle("/my", bMy)
|
||||
bot.Handle("/bind", bBind)
|
||||
bot.Handle("/unbind", bUnBind)
|
||||
bot.Handle("/about", bAbout)
|
||||
bot.Handle(tb.OnText, bOnText)
|
||||
//bot.Handle(tb.InlineButton{Unique: ""})
|
||||
}
|
||||
func TaskLaunch() {
|
||||
task := cron.New()
|
||||
SignTask()
|
||||
//每三小时执行一次
|
||||
task.AddFunc("1 */3 * * *", SignTask)
|
||||
// */1 * * * *
|
||||
task.Start()
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user