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
|
/* BotServ functions
*
* (C) 2003-2012 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 "services.h"
#include "modules.h"
BotInfo *findbot(const Anope::string &nick)
{
BotInfo *bi = NULL;
if (isdigit(nick[0]) && ircd->ts6)
{
Anope::map<BotInfo *>::iterator it = BotListByUID.find(nick);
if (it != BotListByUID.end())
bi = it->second;
}
else
{
Anope::insensitive_map<BotInfo *>::iterator it = BotListByNick.find(nick);
if (it != BotListByNick.end())
bi = it->second;
}
FOREACH_MOD(I_OnFindBot, OnFindBot(nick));
return bi;
}
/*************************************************************************/
/* Makes a simple ban and kicks the target
* @param requester The user requesting the kickban
* @param ci The channel
* @param u The user being kicked
* @param reason The reason
*/
void bot_raw_ban(User *requester, ChannelInfo *ci, User *u, const Anope::string &reason)
{
if (!u || !ci)
return;
if (ModeManager::FindUserModeByName(UMODE_PROTECTED) && u->IsProtected() && requester != u)
{
ircdproto->SendPrivmsg(ci->bi, ci->name, "%s", translate(requester, ACCESS_DENIED));
return;
}
AccessGroup u_access = ci->AccessFor(u), req_access = ci->AccessFor(requester);
if (ci->HasFlag(CI_PEACE) && u != requester && u_access >= req_access)
return;
if (matches_list(ci->c, u, CMODE_EXCEPT))
{
ircdproto->SendPrivmsg(ci->bi, ci->name, "%s", translate(requester, _("User matches channel except.")));
return;
}
Anope::string mask;
get_idealban(ci, u, mask);
ci->c->SetMode(NULL, CMODE_BAN, mask);
/* Check if we need to do a signkick or not -GD */
if (ci->HasFlag(CI_SIGNKICK) || (ci->HasFlag(CI_SIGNKICK_LEVEL) && !req_access.HasPriv("SIGNKICK")))
ci->c->Kick(ci->bi, u, "%s (%s)", !reason.empty() ? reason.c_str() : ci->bi->nick.c_str(), requester->nick.c_str());
else
ci->c->Kick(ci->bi, u, "%s", !reason.empty() ? reason.c_str() : ci->bi->nick.c_str());
}
/*************************************************************************/
/* Makes a kick with a "dynamic" reason ;)
* @param requester The user requesting the kick
* @param ci The channel
* @param u The user being kicked
* @param reason The reason for the kick
*/
void bot_raw_kick(User *requester, ChannelInfo *ci, User *u, const Anope::string &reason)
{
if (!u || !ci || !ci->c || !ci->c->FindUser(u))
return;
if (ModeManager::FindUserModeByName(UMODE_PROTECTED) && u->IsProtected() && requester != u)
{
ircdproto->SendPrivmsg(ci->bi, ci->name, "%s", translate(requester, ACCESS_DENIED));
return;
}
AccessGroup u_access = ci->AccessFor(u), req_access = ci->AccessFor(requester);
if (ci->HasFlag(CI_PEACE) && requester != u && u_access >= req_access)
return;
if (ci->HasFlag(CI_SIGNKICK) || (ci->HasFlag(CI_SIGNKICK_LEVEL) && !req_access.HasPriv("SIGNKICK")))
ci->c->Kick(ci->bi, u, "%s (%s)", !reason.empty() ? reason.c_str() : ci->bi->nick.c_str(), requester->nick.c_str());
else
ci->c->Kick(ci->bi, u, "%s", !reason.empty() ? reason.c_str() : ci->bi->nick.c_str());
}
|