From e0760eaf806276fc535eb3f027213d7748edc9e9 Mon Sep 17 00:00:00 2001 From: Bo-Yi Wu Date: Fri, 4 Nov 2016 11:39:30 +0800 Subject: [PATCH] change , to : Signed-off-by: Bo-Yi Wu --- plugin.go | 3 ++- plugin_test.go | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/plugin.go b/plugin.go index ae9739b..ecca361 100644 --- a/plugin.go +++ b/plugin.go @@ -136,10 +136,11 @@ func convertLocation(value string) (Location, bool) { } func parseTo(value, authorEmail string) (int64, bool) { - ids := trimElement(strings.Split(value, ",")) + ids := trimElement(strings.Split(value, ":")) if len(ids) > 1 { if email := ids[1]; email != authorEmail { + log.Println("email not match") return int64(0), false } } diff --git a/plugin_test.go b/plugin_test.go index 45ea800..ab51b44 100644 --- a/plugin_test.go +++ b/plugin_test.go @@ -68,7 +68,7 @@ func TestSendMessage(t *testing.T) { Config: Config{ Token: os.Getenv("TELEGRAM_TOKEN"), - To: []string{os.Getenv("TELEGRAM_TO"), os.Getenv("TELEGRAM_TO") + ",appleboy@gmail.com", "中文ID", "1234567890"}, + To: []string{os.Getenv("TELEGRAM_TO"), os.Getenv("TELEGRAM_TO") + ":appleboy@gmail.com", "中文ID", "1234567890"}, Message: []string{"Test Telegram Chat Bot From Travis or Local", "commit message: 『{{ build.message }}』", " "}, Photo: []string{"tests/github.png", "1234", " "}, Document: []string{"tests/gophercolor.png", "1234", " "}, @@ -138,17 +138,17 @@ func TestParseTo(t *testing.T) { assert.Equal(t, true, enable) assert.Equal(t, int64(1234567890), id) - id, enable = parseTo("1234567890,test2@gmail.com", "test@gmail.com") + id, enable = parseTo("1234567890:test2@gmail.com", "test@gmail.com") assert.Equal(t, false, enable) assert.Equal(t, int64(0), id) - id, enable = parseTo("1234567890,test@gmail.com", "test@gmail.com") + id, enable = parseTo("1234567890:test@gmail.com", "test@gmail.com") assert.Equal(t, true, enable) assert.Equal(t, int64(1234567890), id) - id, enable = parseTo("測試,test@gmail.com", "test@gmail.com") + id, enable = parseTo("測試:test@gmail.com", "test@gmail.com") assert.Equal(t, false, enable) assert.Equal(t, int64(0), id)