add command parser

This commit is contained in:
Jay 2019-09-16 07:51:32 +00:00
parent 245bdf8c78
commit 368e29b3de
2 changed files with 10 additions and 2 deletions

View File

@ -20,10 +20,10 @@ func addServer(info EvtInfo, name string) string {
exists, err := dsmodel.GetServerByID(info.Server)
if err != nil {
log.Println("check server exists fail :: ", err)
return ErrCheckServer
return ErrCheckServer.Error()
}
if exists != nil {
return ErrServerExists
return ErrServerExists.Error()
}
ds, err := dsmodel.NewServer(info.Server, name, 0)

View File

@ -167,6 +167,14 @@ func selectAction(info EvtInfo, cmdKey, cmdValue, payload string) string {
return addFacebookPage(info, strs[0], strings.Join(strs[1:], " "))
case "ds_delfacebook":
return delFacebookPage(info, payload)
case "ds_addinstagram":
strs := strings.Split(payload, " ")
if len(strs) < 2 {
return "!ds_addinstagram {instagram_id} {template}"
}
return addInstagram(info, strs[0], strings.Join(strs[1:], " "))
case "ds_delinstagram":
return delInstagram(info, payload)
}
return ""