Skip to content

Commit 32ae692

Browse files
committed
chanfix updates
1 parent e3fec48 commit 32ae692

File tree

3 files changed

+91
-0
lines changed

3 files changed

+91
-0
lines changed

modules/third/ChanFix/chanfix.cpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,36 @@ class CommandChanFix final
3939
}
4040
};
4141

42+
class CommandCSChanFix final
43+
: public Command
44+
{
45+
ChanFixCore& cf;
46+
47+
public:
48+
CommandCSChanFix(Module* creator, ChanFixCore& core)
49+
: Command(creator, "chanserv/chanfix", 1, 1)
50+
, cf(core)
51+
{
52+
this->SetDesc("Request ChanFix for an unregistered channel.");
53+
this->SetSyntax("<#channel>");
54+
this->AllowUnregistered(true);
55+
}
56+
57+
void Execute(CommandSource& source, const std::vector<Anope::string>& params) override
58+
{
59+
cf.RequestFixFromChanServ(source, params[0]);
60+
}
61+
62+
bool OnHelp(CommandSource& source, const Anope::string&) override
63+
{
64+
source.Reply(" ");
65+
source.Reply("Requests a fix for an unregistered channel.");
66+
source.Reply("You must be opped in the channel or have chanfix/admin.");
67+
source.Reply("Example: CHANFIX #channel");
68+
return true;
69+
}
70+
};
71+
4272
class CommandChanFixScores final
4373
: public Command
4474
{
@@ -236,6 +266,7 @@ class ChanFix final
236266
ChanFixCore core;
237267

238268
CommandChanFix cmd_chanfix;
269+
CommandCSChanFix cmd_cs_chanfix;
239270
CommandChanFixScores cmd_scores;
240271
CommandChanFixInfo cmd_info;
241272
CommandChanFixList cmd_list;
@@ -269,6 +300,7 @@ class ChanFix final
269300
: Module(modname, creator, VENDOR)
270301
, core(this)
271302
, cmd_chanfix(this, core)
303+
, cmd_cs_chanfix(this, core)
272304
, cmd_scores(this, core)
273305
, cmd_info(this, core)
274306
, cmd_list(this, core)

modules/third/ChanFix/chanfix.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ class ChanFixCore final
6161
bool IsAuspex(CommandSource& source) const;
6262

6363
bool RequestFix(CommandSource& source, const Anope::string& chname);
64+
bool RequestFixFromChanServ(CommandSource& source, const Anope::string& chname);
6465
bool SetMark(CommandSource& source, const Anope::string& chname, bool on, const Anope::string& reason);
6566
bool SetNoFix(CommandSource& source, const Anope::string& chname, bool on, const Anope::string& reason);
6667

modules/third/ChanFix/chanfix_core.cpp

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -756,6 +756,64 @@ bool ChanFixCore::RequestFix(CommandSource& source, const Anope::string& chname)
756756
return true;
757757
}
758758

759+
bool ChanFixCore::RequestFixFromChanServ(CommandSource& source, const Anope::string& chname)
760+
{
761+
if (!IsValidChannelName(chname))
762+
{
763+
source.Reply("Invalid channel name.");
764+
return false;
765+
}
766+
767+
Channel* c = Channel::Find(chname);
768+
if (!c)
769+
{
770+
source.Reply("Channel %s does not exist.", chname.c_str());
771+
return false;
772+
}
773+
774+
if (this->IsRegistered(c))
775+
{
776+
source.Reply("%s is registered; ChanFix will not touch it.", chname.c_str());
777+
return false;
778+
}
779+
780+
if (!this->IsAdmin(source))
781+
{
782+
User* u = source.GetUser();
783+
if (!u)
784+
{
785+
source.Reply(ACCESS_DENIED);
786+
return false;
787+
}
788+
789+
ChanUserContainer* cuc = c->FindUser(u);
790+
if (!cuc || !cuc->status.HasMode(this->op_status_char))
791+
{
792+
source.Reply(ACCESS_DENIED);
793+
return false;
794+
}
795+
}
796+
797+
CFChannelRecord& rec = this->GetOrCreateRecord(c);
798+
if (rec.nofix)
799+
{
800+
source.Reply("%s has NOFIX enabled.", chname.c_str());
801+
return false;
802+
}
803+
804+
const unsigned int highscore = this->GetHighScore(rec);
805+
if (highscore < this->min_fix_score)
806+
{
807+
source.Reply("Scores for %s are too low (< %u) for a fix.", chname.c_str(), this->min_fix_score);
808+
return false;
809+
}
810+
811+
rec.fix_requested = true;
812+
rec.fix_started = 0;
813+
source.Reply("Fix request acknowledged for %s.", chname.c_str());
814+
return true;
815+
}
816+
759817
bool ChanFixCore::SetMark(CommandSource& source, const Anope::string& chname, bool on, const Anope::string& reason)
760818
{
761819
if (!this->IsAuspex(source))

0 commit comments

Comments
 (0)