/* ircd allows forwards to existing channels; the target channel must be * +F or the setter must have ops in it */ static bool check_forward(const char *value, channel_t *c, mychan_t *mc, user_t *u, myuser_t *mu) { channel_t *target_c; mychan_t *target_mc; chanuser_t *target_cu; if (!VALID_GLOBAL_CHANNEL_PFX(value) || strlen(value) > 50) return false; if (u == NULL && mu == NULL) return true; target_c = channel_find(value); target_mc = mychan_from(target_c); if (target_c == NULL && target_mc == NULL) return false; if (target_c != NULL && target_c->modes & CMODE_FTARGET) return true; if (target_mc != NULL && target_mc->mlock_on & CMODE_FTARGET) return true; if (u != NULL) { target_cu = chanuser_find(target_c, u); if (target_cu != NULL && target_cu->modes & CSTATUS_OP) return true; if (chanacs_user_flags(target_mc, u) & CA_SET) return true; } else if (mu != NULL) if (chanacs_entity_has_flag(target_mc, entity(mu), CA_SET)) return true; return false; }
static void on_channel_mode(hook_channel_mode_t *data) { mychan_t *mc; return_if_fail(data != NULL); return_if_fail(data->c != NULL); mc = mychan_from(data->c); if (mc == NULL || mc->flags & MC_NOSYNC) return; if (do_channel_sync != NULL) do_channel_sync(mc, NULL); }
static void on_channel_message(hook_cmessage_data_t *data) { if (data != NULL && data->msg != NULL) { mychan_t *mc = mychan_from(data->c); metadata_t *md; if (!mc) return; if (!metadata_find(mc, "babbler:enable")) return; if (!(md = metadata_find(mc, "babbler:nicks"))) return; if (strstr(md->value, data->u->nick)) { char *source = NULL; char *target; if (!(md = metadata_find(mc, "babbler:target"))) return; target = md->value; if (!(md = metadata_find(mc, "babbler:source"))) source = chansvs.nick; else source = md->value; msg(source, data->c->name, "%s: <%s> %s", target, data->u->nick, data->msg); } } }