本文整理汇总了Golang中pkg/config.CherryRooms.GetDeIgnoreAction方法的典型用法代码示例。如果您正苦于以下问题:Golang CherryRooms.GetDeIgnoreAction方法的具体用法?Golang CherryRooms.GetDeIgnoreAction怎么用?Golang CherryRooms.GetDeIgnoreAction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pkg/config.CherryRooms
的用法示例。
在下文中一共展示了CherryRooms.GetDeIgnoreAction方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: PostBannerHandle
// PostBannerHandle implements the handle for the banner document (POST).
func PostBannerHandle(newConn net.Conn, roomName, httpPayload string, rooms *config.CherryRooms, preprocessor *html.Preprocessor) {
var userData map[string]string
var replyBuffer []byte
var invalidRequest = false
userData = rawhttp.GetFieldsFromPost(httpPayload)
if _, has := userData["user"]; !has {
invalidRequest = true
} else if _, has := userData["id"]; !has {
invalidRequest = true
} else if _, has := userData["action"]; !has {
invalidRequest = true
} else if _, has := userData["whoto"]; !has {
invalidRequest = true
} else if _, has := userData["image"]; !has {
invalidRequest = true
} else if _, has := userData["says"]; !has {
invalidRequest = true
}
var restoreBanner = true
if invalidRequest || !rooms.IsValidUserRequest(roomName, userData["user"], userData["id"], newConn) {
replyBuffer = rawhttp.MakeReplyBuffer(html.GetBadAssErrorData(), 404, true)
} else if userData["action"] == rooms.GetIgnoreAction(roomName) {
if userData["user"] != userData["whoto"] && !rooms.IsIgnored(userData["user"], userData["whoto"], roomName) {
rooms.AddToIgnoreList(userData["user"], userData["whoto"], roomName)
rooms.EnqueueMessage(roomName, userData["user"], "", "", "", rooms.GetOnIgnoreMessage(roomName)+userData["whoto"], "1")
restoreBanner = false
}
} else if userData["action"] == rooms.GetDeIgnoreAction(roomName) {
if rooms.IsIgnored(userData["user"], userData["whoto"], roomName) {
rooms.DelFromIgnoreList(userData["user"], userData["whoto"], roomName)
rooms.EnqueueMessage(roomName, userData["user"], "", "", "", rooms.GetOnDeIgnoreMessage(roomName)+userData["whoto"], "1")
restoreBanner = false
}
} else {
var somethingToSay = (len(userData["says"]) > 0 || len(userData["image"]) > 0 || len(userData["sound"]) > 0)
if somethingToSay {
// INFO(Santiago): Any further antiflood control would go from here.
rooms.EnqueueMessage(roomName, userData["user"], userData["whoto"], userData["action"], userData["image"], userData["says"], userData["priv"])
}
}
preprocessor.SetDataValue("{{.nickname}}", userData["user"])
preprocessor.SetDataValue("{{.session-id}}", userData["id"])
if userData["priv"] == "1" {
preprocessor.SetDataValue("{{.priv}}", "checked")
}
tempBanner := preprocessor.ExpandData(roomName, rooms.GetBannerTemplate(roomName))
if restoreBanner {
tempBanner = strings.Replace(tempBanner,
"<option value = \""+userData["whoto"]+"\">",
"<option value = \""+userData["whoto"]+"\" selected>", -1)
tempBanner = strings.Replace(tempBanner,
"<option value = \""+userData["action"]+"\">",
"<option value = \""+userData["action"]+"\" selected>", -1)
}
replyBuffer = rawhttp.MakeReplyBuffer(tempBanner, 200, true)
newConn.Write(replyBuffer)
newConn.Close()
}