init: web_hgdjc_server
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
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")
|
||||
}
|
||||
Reference in New Issue
Block a user