00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef lint
00021 static const char rcsid[] = "$Id: events.c,v 1.10 2007-08-18 22:32:24 sven Exp $";
00022 #endif
00023
00024 #include <string.h>
00025
00026 #include <eggdrop/eggdrop.h>
00027
00028 #include "dccparty.h"
00029
00030 static int on_privmsg(void *client_data, partymember_t *dest, botnet_entity_t *src, const char *text, int len);
00031 static int on_nick(void *client_data, partymember_t *src, const char *oldnick, const char *newnick);
00032 static int on_quit(void *client_data, partymember_t *src, const botnet_bot_t *lostbot, const char *text, int len);
00033 static int on_chanmsg(void *client_data, partychan_t *chan, botnet_entity_t *src, const char *text, int len);
00034 static int on_join(void *client_data, partychan_t *chan, partymember_t *src, int linking);
00035 static int on_part(void *client_data, partychan_t *chan, partymember_t *src, const char *text, int len);
00036
00037 partyline_event_t dcc_party_handler = {
00038 on_privmsg,
00039 on_nick,
00040 on_quit,
00041 on_chanmsg,
00042 on_join,
00043 on_part
00044 };
00045
00046 static int on_privmsg(void *client_data, partymember_t *dest, botnet_entity_t *src, const char *text, int len)
00047 {
00048 dcc_session_t *session = client_data;
00049
00050 if (src) {
00051 if (len >= 9 && !strncasecmp(text, "\1ACTION ", 8) && text[len - 1] == 1) {
00052 egg_iprintf(session->idx, "%s %.*s\r\n", entity_common_name(src), len - 9, text + 8);
00053 } else {
00054 egg_iprintf(session->idx, "[%s] %s\r\n", entity_common_name(src), text);
00055 }
00056 } else {
00057 egg_iprintf(session->idx, "%s\r\n", text);
00058 }
00059 return(0);
00060 }
00061
00062 static int on_nick(void *client_data, partymember_t *src, const char *oldnick, const char *newnick)
00063 {
00064 dcc_session_t *session = client_data;
00065
00066 if (src->bot) egg_iprintf(session->idx, "%s@%s is now known as %s@%s.\n", oldnick, src->bot->name, newnick,src->bot->name);
00067 else egg_iprintf(session->idx, "%s is now known as %s.\n", oldnick, newnick);
00068 return(0);
00069 }
00070
00071 static int on_quit(void *client_data, partymember_t *src, const botnet_bot_t *lostbot, const char *text, int len)
00072 {
00073 dcc_session_t *session = client_data;
00074
00075 if (lostbot) return 0;
00076 egg_iprintf(session->idx, "%s (%s@%s) has quit: %s\n", src->common_name, src->ident, src->host, text);
00077
00078 return(0);
00079 }
00080
00081 static int on_chanmsg(void *client_data, partychan_t *chan, botnet_entity_t *src, const char *text, int len)
00082 {
00083 dcc_session_t *session = client_data;
00084
00085 if (src) {
00086 if (len >= 9 && !strncasecmp(text, "\1ACTION ", 8) && text[len - 1] == 1) {
00087 egg_iprintf(session->idx, "%s %s %.*s\r\n", chan->name, entity_common_name(src), len - 9, text + 8);
00088 } else {
00089 egg_iprintf(session->idx, "%s <%s> %s\r\n", chan->name, entity_common_name(src), text);
00090 }
00091 } else {
00092 egg_iprintf(session->idx, "%s %s\r\n", chan->name, text);
00093 }
00094 return(0);
00095 }
00096
00097 static int on_join(void *client_data, partychan_t *chan, partymember_t *src, int linking)
00098 {
00099 dcc_session_t *session = client_data;
00100
00101 if (!linking) egg_iprintf(session->idx, "%s %s (%s@%s) has joined the channel.\r\n", chan->name, src->common_name, src->ident, src->host);
00102 return(0);
00103 }
00104
00105 static int on_part(void *client_data, partychan_t *chan, partymember_t *src, const char *text, int len)
00106 {
00107 dcc_session_t *session = client_data;
00108
00109 egg_iprintf(session->idx, "%s %s (%s@%s) has left the channel: %s\r\n", chan->name, src->common_name, src->ident, src->host, text);
00110 return(0);
00111 }