Bring up updated roleplay module from charybdis.

This commit is contained in:
B.Greenham 2010-12-11 16:28:40 -05:00
parent 5323ec7352
commit a26bd77404
3 changed files with 60 additions and 58 deletions

View File

@ -1,3 +1,19 @@
/*
* roleplay commands for charybdis.
*
* adds NPC, NPCA, and SCENE which allow users to send messages from 'fake'
* nicknames. in the case of NPC and NPCA, the nickname will be underlined
* to clearly show that it is fake. SCENE is a special case and not underlined.
* these commands only work on channels set +N
*
* also adds oper commands FSAY and FACTION, which are like NPC and NPCA
* except without the underline.
*
* all of these messages have the hostmask npc.fakeuser.invalid, and their ident
* is the nickname of the user running the commands.
*/
#include "stdinc.h" #include "stdinc.h"
#include "ircd.h" #include "ircd.h"
#include "client.h" #include "client.h"
@ -8,6 +24,8 @@
#include "s_serv.h" #include "s_serv.h"
#include "inline/stringops.h" #include "inline/stringops.h"
#include "chmode.h" #include "chmode.h"
#include "tgchange.h"
#include "channel.h"
static int m_scene(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]); static int m_scene(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]);
static int m_fsay(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]); static int m_fsay(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]);
@ -21,12 +39,8 @@ static unsigned int mymode;
static int static int
_modinit(void) _modinit(void)
{ {
/* initalize the +x and +d cmodes */ /* initalize the +N cmode */
mymode = cflag_add('x', chm_simple); mymode = cflag_add('N', chm_simple);
if (mymode == 0)
return -1;
mymode = cflag_add('d', chm_simple);
if (mymode == 0) if (mymode == 0)
return -1; return -1;
@ -36,10 +50,8 @@ _modinit(void)
static void static void
_moddeinit(void) _moddeinit(void)
{ {
/* orphan the +x and +d cmodes on modunload */ /* orphan the +N cmode on modunload */
cflag_orphan('x'); cflag_orphan('N');
cflag_orphan('d');
} }
@ -48,6 +60,7 @@ struct Message scene_msgtab = {
{mg_unreg, {m_scene, 3}, mg_ignore, mg_ignore, mg_ignore, {m_scene, 3}} {mg_unreg, {m_scene, 3}, mg_ignore, mg_ignore, mg_ignore, {m_scene, 3}}
}; };
/* this serves as an alias for people who are used to inspircd/unreal m_roleplay */
struct Message ambiance_msgtab = { struct Message ambiance_msgtab = {
"AMBIANCE", 0, 0, 0, MFLG_SLOW, "AMBIANCE", 0, 0, 0, MFLG_SLOW,
{mg_unreg, {m_scene, 3}, mg_ignore, mg_ignore, mg_ignore, {m_scene, 3}} {mg_unreg, {m_scene, 3}, mg_ignore, mg_ignore, mg_ignore, {m_scene, 3}}
@ -75,12 +88,12 @@ struct Message npca_msgtab = {
struct Message roleplay_msgtab = { struct Message roleplay_msgtab = {
"ROLEPLAY", 0, 0, 0, MFLG_SLOW, "ROLEPLAY", 0, 0, 0, MFLG_SLOW,
{mg_ignore, mg_ignore, mg_ignore, mg_ignore, {me_roleplay, 5}, mg_ignore} {mg_ignore, mg_ignore, mg_ignore, mg_ignore, {me_roleplay, 4}, mg_ignore}
}; };
mapi_clist_av1 roleplay_clist[] = { &scene_msgtab, &ambiance_msgtab, &fsay_msgtab, &faction_msgtab, &npc_msgtab, &npca_msgtab, &roleplay_msgtab, NULL }; mapi_clist_av1 roleplay_clist[] = { &scene_msgtab, &ambiance_msgtab, &fsay_msgtab, &faction_msgtab, &npc_msgtab, &npca_msgtab, &roleplay_msgtab, NULL };
DECLARE_MODULE_AV1(roleplay, _modinit, _moddeinit, roleplay_clist, NULL, NULL, "$m_roleplay 1.0 - Taros $"); DECLARE_MODULE_AV1(roleplay, _modinit, _moddeinit, roleplay_clist, NULL, NULL, "$m_roleplay$");
static int static int
m_scene(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) m_scene(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
@ -122,7 +135,7 @@ m_displaymsg(struct Client *source_p, const char *channel, int underline, int ac
{ {
struct Channel *chptr; struct Channel *chptr;
struct membership *msptr; struct membership *msptr;
char nick2[109]; char nick2[NICKLEN+1];
char *nick3 = rb_strdup(nick); char *nick3 = rb_strdup(nick);
char text2[BUFSIZE]; char text2[BUFSIZE];
@ -139,29 +152,28 @@ m_displaymsg(struct Client *source_p, const char *channel, int underline, int ac
return 0; return 0;
} }
if(chptr->mode.mode & chmode_flags['d']) if(!(chptr->mode.mode & chmode_flags['E']))
{ {
sendto_one_numeric(source_p, 573, "%s :Roleplay commands are disabled on this channel (+d)", chptr->chname); sendto_one_numeric(source_p, 573, "%s :Roleplay commands are not enabled on this channel.", chptr->chname);
return 0; return 0;
} }
if(!IsOper(source_p) || chptr->mode.mode & chmode_flags['x']) if(!can_send(chptr, source_p, msptr))
{ {
if(chptr->mode.mode & chmode_flags['x']) sendto_one_numeric(source_p, 573, "%s :Cannot send to channel.", chptr->chname);
{ return 0;
if(!is_chanop_voiced(msptr)) }
{
sendto_one(source_p, ":%s 482 %s %s :You are not a channel operator or voice, and thus cannot use roleplay commands on this channel.", /* enforce flood stuff on roleplay commands */
me.name, source_p->name, chptr->chname); if(flood_attack_channel(0, source_p, chptr, chptr->chname))
return 0; return 0;
}
} /* enforce target change on roleplay commands */
else if(!is_any_op(msptr)) if(!is_chanop_voiced(msptr) && !IsOper(source_p) && !add_channel_target(source_p, chptr))
{ {
sendto_one(source_p, ":%s 482 %s %s :You are not a channel operator, and thus cannot use roleplay commands on this channel.", sendto_one(source_p, form_str(ERR_TARGCHANGE),
me.name, source_p->name, chptr->chname); me.name, source_p->name, chptr->chname);
return 0; return 0;
}
} }
if(underline) if(underline)
@ -169,6 +181,8 @@ m_displaymsg(struct Client *source_p, const char *channel, int underline, int ac
else else
rb_snprintf(nick2, sizeof(nick2), "%s", strip_unprintable(nick3)); rb_snprintf(nick2, sizeof(nick2), "%s", strip_unprintable(nick3));
/* don't allow nicks to be empty after stripping
* this prevents nastiness like fake factions, etc. */
if(EmptyString(nick3)) if(EmptyString(nick3))
{ {
sendto_one_numeric(source_p, 573, "%s :No visible non-stripped characters in nick.", chptr->chname); sendto_one_numeric(source_p, 573, "%s :No visible non-stripped characters in nick.", chptr->chname);
@ -181,8 +195,8 @@ m_displaymsg(struct Client *source_p, const char *channel, int underline, int ac
rb_snprintf(text2, sizeof(text2), "%s", text); rb_snprintf(text2, sizeof(text2), "%s", text);
sendto_channel_local(ALL_MEMBERS, chptr, ":%s!%s@npc.fakeuser.invalid PRIVMSG %s :%s", nick2, source_p->name, channel, text2); sendto_channel_local(ALL_MEMBERS, chptr, ":%s!%s@npc.fakeuser.invalid PRIVMSG %s :%s", nick2, source_p->name, channel, text2);
sendto_match_servs(&me, "*", CAP_ENCAP, NOCAPS, "ENCAP * ROLEPLAY %s %s %s :%s", sendto_match_servs(source_p, "*", CAP_ENCAP, NOCAPS, "ENCAP * ROLEPLAY %s %s :%s",
source_p->name, channel, nick2, text2); channel, nick2, text2);
return 0; return 0;
} }
@ -191,11 +205,11 @@ me_roleplay(struct Client *client_p, struct Client *source_p, int parc, const ch
{ {
struct Channel *chptr; struct Channel *chptr;
/* Don't segfault if we get ENCAP * ROLEPLAY with an invalid channel. /* Don't segfault if we get ROLEPLAY with an invalid channel.
* This shouldn't happen but it's best to be on the safe side. */ * This shouldn't happen but it's best to be on the safe side. */
if((chptr = find_channel(parv[2])) == NULL) if((chptr = find_channel(parv[1])) == NULL)
return 0; return 0;
sendto_channel_local(ALL_MEMBERS, chptr, ":%s!%s@npc.fakeuser.invalid PRIVMSG %s :%s", parv[3], parv[1], parv[2], parv[4]); sendto_channel_local(ALL_MEMBERS, chptr, ":%s!%s@npc.fakeuser.invalid PRIVMSG %s :%s", parv[2], source_p->name, parv[1], parv[3]);
return 0; return 0;
} }

View File

@ -3,21 +3,15 @@ all of which send messages to channel under 'fake'
nicknames. The user of the command can be identified nicknames. The user of the command can be identified
by looking at the ident of the 'fake' user - it will by looking at the ident of the 'fake' user - it will
always be the nickname of the person using the command, always be the nickname of the person using the command,
and the host will always be npc.fakeuser.invalid. and the host will always be npc.fakeuser.invalid. These
commands require the target channel to be set +E, and
These commands normally require chanops to run, unless obey the same restrictions as regular PRIVMSG.
cmode +x is on the channel in question, in which case
any user that is voiced or above can run any roleplay
command. Cmode +d will prevent any roleplay command
being ran on the channel in question.
Roleplay commands from normal users have the nick Roleplay commands from normal users have the nick
underlined, to clearly show that the message is a underlined, to clearly show that the message is a
roleplay message rather than a normal one (with one roleplay message rather than a normal one (with one
exception). Network operators are not subject to this exception). Network operators are not subject to this
restriction. Network operators can also use these restriction.
commands in any channel they are in, without requiring
ops.
NPC <nick> <channel> :message NPC <nick> <channel> :message
Sends a standard roleplay message to #channel with the Sends a standard roleplay message to #channel with the

View File

@ -3,21 +3,15 @@ all of which send messages to channel under 'fake'
nicknames. The user of the command can be identified nicknames. The user of the command can be identified
by looking at the ident of the 'fake' user - it will by looking at the ident of the 'fake' user - it will
always be the nickname of the person using the command, always be the nickname of the person using the command,
and the host will always be npc.fakeuser.invalid. and the host will always be npc.fakeuser.invalid. These
commands require the target channel to be set +E, and
These commands normally require chanops to run, unless obey the same restrictions as regular PRIVMSG.
cmode +x is on the channel in question, in which case
any user that is voiced or above can run any roleplay
command. Cmode +d will prevent any roleplay command
being ran on the channel in question.
Roleplay commands from normal users have the nick Roleplay commands from normal users have the nick
underlined, to clearly show that the message is a underlined, to clearly show that the message is a
roleplay message rather than a normal one (with one roleplay message rather than a normal one (with one
exception). Network operators are not subject to this exception). Network operators are not subject to this
restriction. Network operators can also use these restriction.
commands in any channel they are in, without requiring
ops.
NPC <nick> <channel> :message NPC <nick> <channel> :message
Sends a standard roleplay message to #channel with the Sends a standard roleplay message to #channel with the