Exemplo n.º 1
0
int init() {
   int i, j;
   char *buf;

   talkinfo.last = time(NULL);

   for(i = 0; i < WORD_CNT; i++) {
	   talkinfo.nword[i] = config_getcnt("sercz.so", word[i]);
	   if (!talkinfo.nword[i]) {
		   talkinfo.word[i] = NULL;
         return -1;
      }

	   
	   if(!(talkinfo.word[i] = malloc(talkinfo.nword[i] * sizeof(char*)))) {
         destroy();  
         return -1;
      }
      
	   for(j = 0; j < talkinfo.nword[i]; j++) {
		   talkinfo.word[i][j] = config_getn("sercz.so", word[i], j);
	   }
   }

   buf = config_getn("sercz.so", "interval", 0);
   talkinfo.interval = buf? atoi(buf): 10;

   buf = config_getn("sercz.so", "max", 0);
   talkinfo.max = buf? atoi(buf): 50;

   if(talkinfo.max < 3)
      talkinfo.max = 3;
   return 0;
}
Exemplo n.º 2
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;
}
Exemplo n.º 3
0
void timer(unsigned long ts) {
  int n;
  char *ch, buf[512];

  if (nexttalk <= ts) {
    n = config_getcnt("fortune.so", "channels");
    if (n > 0 && randomline(buf, sizeof(buf)) != NULL) {
      ch = config_getn("fortune.so", "channels", rrand(n));
      irc_privmsg(ch, "%s", buf);
    }
    nexttalk = ts + min_delay + rrand(max_delay - min_delay);
  }
}
Exemplo n.º 4
0
int init() {
   int i;
   char *buf;
   
   helloinfo.last = 0;
   helloinfo.ntrigger = config_getcnt("hello.so", "trigger");
   helloinfo.nreply = config_getcnt("hello.so", "reply");

   if (!helloinfo.ntrigger || !helloinfo.ntrigger)
      return -1;
   
   if((helloinfo.trigger = malloc(helloinfo.ntrigger * sizeof(char*))) == NULL)
      return -1;
   
   if((helloinfo.reply = malloc(helloinfo.nreply * sizeof(char*))) == NULL) {
      free(helloinfo.trigger);
      return -1;
   }
   

   for(i = 0; i < helloinfo.ntrigger; i++) {
      helloinfo.trigger[i] = config_getn("hello.so", "trigger", i);
   }


   for(i = 0; i < helloinfo.nreply; i++) {
      helloinfo.reply[i] = config_getn("hello.so", "reply", i);
   }

   buf = config_getn("hello.so", "interval", 0);
   helloinfo.interval = buf? atoi(buf): 30;

   buf = config_getn("hello.so", "odds", 0);
   helloinfo.odds = buf? atoi(buf): 20;
   return 0;
}