Files
web_hgtv_h5/pub/common/tgbot/tgbot_test.go
T
谢宇宁andClaude Opus 5.5 3639d2184a Initial commit
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-22 14:47:17 +07:00

36 lines
694 B
Go

package tgbot
import (
"testing"
)
func create(t *testing.T) *TgBot {
token := "1014745091:AAFkw5j3Fw4ytvWgIll6iRH1q5WooS6JO74"
robot := NewTelegramBot(token)
if err := robot.Init(); err != nil {
t.Error(err)
t.Fail()
}
// 注册命令.
cmds := BotCmdList{NewBotCmd("test", "return testfunc result", testfunc)}
robot.RegisterCommands(cmds)
return robot
}
func testfunc(string, int64) TgCmdRsp {
return TgCmdRsp{Buf: []byte("help"), BufType: TextType}
}
func TestReceive(t *testing.T) {
robot := create(t)
if err := robot.Receive(); err != nil {
t.Error(err)
t.Fail()
}
}
func TestSend(t *testing.T) {
robot := create(t)
robot.Send([]int64{790603940}, "test send")
}