00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include "stdinc.h"
00026 #include "tools.h"
00027 #include "handlers.h"
00028 #include "channel.h"
00029 #include "channel_mode.h"
00030 #include "client.h"
00031 #include "ircd.h"
00032 #include "numeric.h"
00033 #include "s_log.h"
00034 #include "s_serv.h"
00035 #include "send.h"
00036 #include "whowas.h"
00037 #include "irc_string.h"
00038 #include "hash.h"
00039 #include "msg.h"
00040 #include "parse.h"
00041 #include "modules.h"
00042 #include "common.h"
00043
00044 static void mo_opme(struct Client *, struct Client *, int, char *[]);
00045
00046 struct Message opme_msgtab = {
00047 "OPME", 0, 0, 2, 0, MFLG_SLOW, 0,
00048 { m_unregistered, m_not_oper, m_ignore, m_ignore, mo_opme, m_ignore }
00049 };
00050
00051 #ifndef STATIC_MODULES
00052 void
00053 _modinit(void)
00054 {
00055 mod_add_cmd(&opme_msgtab);
00056 }
00057
00058 void
00059 _moddeinit(void)
00060 {
00061 mod_del_cmd(&opme_msgtab);
00062 }
00063
00064 const char *_version = "$Revision: 33 $";
00065 #endif
00066
00067 static int
00068 chan_is_opless(const struct Channel *const chptr)
00069 {
00070 const dlink_node *ptr = NULL;
00071
00072 DLINK_FOREACH(ptr, chptr->members.head)
00073 if (((struct Membership *)ptr->data)->flags & CHFL_CHANOP)
00074 return(0);
00075
00076 return(1);
00077 }
00078
00079
00080
00081
00082
00083
00084 static void
00085 mo_opme(struct Client *client_p, struct Client *source_p,
00086 int parc, char *parv[])
00087 {
00088 struct Channel *chptr = NULL;
00089 struct Membership *member = NULL;
00090
00091 if (!IsAdmin(source_p))
00092 {
00093 sendto_one(source_p, form_str(ERR_NOPRIVILEGES),
00094 me.name, source_p->name);
00095 return;
00096 }
00097
00098
00099
00100 if ((chptr = hash_find_channel(parv[1])) == NULL)
00101 {
00102 sendto_one(source_p, form_str(ERR_NOSUCHCHANNEL),
00103 me.name, source_p->name, parv[1]);
00104 return;
00105 }
00106
00107 if ((member = find_channel_link(source_p, chptr)) == NULL)
00108 {
00109 sendto_one(source_p, form_str(ERR_NOTONCHANNEL),
00110 me.name, source_p->name, chptr->chname);
00111 return;
00112 }
00113
00114 if (chan_is_opless(chptr) == 0)
00115 {
00116 sendto_one(source_p, ":%s NOTICE %s :%s Channel is not opless",
00117 me.name, source_p->name, chptr->chname);
00118 return;
00119 }
00120
00121 AddMemberFlag(member, CHFL_CHANOP);
00122
00123 if (*parv[1] == '&')
00124 {
00125 sendto_wallops_flags(UMODE_LOCOPS, &me,
00126 "OPME called for [%s] by %s!%s@%s",
00127 chptr->chname, source_p->name, source_p->username,
00128 source_p->host);
00129 }
00130 else
00131 {
00132 sendto_wallops_flags(UMODE_WALLOP, &me,
00133 "OPME called for [%s] by %s!%s@%s",
00134 chptr->chname, source_p->name, source_p->username,
00135 source_p->host);
00136 sendto_server(NULL, source_p, NULL, NOCAPS, NOCAPS, LL_ICLIENT,
00137 ":%s WALLOPS :OPME called for [%s] by %s!%s@%s",
00138 me.name, chptr->chname, source_p->name, source_p->username,
00139 source_p->host);
00140 }
00141
00142 ilog(L_NOTICE, "OPME called for [%s] by %s!%s@%s",
00143 chptr->chname, source_p->name, source_p->username,
00144 source_p->host);
00145
00146 sendto_server(NULL, source_p, chptr, CAP_TS6, NOCAPS, NOFLAGS,
00147 ":%s PART %s", ID(source_p), chptr->chname);
00148 sendto_server(NULL, source_p, chptr, NOCAPS, CAP_TS6, NOFLAGS,
00149 ":%s PART %s", source_p->name, chptr->chname);
00150 sendto_server(NULL, source_p, chptr, CAP_TS6, NOCAPS, NOFLAGS,
00151 ":%s SJOIN %lu %s + :@%s",
00152 me.id, (unsigned long)chptr->channelts,
00153 chptr->chname, ID(source_p));
00154 sendto_server(NULL, source_p, chptr, NOCAPS, CAP_TS6, NOFLAGS,
00155 ":%s SJOIN %lu %s + :@%s",
00156 me.name, (unsigned long)chptr->channelts,
00157 chptr->chname, source_p->name);
00158
00159 sendto_channel_local(ALL_MEMBERS, NO, chptr, ":%s MODE %s +o %s",
00160 me.name, chptr->chname, source_p->name);
00161 }