8000 ns_ajoin ADDALL Issue #363 - Added a basic function for ajoin addall by jnewing · Pull Request #379 · anope/anope · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

ns_ajoin ADDALL Issue #363 - Added a basic function for ajoin addall #379

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

Open
wants to merge 2 commits into
base: 2.0
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

< 8000 /div>
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 72 additions & 0 deletions modules/commands/ns_ajoin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,75 @@ class CommandNSAJoin : public Command
}
}

void DoAddAll(CommandSource &source, NickCore *nc)
{
AJoinList *channels = nc->Require<AJoinList>("ajoinlist");
Anope::string addedchans;
Anope::string alreadyadded;
Anope::string haskey;

User *u = source.GetUser();

int current_list_size = (*channels)->size();
int current_channel_count = u->chans.size();
int total = current_list_size + current_channel_count;

if (total >= static_cast<int>(Config->GetModule(this->owner)->Get<unsigned>("ajoinmax")))
{
source.Reply(_("Sorry, you're in too many channels. It would make your auto join list greater than the maximum of %d."), Config->GetModule(this->owner)->Get<unsigned>("ajoinmax"));
return;
}

for (User::ChanUserList::iterator it = u->chans.begin() ; it != u->chans.end() ; ++it)
{
Channel *chan = it->second->chan;

unsigned i = 0;
for (; i < (*channels)->size(); ++i)
if ((*channels)->at(i)->channel.equals_ci(chan->name))
break;

if (i != (*channels)->size())
{
alreadyadded += chan->name + ", ";
continue;
}

Anope::string k;
if (chan && chan->GetParam("KEY", k))
{
haskey += chan->name + ", ";
continue;
}

// we should be good to add channel here
AJoinEntry *entry = new AJoinEntry(nc);
entry->owner = nc;
entry->channel = chan->name;
(*channels)->push_back(entry);
addedchans += chan->name + ", ";
8000 }

if (!alreadyadded.empty())
{
alreadyadded = alreadyadded.substr(0, alreadyadded.length() - 2);
source.Reply(_("%s is already on %s's auto join list."), alreadyadded.c_str(), nc->display.c_str());
}

if (!haskey.empty())
{
haskey = haskey.substr(0, haskey.length() - 2);
source.Reply(_("%s had an invalid key specified, and was thus ignored."), haskey.c_str());
}

if (addedchans.empty())
return;

addedchans = addedchans.substr(0, addedchans.length() - 2);
Log(nc == source.GetAccount() ? LOG_COMMAND : LOG_ADMIN, source, this) << "to ADD channel " << addedchans << " to " << nc->display;
source.Reply(_("%s added to %s's auto join list."), addedchans.c_str(), nc->display.c_str());
}

void DoAdd(CommandSource &source, NickCore *nc, const Anope::string &chans, const Anope::string &keys)
{
AJoinList *channels = nc->Require<AJoinList>("ajoinlist");
Expand Down Expand Up @@ -228,6 +297,7 @@ class CommandNSAJoin : public Command
CommandNSAJoin(Module *creator) : Command(creator, "nickserv/ajoin", 1, 4)
{
this->SetDesc(_("Manage your auto join list"));
this->SetSyntax(_("ADDALL"));
this->SetSyntax(_("ADD [\037nickname\037] \037channel\037 [\037key\037]"));
this->SetSyntax(_("DEL [\037nickname\037] \037channel\037"));
this->SetSyntax(_("LIST [\037nickname\037]"));
Expand Down Expand Up @@ -273,6 +343,8 @@ class CommandNSAJoin : public Command
return this->DoList(source, nc);
else if (nc->HasExt("NS_SUSPENDED"))
source.Reply(NICK_X_SUSPENDED, nc->display.c_str());
else if (cmd.equals_ci("ADDALL"))
return this->DoAddAll(source, nc);
else if (param.empty())
this->OnSyntaxError(source, "");
else if (Anope::ReadOnly)
3B76 Expand Down
0