This repository has been archived by the owner on Nov 9, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
privreplay.cpp
93 lines (76 loc) · 2.36 KB
/
privreplay.cpp
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
#include "User.h"
#include <sys/stat.h>
class CPrivReplay : public CModule
{
public:
MODCONSTRUCTOR(CPrivReplay)
{
}
virtual ~CPrivReplay()
{
}
virtual EModRet OnPrivMsg(CNick& Nick, CString& sMessage)
{
StoreMessage(Nick, sMessage);
return (CONTINUE);
}
virtual EModRet OnUserRaw(CString &sLine)
{
//PutModule("Raw: " + sLine);
if (sLine.Left(7).Equals("PRIVMSG"))
{
//PutModule("OUTBOUND PRIVMSG");
VCString vsRet;
sLine.Split(" ", vsRet);
// Check the prefix on the to name and ignore special users, control channels and channels.
CString toNamePrefix = vsRet[1].Left(1);
if (toNamePrefix.Equals("*") || toNamePrefix.Equals("&") || toNamePrefix.Equals("#"))
{
return CONTINUE;
}
CString msg = vsRet[2];
msg.LeftChomp(1);
for (int c = 3; vsRet.size() > c; c++)
{
msg += " " + vsRet[c];
}
StoreMessage(":" + vsRet[1] + " PRIVMSG " + m_pUser->GetIRCNick().GetNick() + " :me: " + msg);
}
return (CONTINUE);
}
virtual void OnClientLogin()
{
ReplayMessages();
}
private:
void StoreMessage(const CNick & Nick, CString & sMessage)
{
//PutModule("Store: " + Nick.GetNick() + " -> " + sMessage);
if (m_pUser && Nick.GetNick() == m_pUser->GetIRCNick().GetNick())
{
// StoreMessage(":" + m_pUser->GetIRCNick().GetNick() + " PRIVMSG " + Nick.GetNickMask() + " :" + sMessage);
//StoreMessage(":" + Nick.GetNickMask() + " PRIVMSG " + m_pUser->GetIRCNick().GetNick() + " :" + sMessage);
}
else
{
StoreMessage(":" + Nick.GetNickMask() + " PRIVMSG " + m_pUser->GetIRCNick().GetNick() + " :" + sMessage);
}
}
void StoreMessage(const CString & sText)
{
m_vMessages.push_back(sText);
}
void ReplayMessages()
{
if (!m_vMessages.empty())
{
vector<CString>::iterator iter;
for (iter = m_vMessages.begin(); iter != m_vMessages.end(); iter++)
{
PutUser(*iter);
}
}
}
vector<CString> m_vMessages;
};
MODULEDEFS(CPrivReplay, "Stores private messages and replays them");