func connected(conn *irc.Conn, line *irc.Line) { println("Connected!") conn.Pass(config.Password) conn.Join(config.Channel) conn.Privmsg(config.Channel, "¡Saludos!") constantlyReadTwitter(conn) }
func bot_connected(irc *client.Conn, line *client.Line) { bot := getState(irc) for _, c := range bot.channels { bot.l.Info("Joining %s on startup.\n", c) irc.Join(c) } }
func AutoJoin(conn *irc.Conn, channel string) { autoJoinLock.Lock() defer autoJoinLock.Unlock() if autoJoinChannels[channel] { return } autoJoinChannels[channel] = true conn.AddHandler("CONNECTED", func(c *irc.Conn, l *irc.Line) { conn.Join(channel) }) }
func autojoin(conn *irc.Conn) { for _, s := range sections { split := strings.SplitN(s, " ", 2) if len(split) == 2 && split[0] == conn.Network { // found a channel if readConfBool(s, "autojoin") { fmt.Printf("Joining %s on %s\n", split[1], conn.Network) conn.Join(split[1]) } } } go BanManager(conn) }
func ui(con *irc.Conn, in chan string) { curr_chan := "" for input := range in { if input[0] == '/' { // is a command var cmd string cmdend := strings.Index(input, " ") if cmdend > 0 { cmd = input[:cmdend] } else { cmd = input } switch cmd { case "/join": if len(input) > cmdend { channel := input[cmdend+1:] if channel[0] != '#' { channel = "#" + channel } curr_chan = channel con.Join(channel) } else { fmt.Println("Please specify the channel") } case "/quit": fmt.Println("Bye!") con.Quit() case "/goto": curr_chan = input[cmdend+1:] case "/list": break case "/nick": if cmdend > 0 { con.Nick(input[cmdend+1:]) } else { fmt.Println("Too few arguments") } default: fmt.Println("Unknown command") } fmt.Printf("\n%s: ", curr_chan) } else { con.Privmsg(curr_chan, input) fmt.Printf("%s: ", curr_chan) } } fmt.Println("Closing connection. kthxbai!") con.Quit() }
func handleInvite(conn *irc.Conn, line *irc.Line) { if line.Args[0] != conn.Me.Nick { return } user := line.Src[strings.Index(line.Src, "!")+1:] if user[0] == '~' { user = user[1:] } owner, _ := auth.String(conn.Network, "owner") if user == owner { conn.Join(line.Args[1]) } }
func onInvite(irc *client.Conn, line *client.Line) { who, channel := line.Args[0], line.Args[1] log.Println(line.Nick, "invited bot to", channel) if who == irc.Me.Nick { // some IRCds only allow operators to INVITE, and on registered channels normally only identified users are operators // check anyway, since there are some corner cases where that doesn't happen if checkIdentified(irc, line.Nick) { log.Println("Accepting invite to", channel) irc.Join(channel) } else { irc.Notice(line.Nick, "you must be identified to invite") log.Println("Ignoring invite, user is not identified") } } }
func (s InBandSource) Connect(c *irc.Conn) (err error) { if c.Connected { return nil } c.AddHandler(irc.CONNECTED, func(c *irc.Conn, line *irc.Line) { c.Join(s.Host().Channel) }) if err := c.Connect(s.Host().Server); err != nil { return err } return nil }
func autojoin(conn *irc.Conn) { for _, s := range sections { split := strings.SplitN(s, " ", 2) if len(split) == 2 && split[0] == conn.Network { // found a channel if readConfBool(s, "autojoin") { fmt.Printf("Joining %s on %s\n", split[1], conn.Network) conn.Join(split[1]) } if annstream, _ := conf.Bool(s, "stream"); annstream { announceJustinTv(conn, split[1]) } } } }
func setupClient(c *irc.Conn, chConnected chan bool) { c.AddHandler(irc.CONNECTED, func(conn *irc.Conn, line *irc.Line) { chConnected <- true }) c.AddHandler(irc.DISCONNECTED, func(conn *irc.Conn, line *irc.Line) { chConnected <- false }) c.AddHandler("PRIVMSG", func(conn *irc.Conn, line *irc.Line) { if len(line.Args) < 2 || !strings.HasPrefix(line.Args[1], "!") { return } to := line.Args[0] sender := to if to == c.Me.Nick { // TODO: check if sender is in main chan, else return log.Println("Got ! via PM from " + line.Src) sender = line.Src // replies go via PM too. } else { log.Println("Got ! via chan: " + line.Args[0] + " from " + line.Src) } log.Println(line.Args) switch line.Args[0] { case "!join": if len(line.Args) == 2 { c.Join(line.Args[1]) } else if len(line.Args) == 3 { c.Join(line.Args[1] + " " + line.Args[2]) } else { c.Privmsg(sender, "Usage: !join #chan or !join #chan key") } case "!part": if len(line.Args) == 2 { c.Part(line.Args[1]) } else { c.Privmsg(sender, "Usage: !part #chan") } default: c.Privmsg(sender, "Invalid command: "+strings.Join(line.Args[1:], " ")) return } }) }
func (p *IRCPlug) onConnected(c *client.Conn, l *client.Line) { for _, ch := range p.config.Channels { c.Join(ch) } }
func postConnect(conn *irc.Conn, line *irc.Line) { conn.Join(channel) }
func (ei *EndpointIRC) connect(c *irc.Conn, l *irc.Line) { for _, channel := range ei.Config.Channels { c.Join(channel) } }
func (i *IRC) onConnect(conn *client.Conn, line *client.Line) { for _, c := range i.channels { conn.Join(c) } }