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

[2.0] Fix not being able to message ulines when m_restrictmsg is loaded. #1039

Merged
merged 1 commit into from May 10, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions docs/conf/modules.conf.example
Expand Up @@ -1486,6 +1486,9 @@
# You probably *DO NOT* want to load this module on a public network.
#
#<module name="m_restrictmsg.so">
#
# Uncomment this to allow users to message ulines (e.g. services):
#<restrictmsg uline="yes">

#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#
# R-Line module: Ban users through regular expression patterns.
Expand Down
12 changes: 10 additions & 2 deletions src/modules/m_restrictmsg.cpp
Expand Up @@ -26,15 +26,22 @@

class ModuleRestrictMsg : public Module
{
private:
bool uline;

public:

void init()
{
Implementation eventlist[] = { I_OnUserPreMessage, I_OnUserPreNotice };
OnRehash(NULL);
Implementation eventlist[] = { I_OnRehash, I_OnUserPreMessage, I_OnUserPreNotice };
ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation));
}

void OnRehash(User*)
{
uline = ServerInstance->Config->ConfValue("restrictmsg")->getBool("uline", false);
}

virtual ModResult OnUserPreMessage(User* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list)
{
Expand All @@ -45,8 +52,9 @@ class ModuleRestrictMsg : public Module
// message allowed if:
// (1) the sender is opered
// (2) the recipient is opered
// (3) the recipient is on a ulined server
// anything else, blocked.
if (IS_OPER(u) || IS_OPER(user))
if (IS_OPER(u) || IS_OPER(user) || (uline && ServerInstance->ULine(u->server)))
{
return MOD_RES_PASSTHRU;
}
Expand Down