Add /my Resp
This commit is contained in:
parent
9cd4ac1711
commit
b4943b78e8
35
handle.go
35
handle.go
@ -3,12 +3,13 @@ package main
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
|
"github.com/tidwall/gjson"
|
||||||
tb "gopkg.in/tucnak/telebot.v2"
|
tb "gopkg.in/tucnak/telebot.v2"
|
||||||
"strconv"
|
"strconv"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
bStartContent string = "欢迎使用E5SubBot!\n请输入命令以启用"
|
bStartContent string = "欢迎使用E5SubBot!\n请输入命令以启用Bot"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -38,28 +39,38 @@ func bStart(m *tb.Message) {
|
|||||||
bot.Send(m.Sender, bStartContent)
|
bot.Send(m.Sender, bStartContent)
|
||||||
}
|
}
|
||||||
func bMy(m *tb.Message) {
|
func bMy(m *tb.Message) {
|
||||||
data := QueryData(db, m.Chat.ID)
|
data := QueryDataByTG(db, m.Chat.ID)
|
||||||
var inlineKeys = [][]tb.InlineButton{}
|
var inlineKeys [][]tb.InlineButton
|
||||||
for _, u := range data {
|
for _, u := range data {
|
||||||
|
//uJson := MarshalMSData(u)
|
||||||
|
//fmt.Println(uJson)
|
||||||
inlineBtn := tb.InlineButton{
|
inlineBtn := tb.InlineButton{
|
||||||
Unique: u.refreshToken,
|
Unique: u.msId,
|
||||||
Text: u.refreshToken,
|
Text: gjson.Get(u.other, "alias").String(),
|
||||||
Data: u.uptime.Format("2006-01-02 15:04:05"),
|
Data: u.msId,
|
||||||
}
|
}
|
||||||
bot.Handle(&inlineBtn, bMyinlineBtn)
|
bot.Handle(&inlineBtn, bMyInlineBtn)
|
||||||
inlineKeys = append(inlineKeys, []tb.InlineButton{inlineBtn})
|
inlineKeys = append(inlineKeys, []tb.InlineButton{inlineBtn})
|
||||||
}
|
}
|
||||||
bot.Send(m.Chat, "Hello!", &tb.ReplyMarkup{InlineKeyboard: inlineKeys})
|
bot.Send(m.Chat, "选择一个账户查看具体信息\n\n绑定数: "+strconv.Itoa(GetBindNum(m.Chat.ID))+"/"+strconv.Itoa(BindMaxNum), &tb.ReplyMarkup{InlineKeyboard: inlineKeys})
|
||||||
}
|
}
|
||||||
func bMyinlineBtn(c *tb.Callback) {
|
|
||||||
bot.Send(c.Message.Chat, c.Data)
|
func bMyInlineBtn(c *tb.Callback) {
|
||||||
|
//var inlineKeys [][]tb.InlineButton
|
||||||
|
//bot.Handle(&inlineBtn, bMyinlineBtn)
|
||||||
|
//inlineKeys = append(inlineKeys, []tb.InlineButton{inlineBtn})
|
||||||
|
//bot.EditReplyMarkup(tb.Editable(c.MessageID, int64(c.Sender.ID)))
|
||||||
|
fmt.Println(c.Data)
|
||||||
|
r := QueryDataByMS(db, c.Data)
|
||||||
|
u := r[0]
|
||||||
|
bot.Send(c.Message.Chat, "信息\n别名:"+gjson.Get(u.other, "alias").String()+"\nMS_ID: "+u.msId+"\n最近更新时间: "+u.uptime.Format("2006-01-02 15:04:05"))
|
||||||
bot.Respond(c)
|
bot.Respond(c)
|
||||||
}
|
}
|
||||||
func bBind(m *tb.Message) {
|
func bBind(m *tb.Message) {
|
||||||
tgId := m.Chat.ID
|
tgId := m.Chat.ID
|
||||||
fmt.Println("Auth: " + strconv.FormatInt(tgId, 10))
|
fmt.Println("Auth: " + strconv.FormatInt(tgId, 10))
|
||||||
bot.Send(m.Chat, "授权链接: [点击直达](https://login.microsoftonline.com/common/oauth2/v2.0/authorize?client_id=4d7c8a8a-0baf-497e-9608-57d6abfccce7&response_type=code&redirect_uri=http%3A%2F%2Flocalhost%2Fe5sub%2F&response_mode=query&scope=openid%20offline_access%20mail.read%20user.read)", tb.ModeMarkdown)
|
bot.Send(m.Chat, "授权链接: [点击直达]("+authUrl+")", tb.ModeMarkdown)
|
||||||
_, err := bot.Send(m.Chat, "授权后回复整个http://localhost", &tb.ReplyMarkup{ForceReply: true})
|
_, err := bot.Send(m.Chat, "回复格式:http://localhost/...+空格+别名(用于管理)", &tb.ReplyMarkup{ForceReply: true})
|
||||||
if err == nil {
|
if err == nil {
|
||||||
UserStatus[m.Chat.ID] = USWillBind
|
UserStatus[m.Chat.ID] = USWillBind
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user