本文整理匯總了Golang中github.com/fluffle/goirc/client.Line.Public方法的典型用法代碼示例。如果您正苦於以下問題:Golang Line.Public方法的具體用法?Golang Line.Public怎麽用?Golang Line.Public使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/fluffle/goirc/client.Line
的用法示例。
在下文中一共展示了Line.Public方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: message
func (ei *EndpointIRC) message(c *irc.Conn, l *irc.Line) {
var messageTarget MessageTarget
if l.Public() {
messageTarget = ei.GetChannel(l.Target())
} else {
messageTarget = ei.GetUser(l.Target())
}
ei.handler(l.Text(), ei.GetUser(l.Nick), l.Target(), messageTarget)
}
示例2: handle_command
func handle_command(conn *irc.Conn, line *irc.Line, args []string) {
command := args[0][len(RC.CmdPrefix):]
args = args[1:]
st := conn.StateTracker()
authed := RC.Authed[line.Nick]
if line.Nick == RC.Owner && authed {
// Owner-only commands
if command == "mock" {
for _, n := range args {
_, is_on := st.IsOn(RC.Channel, n)
if is_on {
RC.Mocking[n] = true
conn.Privmsg(RC.Channel, "Now mocking "+n)
}
}
} else if command == "unmock" {
for _, n := range args {
if RC.Mocking[n] {
RC.Mocking[n] = false
conn.Privmsg(RC.Channel, "No longer mocking "+n)
}
}
} else if command == "shorten" {
fmt.Println("unimplemented")
} else if command == "snoop" {
fmt.Println("unimplemented")
}
} else if (RC.Ops[line.Nick] || line.Nick == RC.Owner) && authed {
// Ops-level commands
if command == "poop" {
conn.Privmsg(RC.Channel, "poop")
}
} else if command == "identify" && !line.Public() {
fmt.Println("User " + line.Nick + " attempting to auth...")
h := sha256.New()
h.Write([]byte(args[0]))
pwd_hash := hex.EncodeToString(h.Sum(nil))
if (line.Nick == RC.Owner || RC.Ops[line.Nick]) && RC.Password == pwd_hash {
fmt.Println("Auth succeeded for " + line.Nick)
RC.Authed[line.Nick] = true
conn.Privmsg(line.Nick, "You're authenticated now.")
} else {
fmt.Println("WARNING: Auth failed for " + line.Nick + "!")
conn.Privmsg(line.Nick, "You fucked up.")
}
}
}