本文整理汇总了Golang中github.com/mattermost/platform/model.Command.GotoLocation方法的典型用法代码示例。如果您正苦于以下问题:Golang Command.GotoLocation方法的具体用法?Golang Command.GotoLocation怎么用?Golang Command.GotoLocation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/mattermost/platform/model.Command
的用法示例。
在下文中一共展示了Command.GotoLocation方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: joinCommand
func joinCommand(c *Context, command *model.Command) bool {
// looks for "/join channel-name"
cmd := "/join"
if strings.Index(command.Command, cmd) == 0 {
parts := strings.Split(command.Command, " ")
startsWith := ""
if len(parts) == 2 {
startsWith = parts[1]
}
if result := <-Srv.Store.Channel().GetMoreChannels(c.Session.TeamId, c.Session.UserId); result.Err != nil {
c.Err = result.Err
return false
} else {
channels := result.Data.(*model.ChannelList)
for _, v := range channels.Channels {
if v.Name == startsWith && !command.Suggest {
if v.Type == model.CHANNEL_DIRECT {
return false
}
JoinChannel(c, v.Id, "")
if c.Err != nil {
return false
}
command.GotoLocation = c.GetTeamURL() + "/channels/" + v.Name
command.Response = model.RESP_EXECUTED
return true
}
if len(startsWith) == 0 || strings.Index(v.Name, startsWith) == 0 {
command.AddSuggestion(&model.SuggestCommand{Suggestion: cmd + " " + v.Name, Description: "Join the open channel"})
}
}
}
} else if strings.Index(cmd, command.Command) == 0 {
command.AddSuggestion(&model.SuggestCommand{Suggestion: cmd, Description: "Join an open channel"})
}
return false
}
示例2: logoutCommand
func logoutCommand(c *Context, command *model.Command) bool {
cmd := "/logout"
if strings.Index(command.Command, cmd) == 0 {
command.AddSuggestion(&model.SuggestCommand{Suggestion: cmd, Description: "Logout"})
if !command.Suggest {
command.GotoLocation = "/logout"
command.Response = model.RESP_EXECUTED
return true
}
} else if strings.Index(cmd, command.Command) == 0 {
command.AddSuggestion(&model.SuggestCommand{Suggestion: cmd, Description: "Logout"})
}
return false
}