| 1 |
adx |
30 |
/* |
| 2 |
|
|
* ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). |
| 3 |
|
|
* m_invite.c: Invites the user to join a channel. |
| 4 |
|
|
* |
| 5 |
|
|
* Copyright (C) 2002 by the past and present ircd coders, and others. |
| 6 |
|
|
* |
| 7 |
|
|
* This program is free software; you can redistribute it and/or modify |
| 8 |
|
|
* it under the terms of the GNU General Public License as published by |
| 9 |
|
|
* the Free Software Foundation; either version 2 of the License, or |
| 10 |
|
|
* (at your option) any later version. |
| 11 |
|
|
* |
| 12 |
|
|
* This program is distributed in the hope that it will be useful, |
| 13 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 |
|
|
* GNU General Public License for more details. |
| 16 |
|
|
* |
| 17 |
|
|
* You should have received a copy of the GNU General Public License |
| 18 |
|
|
* along with this program; if not, write to the Free Software |
| 19 |
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 |
| 20 |
|
|
* USA |
| 21 |
|
|
* |
| 22 |
knight |
31 |
* $Id$ |
| 23 |
adx |
30 |
*/ |
| 24 |
|
|
|
| 25 |
|
|
#include "stdinc.h" |
| 26 |
|
|
#include "tools.h" |
| 27 |
|
|
#include "handlers.h" |
| 28 |
|
|
#include "common.h" |
| 29 |
|
|
#include "channel.h" |
| 30 |
|
|
#include "channel_mode.h" |
| 31 |
|
|
#include "list.h" |
| 32 |
|
|
#include "client.h" |
| 33 |
|
|
#include "hash.h" |
| 34 |
|
|
#include "irc_string.h" |
| 35 |
|
|
#include "ircd.h" |
| 36 |
|
|
#include "numeric.h" |
| 37 |
|
|
#include "send.h" |
| 38 |
|
|
#include "s_conf.h" |
| 39 |
|
|
#include "s_serv.h" |
| 40 |
|
|
#include "msg.h" |
| 41 |
|
|
#include "parse.h" |
| 42 |
|
|
#include "modules.h" |
| 43 |
|
|
#include "packet.h" |
| 44 |
|
|
|
| 45 |
|
|
static void m_invite(struct Client *, struct Client *, int, char *[]); |
| 46 |
|
|
|
| 47 |
|
|
struct Message invite_msgtab = { |
| 48 |
|
|
"INVITE", 0, 0, 3, 0, MFLG_SLOW, 0, |
| 49 |
|
|
{ m_unregistered, m_invite, m_invite, m_ignore, m_invite, m_ignore } |
| 50 |
|
|
}; |
| 51 |
|
|
|
| 52 |
|
|
#ifndef STATIC_MODULES |
| 53 |
|
|
void |
| 54 |
|
|
_modinit(void) |
| 55 |
|
|
{ |
| 56 |
|
|
mod_add_cmd(&invite_msgtab); |
| 57 |
|
|
} |
| 58 |
|
|
|
| 59 |
|
|
void |
| 60 |
|
|
_moddeinit(void) |
| 61 |
|
|
{ |
| 62 |
|
|
mod_del_cmd(&invite_msgtab); |
| 63 |
|
|
} |
| 64 |
|
|
|
| 65 |
knight |
31 |
const char *_version = "$Revision$"; |
| 66 |
adx |
30 |
#endif |
| 67 |
|
|
|
| 68 |
|
|
/* |
| 69 |
|
|
** m_invite |
| 70 |
|
|
** parv[0] - sender prefix |
| 71 |
|
|
** parv[1] - user to invite |
| 72 |
|
|
** parv[2] - channel name |
| 73 |
|
|
** parv[3] - invite timestamp |
| 74 |
|
|
*/ |
| 75 |
|
|
static void |
| 76 |
|
|
m_invite(struct Client *client_p, struct Client *source_p, |
| 77 |
|
|
int parc, char *parv[]) |
| 78 |
|
|
{ |
| 79 |
|
|
struct Client *target_p = NULL; |
| 80 |
|
|
struct Channel *chptr = NULL; |
| 81 |
|
|
struct Membership *ms = NULL; |
| 82 |
|
|
|
| 83 |
|
|
if (IsServer(source_p)) |
| 84 |
|
|
return; |
| 85 |
|
|
|
| 86 |
|
|
if (*parv[2] == '\0') |
| 87 |
|
|
{ |
| 88 |
|
|
sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS), |
| 89 |
|
|
me.name, source_p->name, "INVITE"); |
| 90 |
|
|
return; |
| 91 |
|
|
} |
| 92 |
|
|
|
| 93 |
|
|
if (MyClient(source_p) && !IsFloodDone(source_p)) |
| 94 |
|
|
flood_endgrace(source_p); |
| 95 |
|
|
|
| 96 |
|
|
if ((target_p = find_person(client_p, parv[1])) == NULL) |
| 97 |
|
|
{ |
| 98 |
|
|
sendto_one(source_p, form_str(ERR_NOSUCHNICK), |
| 99 |
|
|
me.name, source_p->name, parv[1]); |
| 100 |
|
|
return; |
| 101 |
|
|
} |
| 102 |
|
|
|
| 103 |
|
|
/* Do not send local channel invites to users if they are not on the |
| 104 |
|
|
* same server as the person sending the INVITE message. |
| 105 |
|
|
*/ |
| 106 |
|
|
/* Possibly should be an error sent to source_p */ |
| 107 |
|
|
/* done .. there should be no problem because MyConnect(source_p) should |
| 108 |
|
|
* always be true if parse() and such is working correctly --is |
| 109 |
|
|
*/ |
| 110 |
|
|
if (!MyConnect(target_p) && (*parv[2] == '&')) |
| 111 |
|
|
{ |
| 112 |
|
|
if (ConfigServerHide.hide_servers == 0) |
| 113 |
|
|
sendto_one(source_p, form_str(ERR_USERNOTONSERV), |
| 114 |
|
|
me.name, source_p->name, target_p->name); |
| 115 |
|
|
return; |
| 116 |
|
|
} |
| 117 |
|
|
|
| 118 |
|
|
if ((chptr = hash_find_channel(parv[2])) == NULL) |
| 119 |
|
|
{ |
| 120 |
|
|
sendto_one(source_p, form_str(ERR_NOSUCHCHANNEL), |
| 121 |
|
|
me.name, source_p->name, parv[2]); |
| 122 |
|
|
return; |
| 123 |
|
|
} |
| 124 |
|
|
|
| 125 |
|
|
if ((ms = find_channel_link(source_p, chptr)) == NULL) |
| 126 |
|
|
{ |
| 127 |
|
|
sendto_one(source_p, form_str(ERR_NOTONCHANNEL), |
| 128 |
|
|
me.name, source_p->name, chptr->chname); |
| 129 |
|
|
return; |
| 130 |
|
|
} |
| 131 |
|
|
|
| 132 |
|
|
if (ConfigChannel.invite_ops_only || (chptr->mode.mode & MODE_INVITEONLY)) |
| 133 |
|
|
{ |
| 134 |
|
|
if (MyConnect(source_p) && !has_member_flags(ms, CHFL_CHANOP|CHFL_HALFOP)) |
| 135 |
|
|
{ |
| 136 |
|
|
sendto_one(source_p, form_str(ERR_CHANOPRIVSNEEDED), |
| 137 |
|
|
me.name, source_p->name, chptr->chname); |
| 138 |
|
|
return; |
| 139 |
|
|
} |
| 140 |
|
|
} |
| 141 |
|
|
|
| 142 |
|
|
if (IsMember(target_p, chptr)) |
| 143 |
|
|
{ |
| 144 |
|
|
sendto_one(source_p, form_str(ERR_USERONCHANNEL), |
| 145 |
|
|
me.name, source_p->name, target_p->name, chptr->chname); |
| 146 |
|
|
return; |
| 147 |
|
|
} |
| 148 |
|
|
|
| 149 |
|
|
if (MyConnect(source_p)) |
| 150 |
|
|
{ |
| 151 |
|
|
sendto_one(source_p, form_str(RPL_INVITING), me.name, |
| 152 |
|
|
source_p->name, target_p->name, chptr->chname); |
| 153 |
|
|
|
| 154 |
|
|
if (target_p->away) |
| 155 |
|
|
sendto_one(source_p, form_str(RPL_AWAY), |
| 156 |
|
|
me.name, source_p->name, target_p->name, |
| 157 |
|
|
target_p->away); |
| 158 |
|
|
} |
| 159 |
|
|
else if (parc > 3 && IsDigit(*parv[3])) |
| 160 |
|
|
if (atoi(parv[3]) > chptr->channelts) |
| 161 |
|
|
return; |
| 162 |
|
|
|
| 163 |
|
|
if (!MyConnect(target_p) && ServerInfo.hub && |
| 164 |
|
|
IsCapable(target_p->from, CAP_LL)) |
| 165 |
|
|
{ |
| 166 |
|
|
/* target_p is connected to a LL leaf, connected to us */ |
| 167 |
|
|
if (IsClient(source_p)) |
| 168 |
|
|
client_burst_if_needed(target_p->from, source_p); |
| 169 |
|
|
|
| 170 |
|
|
if ((chptr->lazyLinkChannelExists & |
| 171 |
|
|
target_p->from->localClient->serverMask) == 0) |
| 172 |
|
|
burst_channel(target_p->from, chptr); |
| 173 |
|
|
} |
| 174 |
|
|
|
| 175 |
|
|
if (MyConnect(target_p)) |
| 176 |
|
|
{ |
| 177 |
|
|
sendto_one(target_p, ":%s!%s@%s INVITE %s :%s", |
| 178 |
|
|
source_p->name, source_p->username, |
| 179 |
|
|
source_p->host, |
| 180 |
|
|
target_p->name, chptr->chname); |
| 181 |
|
|
|
| 182 |
|
|
if (chptr->mode.mode & MODE_INVITEONLY) |
| 183 |
|
|
{ |
| 184 |
|
|
if (chptr->mode.mode & MODE_PRIVATE) |
| 185 |
|
|
{ |
| 186 |
|
|
/* Only do this if channel is set +i AND +p */ |
| 187 |
|
|
sendto_channel_local(CHFL_CHANOP|CHFL_HALFOP, NO, chptr, |
| 188 |
|
|
":%s NOTICE %s :%s is inviting %s to %s.", |
| 189 |
|
|
me.name, chptr->chname, source_p->name, |
| 190 |
|
|
target_p->name, chptr->chname); |
| 191 |
|
|
sendto_channel_remote(source_p, client_p, CHFL_CHANOP|CHFL_HALFOP, |
| 192 |
|
|
NOCAPS, NOCAPS, chptr, |
| 193 |
|
|
":%s NOTICE %s :%s is inviting %s to %s.", |
| 194 |
|
|
source_p->name, chptr->chname, source_p->name, |
| 195 |
|
|
target_p->name, chptr->chname); |
| 196 |
|
|
} |
| 197 |
|
|
|
| 198 |
|
|
/* Add the invite if channel is +i */ |
| 199 |
|
|
add_invite(chptr, target_p); |
| 200 |
|
|
} |
| 201 |
|
|
} |
| 202 |
|
|
else if (target_p->from != client_p) |
| 203 |
|
|
sendto_one(target_p, ":%s INVITE %s %s %lu", |
| 204 |
|
|
ID_or_name(source_p, target_p->from), |
| 205 |
|
|
ID_or_name(target_p, target_p->from), |
| 206 |
|
|
chptr->chname, (unsigned long)chptr->channelts); |
| 207 |
|
|
} |