Esempio n. 1
0
int reply(info_t * in) {
   char *p;

   if (in->cmd == cmd_numeric && in->numeric == 1) {
      strnzcpy(in->me, in->argv[0], NICKLEN+1);
   } else if (in->cmd == cmd_nick) {
      if (!strcasecmp(in->sender_nick, in->me)) {
	if (strlen(in->tail))
          strnzcpy(in->me, in->tail, NICKLEN+1);
        else if (strlen(in->argv[0]))
	  strnzcpy(in->me, in->argv[0], NICKLEN+1);
	if (!strcasecmp(in->me, wantednick))
		wantednick[0] = '\0';
      } else if (wantednick[0] && !strcasecmp(in->sender_nick, wantednick)){
      	irc_send("NICK %s", wantednick);
        lasttry = time(NULL);
      }
   } else if (in->cmd == cmd_numeric && in->numeric == 433 && !in->me[0]) {
      irc_send("NICK %s_", in->argv[1]);
      lasttry = time(NULL);
      strnzcpy(wantednick, in->argv[1], NICKLEN+1);
   } else if (in->cmd == cmd_privmsg && CHECKAUTH(in->sender, UL_OP)) {
      in->tail = skip_nick(in->tail, in->me);
      if(!tail_cmd(&in->tail, "nick") && (p = tail_getp(&in->tail))) {
         irc_send("NICK %s", p);
         lasttry = time(NULL);
	 strnzcpy(wantednick, p, NICKLEN+1);
      }
      if(!tail_cmd(&in->tail, "whoareyou"))
	irc_privmsg(to_sender(in), "I am %s", in->me);
   }
   return 0;
}
Esempio n. 2
0
int reply(info_t * in) {
   int i;
   http_req_t *req;
   char buf[4096], *p;
   unsigned long now;

   if (in->cmd == cmd_privmsg) {
      in->tail = skip_nick(in->tail, in->me);
      if (!tail_cmd(&in->tail, "weather")) {
         now = time(NULL);
         if (!CHECKAUTH(in->sender, UL_OP) && lastcall > now - 10) {
            irc_privmsg(to_sender(in), "Please wait a moment");
            return 0;
         }
         
         if (!in->tail || !in->tail[0])
            return 0;

         p = config_get("weather.so", "url");
         if (!p || (i = strlen(p)) >= sizeof(buf))
            return 0;
         strcpy(buf, p);
         if (http_escape_str(in->tail, buf + i, sizeof(buf) -i))
            return 0;
         req = http_new(http_cb);
         if (!req)
            return 0;
         http_setptr(req, strdup(to_sender(in)));
         http_get(req, buf);
         lastcall = now;
      }
   }
   return 0;
}
Esempio n. 3
0
int reply(info_t * in) {
	int e, m;

	if (in->cmd == cmd_privmsg && !tail_cmd(&in->tail,"alignment")) {
		e = rrand(3);
		m = rrand(3);
		if ((e == 1) && (m == 1))
			e = 3;
		irc_privmsg(to_sender(in), "Your alignment is %s %s.", 
			ethic[e], moral[m]);
	}
	return 0;
}
Esempio n. 4
0
int reply(info_t * in) {
	char *p;
	int i;

	if (in->cmd == cmd_privmsg && !tail_cmd(&in->tail,"fut")) {
		i = config_getcnt("fut.so", "insult");
		p = tail_getp(&in->tail);
		if(p) {
			irc_privmsg(to_sender(in), "%s: %s", p, 
				i?config_getn("fut.so", "insult", rrand(i)):"Fut");
		} else {
			irc_privmsg(to_sender(in), "%s",
				i?config_getn("fut.so", "insult", rrand(i)):"Fut");
		}
	}

	return 0;
}
Esempio n. 5
0
int reply(info_t * in) {
   time_t now = time(NULL);
   int i, nword[WORD_CNT];
   
   if (talkinfo.last + talkinfo.interval > now)
      return 0;

   if (in->cmd == cmd_privmsg) {
	   if (!tail_cmd(&in->tail, "sercz")) {
		   for(i = 0; i < WORD_CNT; i++) {
			   nword[i] = rrand(talkinfo.nword[i]);
		   }
		   irc_privmsg(to_sender(in), "%s %s",
   			   talkinfo.word[0][nword[0]], talkinfo.word[1][nword[1]]);
		   irc_privmsg(to_sender(in), "%s %d %s %s",
			   talkinfo.word[2][nword[2]], rrand(talkinfo.max - 2) + 2,
			   talkinfo.word[3][nword[3]], talkinfo.word[4][nword[4]]);
		   irc_privmsg(to_sender(in), "und dabei mein%s %s",
			   talkinfo.word[5][nword[5]], talkinfo.word[6][nword[6]]);				
	   }
   }
   return 0;
}
Esempio n. 6
0
int reply(info_t * in) {
  int remain;
  char buf[512];

  if (in->cmd == cmd_privmsg) {
    in->tail = skip_nick(in->tail, in->me);
    if(!tail_cmd(&in->tail, "fortune")
        && randomline(buf, sizeof(buf)) != NULL) {
      if(time(NULL) - lasttime >= req_delay) {
        irc_privmsg(to_sender(in), "%s", buf); 
        lasttime = time(NULL);
      } else {
        remain = req_delay - (time(NULL) - lasttime);
        if(remain > 3600)
          irc_notice(in->sender_nick, "Please wait %d hours.", remain / 3600);
        else if(remain > 60)
          irc_notice(in->sender_nick, "Please wait %d minutes.", remain / 60);
        else
          irc_notice(in->sender_nick, "Please wait %d seconds.", remain);
      }
    }
  }
  return 0;
}