]> jfr.im git - solanum.git/blobdiff - extensions/override.c
override: Send notice when overriding can_send.
[solanum.git] / extensions / override.c
index 3380c3c5d4ccaa9b825eaa0b4de9301fb6d9b331..bd31590dde4c1aa05d649583929742d280362926 100644 (file)
@@ -26,12 +26,14 @@ static void check_umode_change(void *data);
 static void hack_channel_access(void *data);
 static void hack_can_join(void *data);
 static void hack_can_send(void *data);
+static void handle_client_exit(void *data);
 
 mapi_hfn_list_av1 override_hfnlist[] = {
        { "umode_changed", (hookfn) check_umode_change },
        { "get_channel_access", (hookfn) hack_channel_access },
        { "can_join", (hookfn) hack_can_join },
        { "can_send", (hookfn) hack_can_send },
+       { "client_exit", (hookfn) handle_client_exit },
        { NULL, NULL }
 };
 
@@ -111,6 +113,7 @@ check_umode_change(void *vdata)
 
        if (!IsOperOverride(source_p))
        {
+               sendto_one_notice(source_p, ":*** You need oper:override privilege for +p");
                source_p->umodes &= ~user_modes['p'];
                return;
        }
@@ -188,16 +191,36 @@ hack_can_send(void *vdata)
 
        if (data->client->umodes & user_modes['p'])
        {
-               update_session_deadline(data->client, NULL);
-               data->approved = CAN_SEND_OPV;
+               data->approved = CAN_SEND_NONOP;
 
-#ifdef XXX_UNSURE_IF_WANT
-               sendto_realops_snomask(SNO_GENERAL, L_NETWIDE, "%s is using oper-override on %s (banwalking)",
-                                      get_oper_name(data->client), data->chptr->chname);
-#endif
+               if (MyClient(data->client))
+               {
+                       update_session_deadline(data->client, NULL);
+                       sendto_realops_snomask(SNO_GENERAL, L_NETWIDE, "%s is using oper-override on %s (forcing message)",
+                                              get_oper_name(data->client), data->chptr->chname);
+               }
        }
 }
 
+static void
+handle_client_exit(void *vdata)
+{
+       hook_data_client_exit *data = (hook_data_client_exit *) vdata;
+       rb_dlink_node *n, *tn;
+       struct Client *source_p = data->target;
+
+       RB_DLINK_FOREACH_SAFE(n, tn, overriding_opers.head)
+       {
+               struct OverrideSession *session_p = n->data;
+
+               if (session_p->client != source_p)
+                       continue;
+
+               rb_dlinkDelete(n, &overriding_opers);
+               rb_free(session_p);
+       }       
+}
+
 struct ev_entry *expire_override_deadlines_ev = NULL;
 
 static int