This repository has been archived by the owner on Jun 24, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement the freenode.net/identify-msg vendor cap
- Loading branch information
Showing
7 changed files
with
102 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#include <stdinc.h> | ||
#include <modules.h> | ||
#include <msgbuf.h> | ||
|
||
static const char identify_msg_desc[] = "Provides the freenode.net/identify-msg client capability"; | ||
|
||
static void identmsg_outbound(void *); | ||
unsigned int CLICAP_IDENTIFY_MSG = 0; | ||
|
||
mapi_cap_list_av2 identmsg_cap_list[] = { | ||
{ MAPI_CAP_CLIENT, "freenode.net/identify-msg", NULL, &CLICAP_IDENTIFY_MSG }, | ||
{ 0, NULL, NULL, NULL } | ||
}; | ||
|
||
static mapi_hfn_list_av1 identmsg_hfnlist[] = { | ||
{ "outbound_msgbuf", identmsg_outbound }, | ||
{ NULL, NULL } | ||
}; | ||
|
||
static void identmsg_outbound(void *data_) | ||
{ | ||
hook_data *data = data_; | ||
struct MsgBuf *msgbuf = data->arg1; | ||
|
||
if (IsIdentified(data->client)) | ||
msgbuf_append_tag(msgbuf, "freenode.net/identified", NULL, CLICAP_IDENTIFY_MSG); | ||
} | ||
|
||
DECLARE_MODULE_AV2(identify_msg, NULL, NULL, NULL, NULL, identmsg_hfnlist, identmsg_cap_list, NULL, identify_msg_desc); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
#include <stdinc.h> | ||
#include <modules.h> | ||
#include <messages.h> | ||
#include <send.h> | ||
|
||
static const char identified_desc[] = "Provides the IDENTIFIED server-to-server command"; | ||
|
||
static void m_identified(struct MsgBuf *, struct Client *, struct Client *, int, const char *[]); | ||
|
||
static struct Message identified_msgtab = { | ||
"IDENTIFIED", 0, 0, 0, 0, | ||
{mg_ignore, mg_ignore, mg_ignore, mg_ignore, {m_identified, 3}, mg_ignore} | ||
}; | ||
|
||
static mapi_clist_av1 identified_clist[] = { | ||
&identified_msgtab, | ||
NULL | ||
}; | ||
|
||
static void identified_nick_change(void *); | ||
static void identified_burst_client(void *); | ||
|
||
static mapi_hfn_list_av1 identified_hfnlist[] = { | ||
{ "local_nick_change", identified_nick_change, HOOK_MONITOR }, | ||
{ "remote_nick_change", identified_nick_change, HOOK_MONITOR }, | ||
{ "burst_client", identified_burst_client }, | ||
{ NULL, NULL } | ||
}; | ||
|
||
static void m_identified(struct MsgBuf *msgbuf, struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) | ||
{ | ||
struct Client *target_p = find_person(parv[1]); | ||
const char *nick = parv[2]; | ||
|
||
if (target_p == NULL) | ||
return; | ||
|
||
if (irccmp(target_p->name, nick)) | ||
return; | ||
|
||
if (parc > 3 && irccmp(parv[3], "OFF") == 0) | ||
ClearIdentified(target_p); | ||
else | ||
SetIdentified(target_p); | ||
} | ||
|
||
static void identified_nick_change(void *data_) | ||
{ | ||
hook_cdata *data = data_; | ||
const char *oldnick = data->arg1, *newnick = data->arg2; | ||
|
||
if (irccmp(oldnick, newnick) != 0) | ||
ClearIdentified(data->client); | ||
} | ||
|
||
static void identified_burst_client(void *data_) | ||
{ | ||
hook_data_client *data = data_; | ||
|
||
if (IsIdentified(data->target)) | ||
sendto_one(data->client, ":%s ENCAP * IDENTIFIED %s :%s", me.id, use_id(data->target), data->target->name); | ||
} | ||
|
||
DECLARE_MODULE_AV2(identified, NULL, NULL, identified_clist, NULL, identified_hfnlist, NULL, NULL, identified_desc); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../../modules/core/.libs/m_identified.so |