2015-06-25 19:32:41 +00:00
|
|
|
package telebot
|
|
|
|
|
2015-06-26 07:34:10 +00:00
|
|
|
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)
|
|
|
|
}
|
|
|
|
}
|
2015-06-26 07:34:10 +00:00
|
|
|
|
|
|
|
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+"!")
|
|
|
|
}
|
2015-06-26 07:34:10 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
log.Println("Listening...")
|
|
|
|
bot.Listen(1 * time.Second)
|
|
|
|
}
|