Exemplo n.º 1
0
/* broadcast the signal forward */
static void botnet_event_broadcast(BOT_REC *bot, const char *data)
{
	char *params, *source, *target, *command;

	if (!bot->connected)
		return;

	params = cmd_get_params(data, 3 | PARAM_FLAG_GETREST,
				&source, &target, &command);

	if (g_strcasecmp(target, bot->botnet->nick) == 0) {
		/* message was for us */
		g_free(params);
		return;
	}

	if (*target == '-' && target[1] == '\0') {
		/* broadcast */
		botnet_broadcast(bot->botnet, bot, source, command);
	} else {
		/* send to specified target */
                botnet_send_cmd(bot->botnet, source, target, command);
	}

	g_free(params);
}
Exemplo n.º 2
0
void bot_remotecmd(int idx, char *par) {
  char *tbot = NULL, *fbot = NULL, *fhnd = NULL, *fidx = NULL;
 
  if (par[0])
    tbot = newsplit(&par);
  if (par[0])
    fbot = newsplit(&par);
  if (par[0])
    fhnd = newsplit(&par);
  if (par[0])
    fidx = newsplit(&par);

  /* Make sure the bot is valid */
  int i = nextbot(fbot);
  if (i != idx) {
    fake_alert(idx, "direction", fbot, "rc");
    return;
  }

  if (!strcasecmp(tbot, conf.bot->nick)) {
    gotremotecmd(tbot, fbot, fhnd, fidx, par);
  } else if (!strcmp(tbot, "*")) {
    botnet_send_cmd_broad(idx, fbot, fhnd, atoi(fidx), par);
    gotremotecmd(tbot, fbot, fhnd, fidx, par);
  } else {
    if (nextbot(tbot) != idx)
      botnet_send_cmd(fbot, tbot, fhnd, atoi(fidx), par);
  }
}