Exemple #1
0
func OnConnect(event string, serv *bot.Server, msg *bot.Message) {
	if *nsid != "" {
		serv.WriteMessage(bot.NewMessage("", bot.CMD_PRIVMSG, "NickServ", "IDENTIFY "+*nsid))
		time.Sleep(3)
	}
	serv.WriteMessage(bot.NewMessage("", "JOIN", *channel))
}
Exemple #2
0
func waitloop(psrv proto.GoPaste) {
	chans := strings.Split(*chans, ",")
	in, out := proto.Empty{}, proto.Posted{}

	var (
		errdelay   = 100 * time.Millisecond
		startdelay = 100 * time.Millisecond
		maxdelay   = 10 * time.Minute
	)
	for {
		err := psrv.Next(&in, &out)
		if err != nil {
			log.Printf("paste: next URL: %s", err)
			time.Sleep(errdelay)
			errdelay *= 2
			if errdelay > maxdelay {
				errdelay = maxdelay
			}
			continue
		}
		errdelay = startdelay

		if out.Url == nil {
			log.Printf("paste: warning: empty URL")
			continue
		}

		func() {
			servlock.Lock()
			defer servlock.Unlock()

			for _, cname := range chans {
				msg := bot.NewMessage("", bot.CMD_PRIVMSG, cname, "gopaste: "+*out.Url)
				for sname, s := range servers {
					log.Printf("paste: sending paste to %s on %s", cname, sname)
					s.WriteMessage(msg)
				}
			}
		}()
	}
}
Exemple #3
0
func (g *Game) Chanf(format string, args ...interface{}) {
	g.server.WriteMessage(bot.NewMessage("", "PRIVMSG", g.channel, fmt.Sprintf(format, args...)))
}
Exemple #4
0
func (r *Response) Printf(format string, args ...interface{}) {
	if r.target == "" {
		return
	}
	r.out <- bot.NewMessage("", r.msgtyp, r.target, fmt.Sprintf(format, args...))
}
Exemple #5
0
func (r *Response) WriteString(s string) {
	if r.target == "" {
		return
	}
	r.out <- bot.NewMessage("", r.msgtyp, r.target, s)
}