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


Golang ircx.Sender類代碼示例

本文整理匯總了Golang中github.com/nickvanw/ircx.Sender的典型用法代碼示例。如果您正苦於以下問題:Golang Sender類的具體用法?Golang Sender怎麽用?Golang Sender使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


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

示例1: commandSender

func (c *Client) commandSender(sender ircx.Sender, to string, enc bool) func(s string, a ...interface{}) {
	return func(s string, a ...interface{}) {
		if s == "" {
			return
		}
		msg := s
		if len(a) > 0 {
			msg = fmt.Sprintf(msg, a...)
		}
		if enc {
			if key, ok := c.state.Encryption().Check(to); ok {
				data, err := dh1080.Enc([]byte(msg), []byte(key))
				if err == nil {
					msg = "+OK *" + base64.StdEncoding.EncodeToString(data)
				}
			}
		}
		newMsg := &irc.Message{
			Command:  irc.PRIVMSG,
			Params:   []string{to},
			Trailing: msg,
		}
		sender.Send(newMsg)
	}
}
開發者ID:nickvanw,項目名稱:bogon,代碼行數:25,代碼來源:commands.go

示例2: PingHandler

func PingHandler(s ircx.Sender, m *irc.Message) {
	s.Send(&irc.Message{
		Command:  irc.PONG,
		Params:   m.Params,
		Trailing: m.Trailing,
	})
}
開發者ID:mycroft,項目名稱:go-snippets,代碼行數:7,代碼來源:main.go

示例3: RegisterConnect

func RegisterConnect(s ircx.Sender, m *irc.Message) {
	for _, irc_chan := range config.General.Channels {
		s.Send(&irc.Message{
			Command: irc.JOIN,
			Params:  []string{irc_chan.Name, irc_chan.Pass},
		})
	}
}
開發者ID:derekmorr,項目名稱:uugbot,代碼行數:8,代碼來源:main.go

示例4: pingHandler

func pingHandler(s ircx.Sender, m *irc.Message) {
	// special case, don't use message queue
	s.Send(&irc.Message{
		Command:  irc.PONG,
		Params:   m.Params,
		Trailing: m.Trailing,
	})
}
開發者ID:cosban,項目名稱:muggy,代碼行數:8,代碼來源:bot.go

示例5: RegisterConnect

func RegisterConnect(s ircx.Sender, m *irc.Message) {
	channel := fmt.Sprintf("#%s", *user)
	fmt.Println("Connected, joining", channel, "...")
	s.Send(&irc.Message{
		Command: irc.JOIN,
		Params:  []string{channel},
	})
}
開發者ID:progrium,項目名稱:twitchsay,代碼行數:8,代碼來源:twitchsay.go

示例6: RegisterConnect

func RegisterConnect(s ircx.Sender, m *irc.Message) {
	log.Println(*user + " joining channel " + *channel)

	s.Send(&irc.Message{
		Command: irc.JOIN,
		Params:  []string{*channel},
	})
}
開發者ID:gmaliar,項目名稱:twitch-irc-bot,代碼行數:8,代碼來源:main.go

示例7: nickTakenHandler

func (c *Client) nickTakenHandler(s ircx.Sender, m *irc.Message) {
	newName := fmt.Sprintf("%s|", c.state.Name())
	msg := &irc.Message{
		Command: irc.NICK,
		Params:  []string{newName},
	}
	c.state.SetName(newName)
	s.Send(msg)
}
開發者ID:nickvanw,項目名稱:bogon,代碼行數:9,代碼來源:state_handlers.go

示例8: onPing

func onPing(s ircx.Sender, m *irc.Message) {
	err := s.Send(&irc.Message{
		Command:  irc.PONG,
		Params:   m.Params,
		Trailing: m.Trailing,
	})
	if err != nil {
		log.Printf("Could not reply to PING: %v", err)
	}
}
開發者ID:mvdan,項目名稱:gibot,代碼行數:10,代碼來源:handlers.go

示例9: onWelcome

func onWelcome(s ircx.Sender, m *irc.Message) {
	log.Printf("Connected.")
	err := s.Send(&irc.Message{
		Command: irc.JOIN,
		Params:  []string{strings.Join(config.Chans, ",")},
	})
	if err != nil {
		log.Printf("Could not send JOIN: %v", err)
	}
}
開發者ID:mvdan,項目名稱:gibot,代碼行數:10,代碼來源:handlers.go

示例10: JoinHandler

func JoinHandler(s ircx.Sender, m *irc.Message) {
	if m.Name != name {
		userAdd(m.Name, m.Trailing)
	} else {
		s.Send(&irc.Message{
			Command:  irc.WHO,
			Params:   []string{m.Params[0]},
			Trailing: "%na",
		})
	}
}
開發者ID:cosban,項目名稱:muggy,代碼行數:11,代碼來源:tracking.go

示例11: pingHandler

func pingHandler(s ircx.Sender, m *irc.Message) {
	err := s.Send(&irc.Message{
		Command:  irc.PONG,
		Params:   m.Params,
		Trailing: m.Trailing,
	})

	if err != nil {
		log.Error(err)
	}
}
開發者ID:BigRoom,項目名稱:profx,代碼行數:11,代碼來源:bot.go

示例12: encryptionMsgHandler

func (c *Client) encryptionMsgHandler(s ircx.Sender, m *irc.Message) {
	if dm, ok := c.decodedMessage(m); ok && dm.Trailing == ".encoff" {
		c.state.Encryption().Stop(m.Name)
		out := "I've removed the key for this conversation"
		msg := &irc.Message{
			Command:  irc.PRIVMSG,
			Params:   []string{m.Name},
			Trailing: out,
		}
		s.Send(msg)
	}
}
開發者ID:nickvanw,項目名稱:bogon,代碼行數:12,代碼來源:encryption.go

示例13: inviteHandler

func (c *Client) inviteHandler(s ircx.Sender, m *irc.Message) {
	var channel string
	if len(m.Params) > 1 {
		channel = m.Params[1]
	} else {
		channel = m.Trailing
	}
	msg := &irc.Message{
		Command: irc.JOIN,
		Params:  []string{channel},
	}
	s.Send(msg)
}
開發者ID:nickvanw,項目名稱:bogon,代碼行數:13,代碼來源:state_handlers.go

示例14: kickHandler

func (c *Client) kickHandler(s ircx.Sender, m *irc.Message) {
	if m.Params[1] == c.state.Name() {
		c.state.RemoveChannel(m.Params[0])
		if c.state.Rejoin() {
			msg := &irc.Message{
				Command: irc.JOIN,
				Params:  []string{m.Params[0]},
			}
			s.Send(msg)
		}
	} else {
		c.state.RemoveUser(m.Params[0], m.Params[1])
	}
}
開發者ID:nickvanw,項目名稱:bogon,代碼行數:14,代碼來源:state_handlers.go

示例15: registerHandler

func registerHandler(s ircx.Sender, m *irc.Message) {
	log.Debug("Registered")

	for _, channel := range strings.Split(*channels, " ") {
		err := s.Send(&irc.Message{
			Command: irc.JOIN,
			Params:  []string{channel},
		})

		if err != nil {
			log.WithFields(log.Fields{
				"channel": *channels,
				"host":    *serverName,
			}).Error(err)
		}

	}
}
開發者ID:BigRoom,項目名稱:profx,代碼行數:18,代碼來源:bot.go


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