telebot/telebot_test.go

38 lines
625 B
Go
Raw Normal View History

2015-06-25 19:32:41 +00:00
package telebot
import (
"log"
"testing"
"time"
)
2015-06-25 19:32:41 +00:00
const TESTING_TOKEN = "107177593:AAHBJfF3nv3pZXVjXpoowVhv_KSGw56s8zo"
func TestCreate(t *testing.T) {
_, err := Create(TESTING_TOKEN)
if err != nil {
t.Fatal(err)
}
}
func TestListen(t *testing.T) {
if testing.Short() {
t.Skip("Skipping test in short mode.")
}
bot, err := Create(TESTING_TOKEN)
if err != nil {
t.Fatal(err)
}
bot.AddListener(func(bot *Bot, message Message) {
2015-06-26 16:12:54 +00:00
if message.Text == "/hi" {
2015-06-26 16:27:32 +00:00
bot.SendMessage(message.Chat,
2015-06-26 16:12:54 +00:00
"Hello, "+message.Sender.FirstName+"!")
}
})
log.Println("Listening...")
bot.Listen(1 * time.Second)
}