1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
|
/* OperServ core functions
*
* (C) 2003-2011 Anope Team
* Contact us at team@anope.org
*
* Please read COPYING and README for further details.
*
* Based on the original code of Epona by Lara.
* Based on the original code of Services by Andy Church.
*/
/*************************************************************************/
#include "module.h"
class CommandOSChanList : public Command
{
public:
CommandOSChanList(Module *creator) : Command(creator, "operserv/chanlist", 0, 2)
{
this->SetDesc(_("Lists all channel records"));
this->SetSyntax(_("[{\037pattern\037 | \037nick\037} [\037SECRET\037]]"));
}
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms)
{
const Anope::string &pattern = !params.empty() ? params[0] : "";
const Anope::string &opt = params.size() > 1 ? params[1] : "";
std::list<ChannelModeName> Modes;
User *u2;
if (!opt.empty() && opt.equals_ci("SECRET"))
{
Modes.push_back(CMODE_SECRET);
Modes.push_back(CMODE_PRIVATE);
}
if (!pattern.empty() && (u2 = finduser(pattern)))
{
source.Reply(_("\002%s\002 channel list:\n"
"Name Users Modes Topic"), u2->nick.c_str());
for (UChannelList::iterator uit = u2->chans.begin(), uit_end = u2->chans.end(); uit != uit_end; ++uit)
{
ChannelContainer *cc = *uit;
if (!Modes.empty())
for (std::list<ChannelModeName>::iterator it = Modes.begin(), it_end = Modes.end(); it != it_end; ++it)
if (!cc->chan->HasMode(*it))
continue;
source.Reply(_("%-20s %4d +%-6s %s"), cc->chan->name.c_str(), cc->chan->users.size(), cc->chan->GetModes(true, true).c_str(), !cc->chan->topic.empty() ? cc->chan->topic.c_str() : "");
}
}
else
{
source.Reply(_("Channel list:\n"
"Name Users Modes Topic"));
for (channel_map::const_iterator cit = ChannelList.begin(), cit_end = ChannelList.end(); cit != cit_end; ++cit)
{
Channel *c = cit->second;
if (!pattern.empty() && !Anope::Match(c->name, pattern))
continue;
if (!Modes.empty())
for (std::list<ChannelModeName>::iterator it = Modes.begin(), it_end = Modes.end(); it != it_end; ++it)
if (!c->HasMode(*it))
continue;
source.Reply(_("%-20s %4d +%-6s %s"), c->name.c_str(), c->users.size(), c->GetModes(true, true).c_str(), !c->topic.empty() ? c->topic.c_str() : "");
}
}
source.Reply(_("End of channel list."));
return;
}
bool OnHelp(CommandSource &source, const Anope::string &subcommand)
{
this->SendSyntax(source);
source.Reply(" ");
source.Reply(_("Lists all channels currently in use on the IRC network, whether they\n"
"are registered or not.\n"
"If \002pattern\002 is given, lists only channels that match it. If a nickname\n"
"is given, lists only the channels the user using it is on. If SECRET is\n"
"specified, lists only channels matching \002pattern\002 that have the +s or\n"
"+p mode."));
return true;
}
};
class CommandOSUserList : public Command
{
public:
CommandOSUserList(Module *creator) : Command(creator, "operserv/userlist", 0, 2)
{
this->SetDesc(_("Lists all user records"));
this->SetSyntax(_("[{\037pattern\037 | \037channel\037} [\037INVISIBLE\037]]"));
}
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms)
{
const Anope::string &pattern = !params.empty() ? params[0] : "";
const Anope::string &opt = params.size() > 1 ? params[1] : "";
Channel *c;
std::list<UserModeName> Modes;
if (!opt.empty() && opt.equals_ci("INVISIBLE"))
Modes.push_back(UMODE_INVIS);
if (!pattern.empty() && (c = findchan(pattern)))
{
source.Reply(_("\002%s\002 users list:\n"
"Nick Mask"), pattern.c_str());
for (CUserList::iterator cuit = c->users.begin(), cuit_end = c->users.end(); cuit != cuit_end; ++cuit)
{
UserContainer *uc = *cuit;
if (!Modes.empty())
for (std::list<UserModeName>::iterator it = Modes.begin(), it_end = Modes.end(); it != it_end; ++it)
if (!uc->user->HasMode(*it))
continue;
source.Reply(_("%-20s %s@%s"), uc->user->nick.c_str(), uc->user->GetIdent().c_str(), uc->user->GetDisplayedHost().c_str());
}
}
else
{
source.Reply(_("Users list:\n"
"Nick Mask"));
for (Anope::insensitive_map<User *>::iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it)
{
User *u2 = it->second;
if (!pattern.empty())
{
Anope::string mask = u2->nick + "!" + u2->GetIdent() + "@" + u2->GetDisplayedHost();
if (!Anope::Match(mask, pattern))
continue;
if (!Modes.empty())
for (std::list<UserModeName>::iterator mit = Modes.begin(), mit_end = Modes.end(); mit != mit_end; ++mit)
if (!u2->HasMode(*mit))
continue;
}
source.Reply(_("%-20s %s@%s"), u2->nick.c_str(), u2->GetIdent().c_str(), u2->GetDisplayedHost().c_str());
}
}
source.Reply(_("End of users list."));
return;
}
bool OnHelp(CommandSource &source, const Anope::string &subcommand)
{
this->SendSyntax(source);
source.Reply(" ");
source.Reply(_("Lists all users currently online on the IRC network, whether their\n"
"nick is registered or not.\n"
" \n"
"If \002pattern\002 is given, lists only users that match it (it must be in\n"
"the format nick!user@host). If \002channel\002 is given, lists only users\n"
"that are on the given channel. If INVISIBLE is specified, only users\n"
"with the +i flag will be listed."));
return true;
}
};
class OSList : public Module
{
CommandOSChanList commandoschanlist;
CommandOSUserList commandosuserlist;
public:
OSList(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE),
commandoschanlist(this), commandosuserlist(this)
{
this->SetAuthor("Anope");
ModuleManager::RegisterService(&commandoschanlist);
ModuleManager::RegisterService(&commandosuserlist);
}
};
MODULE_INIT(OSList)
|