2
* Copyright (C) 2008-2011 See the AUTHORS file for details.
4
* This program is free software; you can redistribute it and/or modify it
5
* under the terms of the GNU General Public License version 2 as published
6
* by the Free Software Foundation.
12
class CFOModule : public CModule {
14
MODCONSTRUCTOR(CFOModule) {}
15
virtual ~CFOModule() {}
17
bool IsOnlineModNick(const CString& sNick) {
18
const CString& sPrefix = m_pUser->GetStatusPrefix();
19
if (!sNick.Equals(sPrefix, false, sPrefix.length()))
22
CString sModNick = sNick.substr(sPrefix.length());
23
if (!sModNick.Equals("status") &&
24
!m_pUser->GetModules().FindModule(sModNick) &&
25
!CZNC::Get().GetModules().FindModule(sModNick))
30
virtual EModRet OnUserRaw(CString& sLine) {
32
if (sLine.Token(0).Equals("ison")) {
34
VCString::const_iterator it;
36
// Get the list of nicks which are being asked for
37
sLine.Token(1, true).TrimLeft_n(":").Split(" ", vsNicks, false);
40
for (it = vsNicks.begin(); it != vsNicks.end(); ++it) {
41
if (IsOnlineModNick(*it)) {
42
sBNCNicks += " " + *it;
45
// Remove the leading space
46
sBNCNicks.LeftChomp();
48
if (!m_pUser->GetIRCSock()) {
49
// if we are not connected to any IRC server, send
50
// an empty or module-nick filled response.
51
PutUser(":irc.znc.in 303 " + m_pUser->GetNick() + " :" + sBNCNicks);
53
// We let the server handle this request and then act on
54
// the 303 response from the IRC server.
55
m_ISONRequests.push_back(sBNCNicks);
60
if (sLine.Token(0).Equals("whois")) {
61
CString sNick = sLine.Token(1);
63
if (IsOnlineModNick(sNick)) {
64
PutUser(":znc.in 311 " + m_pUser->GetCurNick() + " " + sNick + " " + sNick + " znc.in * :" + sNick);
65
PutUser(":znc.in 312 " + m_pUser->GetCurNick() + " " + sNick + " *.znc.in :Bouncer");
66
PutUser(":znc.in 318 " + m_pUser->GetCurNick() + " " + sNick + " :End of /WHOIS list.");
75
virtual EModRet OnRaw(CString& sLine) {
76
//Handle 303 reply if m_Requests is not empty
77
if (sLine.Token(1) == "303" && !m_ISONRequests.empty()) {
78
VCString::iterator it = m_ISONRequests.begin();
82
// Only append a space if this isn't an empty reply
83
if (sLine.Right(1) != ":") {
87
//add BNC nicks to the reply
89
m_ISONRequests.erase(it);
96
VCString m_ISONRequests;
99
MODULEDEFS(CFOModule, "Fakes online status of ZNC *-users.")