2
2
* ctcp.c -- part of ctcp.mod
3
3
* all the ctcp handling (except DCC, it's special ;)
5
* $Id: ctcp.c,v 1.17 2002/01/02 03:46:38 guppy Exp $
5
* $Id: ctcp.c,v 1.22 2004/01/09 05:56:38 wcc Exp $
8
8
* Copyright (C) 1997 Robey Pointer
9
* Copyright (C) 1999, 2000, 2001, 2002 Eggheads Development Team
9
* Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004 Eggheads Development Team
11
11
* This program is free software; you can redistribute it and/or
12
12
* modify it under the terms of the GNU General Public License
58
58
static int ctcp_PING(char *nick, char *uhost, char *handle,
59
char *object, char *keyword, char *text)
59
char *object, char *keyword, char *text)
61
61
struct userrec *u = get_user_by_handle(userlist, handle);
62
62
int atr = u ? u->flags : 0;
64
64
if ((ctcp_mode != 1 || (atr & USER_OP)) && strlen(text) <= 80)
65
simple_sprintf(ctcp_reply, "%s\001%s %s\001", ctcp_reply, keyword, text);
65
simple_sprintf(ctcp_reply, "%s\001%s %s\001", ctcp_reply, keyword, text);
69
69
static int ctcp_VERSION(char *nick, char *uhost, char *handle,
70
char *object, char *keyword, char *text)
70
char *object, char *keyword, char *text)
72
72
if (ctcp_mode != 1 && ctcp_version[0])
73
73
simple_sprintf(ctcp_reply, "%s\001VERSION %s\001", ctcp_reply,
78
78
static int ctcp_USERINFO(char *nick, char *uhost, char *handle,
79
char *object, char *keyword, char *text)
79
char *object, char *keyword, char *text)
81
81
if (ctcp_mode != 1 && ctcp_userinfo[0])
82
82
simple_sprintf(ctcp_reply, "%s\001USERINFO %s\001", ctcp_reply,
87
87
static int ctcp_CLIENTINFO(char *nick, char *uhosr, char *handle,
88
char *object, char *keyword, char *msg)
88
char *object, char *keyword, char *msg)
119
119
p = CLIENTINFO_ECHO;
121
121
simple_sprintf(ctcp_reply,
122
"%s\001ERRMSG CLIENTINFO: %s is not a valid function\001",
122
"%s\001ERRMSG CLIENTINFO: %s is not a valid function\001",
125
125
simple_sprintf(ctcp_reply, "%s\001CLIENTINFO %s\001", ctcp_reply, p);
129
129
static int ctcp_TIME(char *nick, char *uhost, char *handle, char *object,
130
char *keyword, char *text)
130
char *keyword, char *text)
142
142
static int ctcp_CHAT(char *nick, char *uhost, char *handle, char *object,
143
char *keyword, char *text)
143
char *keyword, char *text)
145
145
struct userrec *u = get_user_by_handle(userlist, handle);
146
146
int atr = u ? u->flags : 0, i;
148
if ((atr & (USER_PARTY | USER_XFER)) ||
149
((atr & USER_OP) && !require_p)) {
148
if ((atr & (USER_PARTY | USER_XFER)) || ((atr & USER_OP) && !require_p)) {
151
150
if (u_pass_match(u, "-")) {
152
simple_sprintf(ctcp_reply, "%s\001ERROR no password set\001", ctcp_reply);
151
simple_sprintf(ctcp_reply, "%s\001ERROR no password set\001",
156
156
for (i = 0; i < dcc_total; i++) {
157
157
if ((dcc[i].type->flags & DCT_LISTEN) &&
158
(!strcmp(dcc[i].nick, "(telnet)") ||
159
!strcmp(dcc[i].nick, "(users)"))) {
158
(!strcmp(dcc[i].nick, "(telnet)") ||
159
!strcmp(dcc[i].nick, "(users)"))) {
160
160
/* Do me a favour and don't change this back to a CTCP reply,
161
161
* CTCP replies are NOTICE's this has to be a PRIVMSG
162
162
* -poptix 5/1/1997 */
163
dprintf(DP_SERVER, "PRIVMSG %s :\001DCC CHAT chat %lu %u\001\n",
165
iptolong(natip[0] ? (IP) inet_addr(natip) : getmyip()),
163
dprintf(DP_SERVER, "PRIVMSG %s :\001DCC CHAT chat %lu %u\001\n",
164
nick, iptolong(natip[0] ? (IP) inet_addr(natip) : getmyip()),
175
static cmd_t myctcp[] =
177
{"FINGER", "", ctcp_FINGER, NULL},
178
{"ECHO", "", ctcp_ECHOERR, NULL},
179
{"PING", "", ctcp_PING, NULL},
180
{"ERRMSG", "", ctcp_ECHOERR, NULL},
181
{"VERSION", "", ctcp_VERSION, NULL},
182
{"USERINFO", "", ctcp_USERINFO, NULL},
183
{"CLIENTINFO", "", ctcp_CLIENTINFO, NULL},
184
{"TIME", "", ctcp_TIME, NULL},
185
{"CHAT", "", ctcp_CHAT, NULL},
186
{NULL, NULL, NULL, NULL}
189
static tcl_strings mystrings[] =
191
{"ctcp-version", ctcp_version, 120, 0},
192
{"ctcp-finger", ctcp_finger, 120, 0},
193
{"ctcp-userinfo", ctcp_userinfo, 120, 0},
197
static tcl_ints myints[] =
199
{"ctcp-mode", &ctcp_mode},
174
static cmd_t myctcp[] = {
175
{"FINGER", "", ctcp_FINGER, NULL},
176
{"ECHO", "", ctcp_ECHOERR, NULL},
177
{"PING", "", ctcp_PING, NULL},
178
{"ERRMSG", "", ctcp_ECHOERR, NULL},
179
{"VERSION", "", ctcp_VERSION, NULL},
180
{"USERINFO", "", ctcp_USERINFO, NULL},
181
{"CLIENTINFO", "", ctcp_CLIENTINFO, NULL},
182
{"TIME", "", ctcp_TIME, NULL},
183
{"CHAT", "", ctcp_CHAT, NULL},
184
{NULL, NULL, NULL, NULL}
187
static tcl_strings mystrings[] = {
188
{"ctcp-version", ctcp_version, 120, 0},
189
{"ctcp-finger", ctcp_finger, 120, 0},
190
{"ctcp-userinfo", ctcp_userinfo, 120, 0},
194
static tcl_ints myints[] = {
195
{"ctcp-mode", &ctcp_mode},
203
199
static char *ctcp_close()
213
209
EXPORT_SCOPE char *ctcp_start();
215
static Function ctcp_table[] =
211
static Function ctcp_table[] = {
217
212
(Function) ctcp_start,
218
213
(Function) ctcp_close,
223
char *ctcp_start(Function * global_funcs)
218
char *ctcp_start(Function *global_funcs)
225
220
global = global_funcs;
227
222
module_register(MODULE_NAME, ctcp_table, 1, 0);
228
223
if (!module_depend(MODULE_NAME, "eggdrop", 106, 0)) {
229
224
module_undepend(MODULE_NAME);
230
return "You need an eggdrop of at least v1.6.0 to use this ctcp module.";
225
return "This module requires Eggdrop 1.6.0 or later.";
232
227
if (!(server_funcs = module_depend(MODULE_NAME, "server", 1, 0))) {
233
228
module_undepend(MODULE_NAME);
234
return "You need the server module to use the ctcp module.";
229
return "This module requires server module 1.0 or later.";
236
231
add_tcl_strings(mystrings);
237
232
add_tcl_ints(myints);