本文整理匯總了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)
}
}
示例2: PingHandler
func PingHandler(s ircx.Sender, m *irc.Message) {
s.Send(&irc.Message{
Command: irc.PONG,
Params: m.Params,
Trailing: m.Trailing,
})
}
示例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},
})
}
}
示例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,
})
}
示例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},
})
}
示例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},
})
}
示例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)
}
示例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)
}
}
示例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)
}
}
示例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",
})
}
}
示例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)
}
}
示例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)
}
}
示例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)
}
示例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])
}
}
示例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)
}
}
}