Skip to content

Commit

Permalink
Update modules for the latest v4 release.
Browse files Browse the repository at this point in the history
  • Loading branch information
SadieCat committed Mar 4, 2024
1 parent f3bace3 commit f80fc04
Show file tree
Hide file tree
Showing 11 changed files with 46 additions and 94 deletions.
4 changes: 2 additions & 2 deletions 4/m_asn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class ASNExtBan final
bool IsMatch(User* user, Channel* channel, const std::string& text) override
{
const std::string asnstr = ConvToStr(asnext.Get(user));
return stdalgo::string::equalsci(asnstr, text);
return insp::equalsci(asnstr, text);
}
};

Expand Down Expand Up @@ -203,7 +203,7 @@ class ModuleASN final
for (std::string token; asnstream.GetToken(token); )
{
// If the user matches this ASN then they can use this connect class.
if (stdalgo::string::equalsci(asnstr, token))
if (insp::equalsci(asnstr, token))
return MOD_RES_PASSTHRU;
}

Expand Down
18 changes: 8 additions & 10 deletions 4/m_autoaway.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,23 +76,23 @@ class ModuleAutoAway final
continue;

autoaway.Set(user);
user->awaytime = ServerInstance->Time();
user->awaymsg.assign(message, 0, ServerInstance->Config->Limits.MaxAway);
const auto prevstate = user->away;
user->away.emplace(message);
user->WriteNumeric(RPL_NOWAWAY, "You have been automatically marked as being away");
awayevprov.Call(&Away::EventListener::OnUserAway, user);
awayevprov.Call(&Away::EventListener::OnUserAway, user, prevstate);
}
setting = false;
return true;
}

void OnUserAway(User* user) override
void OnUserAway(User* user, const std::optional<AwayState>& prevstate) override
{
// If the user is changing their away status then unmark them.
if (IS_LOCAL(user) && !setting)
autoaway.Unset(user);
}

void OnUserBack(User* user, const std::string& awaymessage) override
void OnUserBack(User* user, const std::optional<AwayState>& prevstate) override
{
// If the user is unsetting their away status then unmark them.
if (IS_LOCAL(user))
Expand All @@ -104,13 +104,11 @@ class ModuleAutoAway final
if (!IS_LOCAL(user) || !autoaway.Get(user))
return;


const std::string awaymsg = user->awaymsg;
const auto prevstate = user->away;
autoaway.Unset(user);
user->awaytime = 0;
user->awaymsg.clear();
user->away.reset();
user->WriteNumeric(RPL_UNAWAY, "You are no longer automatically marked as being away");
awayevprov.Call(&Away::EventListener::OnUserBack, user, awaymsg);
awayevprov.Call(&Away::EventListener::OnUserBack, user, prevstate);
}
};

Expand Down
2 changes: 1 addition & 1 deletion 4/m_customtags.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ class ModuleCustomTags final
ModResult OnWhoLine(const Who::Request& request, LocalUser* source, User* user, Membership* memb, Numeric::Numeric& numeric) override
{
size_t nick_index;
ctags.whox_index = request.GetFieldIndex('n', nick_index) ? nick_index : -1;
ctags.whox_index = request.GetFieldIndex('n', nick_index) ? static_cast<int>(nick_index) : -1;
return MOD_RES_PASSTHRU;
}

Expand Down
12 changes: 7 additions & 5 deletions 4/m_eventexec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@

#include "inspircd.h"
#include "modules/server.h"
#include "stringutils.h"
#include "utility/string.h"

enum EventType
{
Expand Down Expand Up @@ -108,15 +110,15 @@ class ModuleEventExec final

// Ensure that the <eventexec:event> value is well formed.
EventType event;
if (stdalgo::string::equalsci(eventstr, "startup"))
if (insp::equalsci(eventstr, "startup"))
event = ET_STARTUP;
else if (stdalgo::string::equalsci(eventstr, "shutdown"))
else if (insp::equalsci(eventstr, "shutdown"))
event = ET_SHUTDOWN;
else if (stdalgo::string::equalsci(eventstr, "rehash"))
else if (insp::equalsci(eventstr, "rehash"))
event = ET_REHASH;
else if (stdalgo::string::equalsci(eventstr, "link"))
else if (insp::equalsci(eventstr, "link"))
event = ET_SERVER_LINK;
else if (stdalgo::string::equalsci(eventstr, "unlink"))
else if (insp::equalsci(eventstr, "unlink"))
event = ET_SERVER_UNLINK;
else
throw ModuleException(this, "<eventexec:event> contains an unrecognised event '" + eventstr + "', at " + tag->source.str());
Expand Down
12 changes: 6 additions & 6 deletions 4/m_hostchange.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@

#include "inspircd.h"
#include "modules/account.h"
#include "utility/string.h"

// Holds information about a <hostchange> rule.
class HostRule final
Expand Down Expand Up @@ -108,7 +109,7 @@ class HostRule final

bool Matches(LocalUser* user) const
{
if (!klass.empty() && !stdalgo::string::equalsci(klass, user->GetClass()->GetName()))
if (!klass.empty() && !insp::equalsci(klass, user->GetClass()->GetName()))
return false;

if (!ports.empty() && !ports.count(user->server_sa.port()))
Expand Down Expand Up @@ -174,17 +175,17 @@ class ModuleHostChange final

// Determine what type of host rule this is.
const std::string action = tag->getString("action");
if (stdalgo::string::equalsci(action, "addaccount"))
if (insp::equalsci(action, "addaccount"))
{
// The hostname is in the format [prefix]<account>[suffix].
rules.emplace_back(tag, HostRule::HostChangeAction::ADD_ACCOUNT, mask, tag->getString("prefix"), tag->getString("suffix"));
}
else if (stdalgo::string::equalsci(action, "addnick"))
else if (insp::equalsci(action, "addnick"))
{
// The hostname is in the format [prefix]<nick>[suffix].
rules.emplace_back(tag, HostRule::HostChangeAction::ADD_NICK, mask, tag->getString("prefix"), tag->getString("suffix"));
}
else if (stdalgo::string::equalsci(action, "set"))
else if (insp::equalsci(action, "set"))
{
// Ensure that we have the <hostchange:value> parameter.
const std::string value = tag->getString("value");
Expand Down Expand Up @@ -257,8 +258,7 @@ class ModuleHostChange final
if (!newhost.empty())
{
user->WriteNotice("Setting your virtual host: " + newhost);
if (!user->ChangeDisplayedHost(newhost))
user->WriteNotice("Could not set your virtual host: " + newhost);
user->ChangeDisplayedHost(newhost);
return;
}
}
Expand Down
51 changes: 0 additions & 51 deletions 4/m_identmeta.cpp

This file was deleted.

2 changes: 1 addition & 1 deletion 4/m_messagelength.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class ModuleMessageLength final
if (!channel->IsModeSet(&mode))
return MOD_RES_PASSTHRU;

unsigned int msglength = mode.ext.Get(channel);
size_t msglength = (size_t)mode.ext.Get(channel);
if (details.text.length() > msglength)
details.text.resize(msglength);

Expand Down
3 changes: 2 additions & 1 deletion 4/m_messagesocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@


#include "inspircd.h"
#include "utility/string.h"

class MessageSocket;

Expand Down Expand Up @@ -103,7 +104,7 @@ class ModuleMessageSocket final

ModResult OnAcceptConnection(int nfd, ListenSocket* from, const irc::sockets::sockaddrs& client, const irc::sockets::sockaddrs& server) override
{
if (!stdalgo::string::equalsci(from->bind_tag->getString("type"), "message"))
if (!insp::equalsci(from->bind_tag->getString("type"), "message"))
return MOD_RES_PASSTHRU;

sockets.push_front(new MessageSocket(nfd));
Expand Down
30 changes: 16 additions & 14 deletions 4/m_qrcode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
#include "clientprotocolmsg.h"
#include "modules/ssl.h"
#include "numerichelper.h"
#include "stringutils.h"
#include "utility/string.h"

class QRCode final
{
Expand Down Expand Up @@ -212,46 +214,46 @@ class ModuleQRCode final
std::string name = tag->getString(key, def);
std::transform(name.begin(), name.end(), name.begin(), ::tolower);

if (stdalgo::string::equalsci(name, "white"))
if (insp::equalsci(name, "white"))
return "0";

if (stdalgo::string::equalsci(name, "black"))
if (insp::equalsci(name, "black"))
return "1";

if (stdalgo::string::equalsci(name, "blue"))
if (insp::equalsci(name, "blue"))
return "2";

if (stdalgo::string::equalsci(name, "green"))
if (insp::equalsci(name, "green"))
return "3";

if (stdalgo::string::equalsci(name, "red"))
if (insp::equalsci(name, "red"))
return "4";

if (stdalgo::string::equalsci(name, "brown"))
if (insp::equalsci(name, "brown"))
return "5";

if (stdalgo::string::equalsci(name, "purple"))
if (insp::equalsci(name, "purple"))
return "6";

if (stdalgo::string::equalsci(name, "orange"))
if (insp::equalsci(name, "orange"))
return "7";

if (stdalgo::string::equalsci(name, "yellow"))
if (insp::equalsci(name, "yellow"))
return "8";

if (stdalgo::string::equalsci(name, "lightgreen"))
if (insp::equalsci(name, "lightgreen"))
return "9";

if (stdalgo::string::equalsci(name, "cyan"))
if (insp::equalsci(name, "cyan"))
return "10";

if (stdalgo::string::equalsci(name, "lightcyan"))
if (insp::equalsci(name, "lightcyan"))
return "11";

if (stdalgo::string::equalsci(name, "lightblue"))
if (insp::equalsci(name, "lightblue"))
return "12";

if (stdalgo::string::equalsci(name, "pink"))
if (insp::equalsci(name, "pink"))
return "13";

if (name == "gray" || name == "grey")
Expand Down
4 changes: 2 additions & 2 deletions 4/m_solvemsg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@

struct Problem final
{
int first;
int second;
unsigned long first;
unsigned long second;
time_t nextwarning;
};

Expand Down
2 changes: 1 addition & 1 deletion 4/m_teams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ class ModuleTeams final
TeamList* teams = ext.Get(whois.GetTarget());
if (teams)
{
const std::string teamstr = stdalgo::string::join(*teams);
const std::string teamstr = insp::join(*teams);
whois.SendLine(RPL_WHOISTEAMS, teamstr, "is a member of these teams");
}
}
Expand Down

0 comments on commit f80fc04

Please sign in to comment.