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


Golang Message.Dup方法代碼示例

本文整理匯總了Golang中kevlar/ircd/parser.Message.Dup方法的典型用法代碼示例。如果您正苦於以下問題:Golang Message.Dup方法的具體用法?Golang Message.Dup怎麽用?Golang Message.Dup使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在kevlar/ircd/parser.Message的用法示例。


在下文中一共展示了Message.Dup方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: Uid

func Uid(hook string, msg *parser.Message, ircd *IRCd) {
	nickname, hopcount, nickTS := msg.Args[0], msg.Args[1], msg.Args[2]
	umode, username, hostname := msg.Args[3], msg.Args[4], msg.Args[5]
	ip, uid, name := msg.Args[6], msg.Args[7], msg.Args[8]
	_ = umode

	err := user.Import(uid, nickname, username, hostname, ip, hopcount, nickTS, name)
	if err != nil {
		// TODO: TS check - Kill remote or local? For now, we kill remote.
		ircd.ToServer <- &parser.Message{
			Prefix:  Config.SID,
			Command: parser.CMD_SQUIT,
			Args: []string{
				uid,
				err.String(),
			},
			DestIDs: []string{msg.SenderID},
		}
	}

	for fwd := range server.Iter() {
		if fwd != msg.SenderID {
			log.Debug.Printf("Forwarding UID from %s to %s", msg.SenderID, fwd)
			fmsg := msg.Dup()
			fmsg.DestIDs = []string{fwd}
		}
	}
}
開發者ID:kylelemons,項目名稱:ircd-blight,代碼行數:28,代碼來源:registration.go

示例2: SQuit

func SQuit(hook string, msg *parser.Message, ircd *IRCd) {
	split, reason := msg.Args[0], msg.Args[1]

	if split == Config.SID {
		split = msg.SenderID
	}

	// Forward
	for sid := range server.Iter() {
		if sid != msg.SenderID {
			msg := msg.Dup()
			msg.DestIDs = []string{sid}
			ircd.ToServer <- msg
		}
	}
	if server.IsLocal(split) {
		ircd.ToServer <- &parser.Message{
			Command: parser.CMD_ERROR,
			Args: []string{
				"SQUIT: " + reason,
			},
		}
	}

	sids := server.Unlink(split)
	peers := user.Netsplit(sids)
	notify := channel.Netsplit(Config.SID, peers)

	log.Debug.Printf("NET SPLIT: %s", split)
	log.Debug.Printf(" -   SIDs: %v", sids)
	log.Debug.Printf(" -  Peers: %v", peers)
	log.Debug.Printf(" - Notify: %v", notify)

	for uid, peers := range notify {
		if len(peers) > 0 {
			ircd.ToClient <- &parser.Message{
				Prefix:  uid,
				Command: parser.CMD_QUIT,
				Args: []string{
					"*.net *.split",
				},
				DestIDs: peers,
			}
		}
	}
	// Delete all of the peers
	if len(peers) > 0 {
		ircd.ToClient <- &parser.Message{
			Command: parser.INT_DELUSER,
			DestIDs: peers,
		}
	}
}
開發者ID:kylelemons,項目名稱:ircd-blight,代碼行數:53,代碼來源:registration.go

示例3: SPart

// Server PART
func SPart(hook string, msg *parser.Message, ircd *IRCd) {
	chanlist, reason := strings.Split(msg.Args[0], ","), msg.Args[1]

	// Forward on to other servers
	for fwd := range server.Iter() {
		if fwd != msg.SenderID {
			log.Debug.Printf("Forwarding PART from %s to %s", msg.SenderID, fwd)
			fmsg := msg.Dup()
			fmsg.DestIDs = []string{fwd}
		}
	}

	for _, channame := range chanlist {
		channel, err := channel.Get(channame, false)
		if num, ok := err.(*parser.Numeric); ok {
			ircd.ToServer <- num.Error(msg.SenderID)
			return
		}

		chanusers, err := channel.Part(msg.Prefix)
		if num, ok := err.(*parser.Numeric); ok {
			ircd.ToServer <- num.Error(msg.SenderID)
			return
		}

		notify := []string{}
		for _, uid := range chanusers {
			if uid[:3] == Config.SID {
				notify = append(notify, uid)
			}
		}

		if len(notify) > 0 {
			ircd.ToClient <- &parser.Message{
				Prefix:  msg.Prefix,
				Command: parser.CMD_PART,
				Args: []string{
					channel.Name(),
					reason,
				},
				DestIDs: notify,
			}
		}
	}
}
開發者ID:kylelemons,項目名稱:ircd-blight,代碼行數:46,代碼來源:channel.go

示例4: Sid

func Sid(hook string, msg *parser.Message, ircd *IRCd) {
	servname, hopcount, sid, desc := msg.Args[0], msg.Args[1], msg.Args[2], msg.Args[3]

	err := server.Link(msg.Prefix, sid, servname, hopcount, desc)
	if err != nil {
		ircd.ToServer <- &parser.Message{
			Prefix:  Config.SID,
			Command: parser.CMD_SQUIT,
			Args: []string{
				sid,
				err.String(),
			},
			DestIDs: []string{msg.SenderID},
		}
	}

	for fwd := range server.Iter() {
		if fwd != msg.SenderID {
			log.Debug.Printf("Forwarding SID from %s to %s", msg.SenderID, fwd)
			fmsg := msg.Dup()
			fmsg.DestIDs = []string{fwd}
		}
	}
}
開發者ID:kylelemons,項目名稱:ircd-blight,代碼行數:24,代碼來源:registration.go

示例5: SJoin

// Server JOIN and SJOIN
func SJoin(hook string, msg *parser.Message, ircd *IRCd) {
	chanTS, channame, mode := msg.Args[0], msg.Args[1], msg.Args[2]

	uids := []string{msg.Prefix}
	if len(msg.Prefix) == 3 {
		if len(msg.Args) == 3 {
			return
		}
		uids = strings.Split(msg.Args[3], " ")
	}

	_ = chanTS
	_ = mode

	// Forward on to other servers
	for fwd := range server.Iter() {
		if fwd != msg.SenderID {
			log.Debug.Printf("Forwarding SJOIN from %s to %s", msg.SenderID, fwd)
			fmsg := msg.Dup()
			fmsg.DestIDs = []string{fwd}
		}
	}

	for i, uid := range uids {
		uids[i] = uid[len(uid)-9:]
	}

	channel, err := channel.Get(channame, true)
	if num, ok := err.(*parser.Numeric); ok {
		ircd.ToServer <- num.Error(msg.SenderID)
		return
	}

	if len(uids) == 0 && len(msg.Prefix) == 9 {
		uids = []string{msg.Prefix}
	}

	chanusers, err := channel.Join(uids...)
	if num, ok := err.(*parser.Numeric); ok {
		ircd.ToServer <- num.Error(msg.SenderID)
		return
	}

	notify := []string{}
	for _, uid := range chanusers {
		if uid[:3] == Config.SID {
			notify = append(notify, uid)
		}
	}

	if len(notify) > 0 {
		for _, joiner := range uids {
			ircd.ToClient <- &parser.Message{
				Prefix:  joiner,
				Command: parser.CMD_JOIN,
				Args: []string{
					channel.Name(),
				},
				DestIDs: notify,
			}
		}
	}
}
開發者ID:kylelemons,項目名稱:ircd-blight,代碼行數:64,代碼來源:channel.go


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