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
|
/*
* Anope IRC Services
*
* Copyright (C) 2003-2017 Anope Team <team@anope.org>
*
* This file is part of Anope. Anope is free software; you can
* redistribute it and/or modify it under the terms of the GNU
* General Public License as published by the Free Software
* Foundation, version 2.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see see <http://www.gnu.org/licenses/>.
*/
#include "module.h"
class CommandBSSay : public Command
{
public:
CommandBSSay(Module *creator) : Command(creator, "botserv/say", 2, 2)
{
this->SetDesc(_("Makes the bot say the specified text on the specified channel"));
this->SetSyntax(_("\037channel\037 \037text\037"));
}
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override
{
const Anope::string &chan = params[0];
const Anope::string &text = params[1];
ChanServ::Channel *ci = ChanServ::Find(chan);
if (ci == NULL)
{
source.Reply(_("Channel \002{0}\002 isn't registered."), chan);
return;
}
if (!source.AccessFor(ci).HasPriv("SAY") && !source.HasOverridePriv("botserv/administration"))
{
source.Reply(_("Access denied. You do not have privilege \002{0}\002 on \002{1}\002."), "SAY", ci->GetName());
return;
}
if (!ci->GetBot())
{
source.Reply(_("There is no bot assigned to \002{0}\002. One must be assigned to the channel before this command can be used."), ci->GetName());
ServiceBot *bi;
Anope::string name;
Command::FindCommandFromService("botserv/assign", bi, name);
CommandInfo *help = source.service->FindCommand("generic/help");
if (bi && help)
source.Reply(_("See \002{msg}{service} {help} {command}\002 for information on assigning bots."),
"msg"_kw = Config->StrictPrivmsg, "service"_kw = bi->nick, "help"_kw = help->cname, "command"_kw = name);
return;
}
if (!ci->c || !ci->c->FindUser(ci->GetBot()))
{
source.Reply(_("Bot \002{0}\002 is not on channel \002{1}\002."), ci->GetBot()->nick, ci->GetName());
return;
}
if (text[0] == '\001')
{
this->OnSyntaxError(source, "");
return;
}
IRCD->SendPrivmsg(ci->GetBot(), ci->GetName(), text);
ci->GetBot()->lastmsg = Anope::CurTime;
logger.Command(source, ci, _("{source} used {command} on {channel} to say: {0}"), text);
}
bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
this->SendSyntax(source);
source.Reply(" ");
source.Reply(_("Makes the bot say the given \037text\037 on \037channel\037.\n"
"\n"
"Example:\n"
" {command} #anope mmm pie\n"
" Makes the assigned service bot say \"mmm pie\"."));
return true;
}
};
class CommandBSAct : public Command
{
public:
CommandBSAct(Module *creator) : Command(creator, "botserv/act", 2, 2)
{
this->SetDesc(_("Makes the bot do the equivalent of a \"/me\" command"));
this->SetSyntax(_("\037channel\037 \037text\037"));
}
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override
{
const Anope::string &chan = params[0];
Anope::string message = params[1];
ChanServ::Channel *ci = ChanServ::Find(chan);
if (ci == NULL)
{
source.Reply(_("Channel \002{0}\002 isn't registered."), chan);
return;
}
if (!source.AccessFor(ci).HasPriv("SAY") && !source.HasOverridePriv("botserv/administration"))
{
source.Reply(_("Access denied. You do not have privilege \002{0}\002 on \002{1}\002."), "SAY", ci->GetName());
return;
}
if (!ci->GetBot())
{
source.Reply(_("There is no bot assigned to \002{0}\002. One must be assigned to the channel before this command can be used."), ci->GetName());
ServiceBot *bi;
Anope::string name;
Command::FindCommandFromService("botserv/assign", bi, name);
CommandInfo *help = source.service->FindCommand("generic/help");
if (bi && help)
source.Reply(_("See \002{msg}{service} {help} {command}\002 for information on assigning bots."),
"msg"_kw = Config->StrictPrivmsg, "service"_kw = bi->nick, "help"_kw = help->cname, "command"_kw = name);
return;
}
if (!ci->c || !ci->c->FindUser(ci->GetBot()))
{
source.Reply(_("Bot \002{0}\002 is not on channel \002{1}\002."), ci->GetBot()->nick, ci->GetName());
return;
}
message = message.replace_all_cs("\1", "");
if (message.empty())
return;
IRCD->SendAction(ci->GetBot(), ci->GetName(), message);
ci->GetBot()->lastmsg = Anope::CurTime;
logger.Command(source, ci, _("{source} used {command} to say: {0}"), message);
}
bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
source.Reply(_("Makes the assigned bot do the equivalent of a \"/me\" command on \037channel\037 using the given \037text\037.\n"
"\n"
"Example:\n"
" {command} #anope slaps Cronus\n"
" Shows the assigned service bot \"slapping\" Cronus."),
"command"_kw = source.GetCommand());
return true;
}
};
class BSControl : public Module
{
CommandBSSay commandbssay;
CommandBSAct commandbsact;
public:
BSControl(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR)
, commandbssay(this), commandbsact(this)
{
}
};
MODULE_INIT(BSControl)
|