change , to :
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
This commit is contained in:
parent
b16d4444dc
commit
e0760eaf80
@ -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
|
||||
}
|
||||
}
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user