Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cs_regmode: Set +r if a registered channel is being recreated #36

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ Responds to users that ping ChanServ with "Pong!".
#### cs_regmode.c

Sets the stupid, pointless DALNet-style +/-r mode when a channel
is registered or dropped. NOT RECOMMENDED TO USE.
is registered, recreated, or dropped. NOT RECOMMENDED TO USE.

#### cs_regnotice.c

Expand Down
16 changes: 15 additions & 1 deletion cs_regmode.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) 2011 William Pitcock <[email protected]>
* Rights to this code are as documented in doc/LICENSE.
*
* Set/unset DALnet channel mode +r on registration/deregistration.
* Set/unset DALnet channel mode +r on registration/recreation/deregistration.
*/

#include "atheme-compat.h"
Expand All @@ -24,6 +24,16 @@ static void register_hook(hook_channel_req_t *hdata)
modestack_mode_simple(chansvs.nick, mc->chan, MTYPE_ADD, CMODE_CHANREG);
}

static void add_hook(channel_t *c)
{
mychan_t *mc;

if (!(mc = mychan_find(c->name)))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't a channel_t have ->mychan?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, really not a fan of assignments inside if()...

return;

modestack_mode_simple(chansvs.nick, mc->chan, MTYPE_ADD, CMODE_CHANREG);
}

static void drop_hook(mychan_t *mc)
{
if (mc == NULL || mc->chan == NULL)
Expand All @@ -38,6 +48,9 @@ _modinit(module_t *m)
hook_add_event("channel_register");
hook_add_channel_register(register_hook);

hook_add_event("channel_add");
hook_add_channel_add(add_hook);

hook_add_event("channel_drop");
hook_add_channel_drop(drop_hook);
}
Expand All @@ -46,5 +59,6 @@ void
_moddeinit(module_unload_intent_t intent)
{
hook_del_channel_register(register_hook);
hook_del_channel_add(add_hook);
hook_del_channel_drop(drop_hook);
}