當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Line.Public方法代碼示例

本文整理匯總了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)
}
開發者ID:andyleap,項目名稱:srvbot,代碼行數:9,代碼來源:endpoint_irc.go

示例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.")
		}
	}
}
開發者ID:cneill,項目名稱:rusty-robot,代碼行數:49,代碼來源:handlers.go


注:本文中的github.com/fluffle/goirc/client.Line.Public方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。