blob: 4456ce37ce4546e46fb8877166da55b40845d616 (
plain)
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
|
/* ChanServ 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 "anope.h"
#include "regchannel.h"
#include "users.h"
#include "channels.h"
#include "access.h"
#include "account.h"
ChannelInfo* cs_findchan(const Anope::string &chan)
{
registered_channel_map::const_iterator it = RegisteredChannelList->find(chan);
if (it != RegisteredChannelList->end())
{
it->second->QueueUpdate();
return it->second;
}
return NULL;
}
/*************************************************************************/
/** Is the user the real founder?
* @param user The user
* @param ci The channel
* @return true or false
*/
bool IsFounder(const User *user, const ChannelInfo *ci)
{
if (!user || !ci)
return false;
if (user->SuperAdmin)
return true;
if (user->Account() && user->Account() == ci->GetFounder())
return true;
return false;
}
/*************************************************************************/
void update_cs_lastseen(User *user, ChannelInfo *ci)
{
if (!ci || !user)
return;
AccessGroup u_access = ci->AccessFor(user);
for (unsigned i = u_access.size(); i > 0; --i)
u_access[i - 1]->last_seen = Anope::CurTime;
}
/*************************************************************************/
/* Returns the best ban possible for a user depending of the bantype
value. */
int get_idealban(const ChannelInfo *ci, User *u, Anope::string &ret)
{
Anope::string mask;
if (!ci || !u)
return 0;
Anope::string vident = u->GetIdent();
switch (ci->bantype)
{
case 0:
ret = "*!" + vident + "@" + u->GetDisplayedHost();
return 1;
case 1:
if (vident[0] == '~')
ret = "*!*" + vident + "@" + u->GetDisplayedHost();
else
ret = "*!" + vident + "@" + u->GetDisplayedHost();
return 1;
case 2:
ret = "*!*@" + u->GetDisplayedHost();
return 1;
case 3:
mask = create_mask(u);
ret = "*!" + mask;
return 1;
default:
return 0;
}
}
|