コード例 #1
0
ファイル: chanprog.c プロジェクト: x90/wraith
bool bot_shouldjoin(struct userrec* u, struct flag_record* fr, struct chanset_t* chan, bool ignore_inactive)
{
  // If restarting, keep this channel.
  if (restarting && (reset_chans == 2) && (channel_active(chan) || channel_pending(chan))) return 1;
  /* If the bot is restarting (and hasn't finished getting the userfile for the first time) DO NOT JOIN channels - breaks +B/+backup */
  if (restarting || loading) return 0;

  // No user record, can't make any safe assumptions really
  if (!u) return 0;

#ifdef DEBUG
  /* Force debugging bots to only join 3 channels */
  if (!strncmp(u->handle, "wtest", 5)) {
    if (!strcmp(chan->dname, "#skynet") || 
        !strcmp(chan->dname, "#bryan") || 
        !strcmp(chan->dname, "#wraith-devel"))
      return 1;
    else
      return 0;
  }
#endif
  // Ignore +inactive during cmd_slowjoin to ensure that +backup bots join
  return (!glob_kick(*fr) && !chan_kick(*fr) &&
      ((ignore_inactive || !channel_inactive(chan)) &&
       (channel_backup(chan) || (!glob_backup(*fr) && !chan_backup(*fr)))));
}
コード例 #2
0
ファイル: flags.c プロジェクト: Protospace/protobot
int flagrec_ok(struct flag_record *req, struct flag_record *have)
{
  /* FIXME: flag masks with '&' in them won't be subject to
   *        further tests below. Example: 'o&j'
   */
  if (req->match & FR_AND)
    return flagrec_eq(req, have);
  else if (req->match & FR_OR) {
    int hav = have->global;

    /* Exception 1 - global +d/+k cant use -|-, unless they are +p */
    if (!req->chan && !req->global && !req->udef_global && !req->udef_chan) {
      if (!allow_dk_cmds) {
        if (glob_party(*have))
          return 1;
        if (glob_kick(*have) || chan_kick(*have))
          return 0;             /* +k cant use -|- commands */
        if (glob_deop(*have) || chan_deop(*have))
          return 0;             /* neither can +d's */
      }
      return 1;
    }
    /* The +n/+m checks aren't needed anymore because +n/+m
     * automatically adds lower flags
     */
    if (!require_p && ((hav & USER_OP) || (have->chan & USER_OWNER)))
      hav |= USER_PARTY;
    if (hav & req->global)
      return 1;
    if (have->chan & req->chan)
      return 1;
    if (have->udef_global & req->udef_global)
      return 1;
    if (have->udef_chan & req->udef_chan)
      return 1;
    return 0;
  }
  return 0;                     /* fr0k3 binding, dont pass it */
}
コード例 #3
0
ファイル: flags.c プロジェクト: Estella/eggdrop-1.4
int flagrec_ok(struct flag_record *req,
	       struct flag_record *have)
{
  if (req->match & FR_AND) {
    return flagrec_eq(req, have);
  } else if (req->match & FR_OR) {
    int hav = have->global;

    /* exception 1 - global +d/+k cant use -|-, unless they are +p */
    if (!req->chan && !req->global && !req->udef_global &&
	!req->udef_chan) {
      if (!allow_dk_cmds) {
	if (glob_party(*have))
	  return 1;
	if (glob_kick(*have) || chan_kick(*have))
	  return 0;		/* +k cant use -|- commands */
	if (glob_deop(*have) || chan_deop(*have))
	  return 0;		/* neither can +d's */
      }
      return 1;
    }
    /* the +n/+m checks arent needed anymore since +n/+m
     * automatically add lower flags */
    if (!require_p && ((hav & USER_OP) || (have->chan & USER_OWNER)))
      hav |= USER_PARTY;
    if (hav & req->global)
      return 1;
    if (have->chan & req->chan)
      return 1;
    if (have->udef_global & req->udef_global)
      return 1;
    if (have->udef_chan & req->udef_chan)
      return 1;
    return 0;
  }
  return 0;			/* fr0k3 binding, dont pass it */
}