From 29fdfc0640c46cc393aa674728d18821b00427f7 Mon Sep 17 00:00:00 2001 From: shoopea Date: Sat, 1 Feb 2020 20:02:02 +0800 Subject: [PATCH] test --- bot.go | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/bot.go b/bot.go index 379737d..0305b5c 100644 --- a/bot.go +++ b/bot.go @@ -23,6 +23,8 @@ func BotHandlers(b *tb.Bot) { b.Handle("/test", botTest) b.Handle("/test_delay", botTestDelay) b.Handle("/test_html", botTestHTML) + b.Handle("/test_user", botTestUser) + b.Handle("/msg_rescan", botMsgRescan) b.Handle("/msg_rescan_all", botMsgRescanAll) b.Handle("/msg_dump", botMsgDump) @@ -171,6 +173,36 @@ func botHelp(m *tb.Message) { return } +func botTestUser(m *tb.Message) { + if !m.Private() { + return + } + + c, err := bot.ChatByID(m.Payload) + + if err != nil { + c := TGCommand{ + Type: commandReplyMsg, + Text: fmt.Sprintf("%s", err), + FromMsgID64: int64(m.ID), + FromChatID64: m.Chat.ID, + ParseMode: cmdParseModeHTML, + } + TGCmdQueue <- c + } else { + c := TGCommand{ + Type: commandReplyMsg, + Text: c.Username, + FromMsgID64: int64(m.ID), + FromChatID64: m.Chat.ID, + ParseMode: cmdParseModeHTML, + } + TGCmdQueue <- c + } + + return +} + func botTestHTML(m *tb.Message) { if !m.Private() { return