Skip to content

Commit 848ee6e

Browse files
authored
Merge pull request #74 from ValwareIRC/patch-12
helpop: Add JOIN notifications and autoop for help chan
2 parents a1e84d5 + 63ea641 commit 848ee6e

File tree

1 file changed

+42
-6
lines changed

1 file changed

+42
-6
lines changed

files/helpop.c

Lines changed: 42 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,20 +50,16 @@ CMD_FUNC(REPORT);
5050

5151
ModuleHeader MOD_HEADER = {
5252
"third/helpop", // Module name
53-
"1.3", // Module Version
53+
"1.4", // Module Version
5454
"HelpOp - Provides usermode h (HelpOp) and swhois line, channelmode g (HelpOp-only room), and command /HELPOPS", // Description
5555
"Valware", // Author
5656
"unrealircd-6", // Unreal Version
5757
};
5858

5959
int helpop_whois(Client *requester, Client *acptr, NameValuePrioList **list);
6060
int helponly_check (Client *client, Channel *channel, const char *key, char **errmsg);
61+
int helpchan_join_op_presence_check(Client *client, Channel *channel, MessageTag *mtags);
6162

62-
typedef struct {
63-
// Change this or add more variables, whatever suits you fam
64-
char flag;
65-
int p;
66-
} aModeX;
6763

6864
// Initialisation routine (register hooks, commands and modes or create structs etc)
6965
MOD_INIT() {
@@ -80,6 +76,8 @@ MOD_INIT() {
8076
CheckAPIError("CommandAdd(MSG_MYCMD)", CommandAdd(modinfo->handle, MSG_MYCMD, HELPOPS, 1, CMD_SERVER | CMD_USER));
8177

8278
HookAdd(modinfo->handle, HOOKTYPE_WHOIS, 0, helpop_whois);
79+
HookAdd(modinfo->handle, HOOKTYPE_LOCAL_JOIN, 0, helpchan_join_op_presence_check);
80+
HookAdd(modinfo->handle, HOOKTYPE_REMOTE_JOIN, 0, helpchan_join_op_presence_check);
8381

8482
MARK_AS_GLOBAL_MODULE(modinfo);
8583
return MOD_SUCCESS;
@@ -162,3 +160,41 @@ CMD_FUNC(HELPOPS) {
162160
sendto_umode_global(extumode_helpop,"(HelpOps) from %s: %s",client->name,parv[1]);
163161

164162
}
163+
164+
int helpchan_join_op_presence_check(Client *client, Channel *channel, MessageTag *mtags)
165+
{
166+
if (strcasecmp(channel->name,HELP_CHANNEL))
167+
return 0;
168+
169+
Member *member;
170+
int found = 0;
171+
for (member = channel->members; member; member = member->next)
172+
{
173+
Membership *mb = find_membership_link(member->client->user->channel, channel);
174+
175+
if (IsHelpop(member->client) && client == member->client && client->local)
176+
{
177+
MessageTag *mtags = NULL;
178+
179+
new_message(member->client, NULL, &mtags);
180+
sendto_channel(channel, &me, NULL, 0, 0, SEND_LOCAL, mtags,
181+
":%s MODE %s %s %s",
182+
me.name, channel->name, "+o", client->name);
183+
sendto_server(NULL, 0, 0, mtags, ":%s MODE %s %s %s%s", me.id, channel->name, "+o", client->name, IsServer(member->client)?" 0":"");
184+
free_message_tags(mtags);
185+
add_member_mode_fast(member, mb, 'o');
186+
found = 1;
187+
}
188+
if (check_channel_access(member->client, channel, "hoaq"))
189+
{
190+
191+
if (!IsULine(member->client))
192+
found = 1;
193+
}
194+
}
195+
if (!found) // found no op so let them helpops know
196+
{
197+
sendto_umode(extumode_helpop,"[%s] %s has joined the help channel and there are no ops on that channel.", HELP_CHANNEL, client->name);
198+
}
199+
return 0;
200+
}

0 commit comments

Comments
 (0)