summaryrefslogtreecommitdiff
path: root/src/users.cpp
diff options
context:
space:
mode:
authoraquanight <aquanight@e03df62e-2008-0410-955e-edbf42e46eb7>2008-02-08 23:35:39 +0000
committeraquanight <aquanight@e03df62e-2008-0410-955e-edbf42e46eb7>2008-02-08 23:35:39 +0000
commit18154f4d229cf8ebdcec0dac671ad6e2e0049fee (patch)
tree884342c65c18c913dfbbfd5d26c7b81495e792a8 /src/users.cpp
parent31b785cb03d616a7989c57279d76f05f8d9aa9c3 (diff)
Support for /invite <user> <channel> <timeout> - if the user doesn't partake in <timeout> time, the invite expires
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@8854 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/users.cpp')
-rw-r--r--src/users.cpp45
1 files changed, 40 insertions, 5 deletions
diff --git a/src/users.cpp b/src/users.cpp
index be51cc46a..4bf2986b8 100644
--- a/src/users.cpp
+++ b/src/users.cpp
@@ -367,10 +367,20 @@ char* User::GetFullRealHost()
bool User::IsInvited(const irc::string &channel)
{
- for (InvitedList::iterator i = invites.begin(); i != invites.end(); i++)
+ time_t now = time(NULL);
+ InvitedList::iterator safei;
+ for (InvitedList::iterator i = invites.begin(); i != invites.end(); ++i)
{
- if (channel == *i)
+ if (channel == i->first)
{
+ if (i->second != 0 && now > i->second)
+ {
+ /* Expired invite, remove it. */
+ safei = i;
+ --i;
+ invites.erase(safei);
+ continue;
+ }
return true;
}
}
@@ -379,19 +389,44 @@ bool User::IsInvited(const irc::string &channel)
InvitedList* User::GetInviteList()
{
+ time_t now = time(NULL);
+ /* Weed out expired invites here. */
+ InvitedList::iterator safei;
+ for (InvitedList::iterator i = invites.begin(); i != invites.end(); ++i)
+ {
+ if (i->second != 0 && now > i->second)
+ {
+ /* Expired invite, remove it. */
+ safei = i;
+ --i;
+ invites.erase(safei);
+ }
+ }
return &invites;
}
-void User::InviteTo(const irc::string &channel)
+void User::InviteTo(const irc::string &channel, time_t timeout)
{
- invites.push_back(channel);
+ time_t now = time(NULL);
+ if (timeout != 0 && now > timeout) return; /* Don't add invites that are expired from the get-go. */
+ for (InvitedList::iterator i = invites.begin(); i != invites.end(); ++i)
+ {
+ if (channel == i->first)
+ {
+ if (i->second != 0 && timeout > i->second)
+ {
+ i->second = timeout;
+ }
+ }
+ }
+ invites.push_back(std::make_pair(channel, timeout));
}
void User::RemoveInvite(const irc::string &channel)
{
for (InvitedList::iterator i = invites.begin(); i != invites.end(); i++)
{
- if (channel == *i)
+ if (channel == i->first)
{
invites.erase(i);
return;