Initial Commit
This commit is contained in:
parent
dabbea0835
commit
4ff77ee371
11 changed files with 5773 additions and 0 deletions
10
.gitattributes
vendored
10
.gitattributes
vendored
|
@ -1 +1,11 @@
|
|||
* text=auto !eol
|
||||
/Makefile.in -text
|
||||
/configure -text
|
||||
/configure.in -text
|
||||
/events.c -text
|
||||
/install-sh -text
|
||||
/modconfig.h.in -text
|
||||
/seen.c -text
|
||||
/seenserv.c -text
|
||||
/seenserv.h -text
|
||||
/seenserv_help.c -text
|
||||
|
|
61
Makefile.in
Normal file
61
Makefile.in
Normal file
|
@ -0,0 +1,61 @@
|
|||
#Neostats Module Makefile!
|
||||
CC = @CC@
|
||||
CFLAGS = @CFLAGS@
|
||||
LDFLAGS= @LDFLAGS@
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
DIRECTORY = @DIRINST@/modules/
|
||||
INCLUDES = -I@DIRINST@/include/ -I.
|
||||
|
||||
SRCS= seenserv.c seenserv_help.c events.c seen.c
|
||||
OBJS= ${SRCS:.c=.o}
|
||||
TARGET= seenserv.so
|
||||
DOCS=README.SeenServ
|
||||
DATA=
|
||||
SCRIPTS=
|
||||
DISTFILES=$(SRCS) $(DOCS) $(SCRIPTS) *.in configure install-sh ChangeLog *.h LICENSE RELNOTES seenserv.vcproj modconfigwin32.h
|
||||
DISTDIR= @PACKAGE@-@VERSION@
|
||||
|
||||
all: module
|
||||
@echo "Compilation complete."
|
||||
@echo "Run 'make install' (or 'gmake install' on some systems) to install."
|
||||
@echo "If you require support, see the README file."
|
||||
|
||||
# include dependency info
|
||||
@MAKEDEPENDENCIES@
|
||||
|
||||
.c.o:
|
||||
$(CC) -c $(CFLAGS) $(INCLUDES) $<
|
||||
$(CC) -MM $(INCLUDES) -c $< > $*.d
|
||||
|
||||
module: $(OBJS)
|
||||
$(LD) -shared -o $(TARGET) $(OBJS) $(LDFLAGS)
|
||||
|
||||
clean:
|
||||
/bin/rm -rf $(TARGET) *.o *.d Makefile *.log modconfig.h
|
||||
|
||||
distclean:
|
||||
/bin/rm -rf $(TARGET) *.o *.d Makefile *.log modconfig.h config.status configure.scan
|
||||
|
||||
install: module
|
||||
$(INSTALL) -m 644 $(TARGET) $(DIRECTORY)
|
||||
$(INSTALL) -m 644 $(DOCS) $(DIRECTORY)../doc/
|
||||
@echo "Installation complete."
|
||||
@echo "See the README file for instructions on loading this module."
|
||||
|
||||
dist:
|
||||
@echo -n "Creating directories"
|
||||
@-rm -rf $(DISTDIR)
|
||||
@mkdir $(DISTDIR)
|
||||
@echo "Done"
|
||||
@echo -n "Copying distribution files"
|
||||
@for file in $(DISTFILES); do \
|
||||
echo -n "."; \
|
||||
cp -pr $$file $(DISTDIR)/$$file; \
|
||||
done
|
||||
@echo "Done"
|
||||
@tar -czf $(DISTDIR).tar.gz $(DISTDIR)/*
|
||||
@echo "Tar file $(DISTDIR).tar.gz created, Freshmeat Time"
|
||||
|
||||
$(OBJS): Makefile
|
95
configure.in
Normal file
95
configure.in
Normal file
|
@ -0,0 +1,95 @@
|
|||
dnl Process this file with autoconf to produce a configure script.
|
||||
AC_INIT(seenserv.c)
|
||||
AC_CONFIG_HEADER(modconfig.h)
|
||||
|
||||
PACKAGE=SeenServ
|
||||
MODULE_MAJOR=3
|
||||
MODULE_MINOR=0
|
||||
MODULE_REV=a2
|
||||
VERSION=$MODULE_MAJOR.$MODULE_MINOR.$MODULE_REV
|
||||
AC_DEFINE_UNQUOTED(MODULE_VERSION, "$VERSION")
|
||||
AC_DEFINE_UNQUOTED(MODULE_MAJOR, "$MODULE_MAJOR")
|
||||
AC_DEFINE_UNQUOTED(MODULE_MINOR, "$MODULE_MINOR")
|
||||
AC_DEFINE_UNQUOTED(MODULE_REV, "$MODULE_REV")
|
||||
DIRINST=~/NeoStats3.0/
|
||||
AC_PREFIX_DEFAULT(~/NeoStats3.0/)
|
||||
CFLAGS="$CFLAGS -O2"
|
||||
|
||||
case "$host_os" in
|
||||
*openbsd*)
|
||||
MAKEDEPENDENCIES="";;
|
||||
*freebsd*)
|
||||
MAKEDEPENDENCIES="";;
|
||||
*)
|
||||
MAKEDEPENDENCIES="-include \$(OBJS:.o=.d)";;
|
||||
esac
|
||||
|
||||
AC_MSG_CHECKING(Location of NeoStats...)
|
||||
AC_ARG_WITH(neostats,
|
||||
[ --with-neostats=DIR Location of NeoStats installation],
|
||||
[DIRINST=$withval])
|
||||
AC_MSG_RESULT($DIRINST)
|
||||
|
||||
AC_CHECK_FILE($DIRINST/include/neostats.h,
|
||||
[INCLUDEDIR="$DIRINST/include/"],
|
||||
[AC_MSG_ERROR(Can't find existing NeoStats Installation please supply with --with-neostats option)])
|
||||
|
||||
CPPFLAGS="$CPPFLAGS -I$INCLUDEDIR"
|
||||
dnl Check we are running the latest supported version of NeoStats
|
||||
AC_MSG_CHECKING(Version of NeoStats...)
|
||||
AC_TRY_RUN(
|
||||
[
|
||||
#include <config.h>
|
||||
#include <stdlib.h>
|
||||
int main(void) {
|
||||
if (MAJOR >= 3) {
|
||||
if (MINOR >= 0) {
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
exit(1);
|
||||
}
|
||||
], ns_version_ok='yes',
|
||||
ns_version_ok='no',
|
||||
ns_version_ok='no')
|
||||
if test "$ns_version_ok" = "yes"; then
|
||||
AC_MSG_RESULT(Compatible version);
|
||||
else
|
||||
AC_MSG_ERROR(This module requires NeoStats 3.0.a2 or higher)
|
||||
fi
|
||||
|
||||
dnl check if we are running with Debug....
|
||||
AC_MSG_CHECKING(Whether to Enable Debuging...)
|
||||
AC_ARG_ENABLE(debug,
|
||||
[ --enable-debug - Enable Debuging],
|
||||
[ case "$enableval" in
|
||||
yes)
|
||||
CFLAGS="$CFLAGS -Wall -ggdb"
|
||||
AC_DEFINE(DEBUG,1)
|
||||
AC_MSG_RESULT(yes - Watch your Log Files)
|
||||
;;
|
||||
*)
|
||||
AC_MSG_RESULT(no)
|
||||
;;
|
||||
esac],
|
||||
AC_MSG_RESULT(no)
|
||||
)
|
||||
|
||||
dnl Checks for programs.
|
||||
AC_PROG_CC
|
||||
AC_PROG_INSTALL
|
||||
|
||||
AC_SUBST(DIRINST)
|
||||
AC_SUBST(MAKEDEPENDENCIES)
|
||||
AC_SUBST(CFLAGS)
|
||||
AC_SUBST(PACKAGE)
|
||||
AC_SUBST(VERSION)
|
||||
AC_OUTPUT(Makefile)
|
||||
echo "Configuration complete."
|
||||
read -p "Press Enter key to read the release notes"
|
||||
clear
|
||||
more RELNOTES
|
||||
echo "This Module was written by:"
|
||||
echo " DeadNotBurried (dnb@majestic-liaisons.com)"
|
||||
echo "Run 'make' (or 'gmake' on some systems) to compile NeoStats."
|
||||
echo "If you require support, see the README file."
|
115
events.c
Normal file
115
events.c
Normal file
|
@ -0,0 +1,115 @@
|
|||
/* SeenServ - Nickname Seen Service - NeoStats Addon Module
|
||||
** Copyright (c) 2004-2005 DeadNotBuried
|
||||
** Portions Copyright (c) 1999-2005, NeoStats
|
||||
**
|
||||
** This program is free software; you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
** the Free Software Foundation; either version 2 of the License, or
|
||||
** (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program; if not, write to the Free Software
|
||||
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
** USA
|
||||
**
|
||||
** SeenServ CVS Identification
|
||||
** $Id$
|
||||
*/
|
||||
|
||||
#include "neostats.h" /* Required for bot support */
|
||||
#include "seenserv.h"
|
||||
|
||||
/*
|
||||
* Signon Events
|
||||
*/
|
||||
int SeenSignon (CmdParams *cmdparams) {
|
||||
char tmpmsg[512];
|
||||
|
||||
ircsnprintf(tmpmsg, 512, "%s ", cmdparams->param);
|
||||
addseenentry(cmdparams->source->name, cmdparams->source->user->username, cmdparams->source->user->hostname, cmdparams->source->user->vhost, tmpmsg, SS_CONNECTED);
|
||||
return NS_SUCCESS;
|
||||
}
|
||||
|
||||
/*
|
||||
* Quit Events
|
||||
*/
|
||||
int SeenQuit (CmdParams *cmdparams) {
|
||||
char tmpmsg[512];
|
||||
|
||||
ircsnprintf(tmpmsg, 512, "(%s)", cmdparams->param);
|
||||
addseenentry(cmdparams->source->name, cmdparams->source->user->username, cmdparams->source->user->hostname, cmdparams->source->user->vhost, tmpmsg, SS_QUIT);
|
||||
return NS_SUCCESS;
|
||||
}
|
||||
|
||||
/*
|
||||
* Kill Events
|
||||
*/
|
||||
int SeenKill (CmdParams *cmdparams) {
|
||||
char tmpmsg[512];
|
||||
|
||||
ircsnprintf(tmpmsg, 512, "by %s (%s)", cmdparams->target->name, cmdparams->source->name, cmdparams->param);
|
||||
addseenentry(cmdparams->target->name, cmdparams->target->user->username, cmdparams->target->user->hostname, cmdparams->target->user->vhost, tmpmsg, SS_KILLED);
|
||||
return NS_SUCCESS;
|
||||
}
|
||||
|
||||
/*
|
||||
* Nick Events
|
||||
*/
|
||||
int SeenNickChange (CmdParams *cmdparams) {
|
||||
char tmpmsg[512];
|
||||
|
||||
ircsnprintf(tmpmsg, 512, "to %s", cmdparams->source->name);
|
||||
addseenentry(cmdparams->param, cmdparams->source->user->username, cmdparams->source->user->hostname, cmdparams->source->user->vhost, tmpmsg, SS_NICKCHANGE);
|
||||
return NS_SUCCESS;
|
||||
}
|
||||
|
||||
/*
|
||||
* Join Events
|
||||
*/
|
||||
int SeenJoinChan (CmdParams *cmdparams) {
|
||||
char tmpmsg[512];
|
||||
|
||||
if (is_hidden_chan(cmdparams->channel)) {
|
||||
return NS_SUCCESS;
|
||||
}
|
||||
ircsnprintf(tmpmsg, 512, "%s", cmdparams->channel->name);
|
||||
addseenentry(cmdparams->source->name, cmdparams->source->user->username, cmdparams->source->user->hostname, cmdparams->source->user->vhost, tmpmsg, SS_JOIN);
|
||||
return NS_SUCCESS;
|
||||
}
|
||||
|
||||
/*
|
||||
* Part Events
|
||||
*/
|
||||
int SeenPartChan (CmdParams *cmdparams) {
|
||||
char tmpmsg[512];
|
||||
|
||||
if (is_hidden_chan(cmdparams->channel)) {
|
||||
return NS_SUCCESS;
|
||||
}
|
||||
if (cmdparams->param) {
|
||||
ircsnprintf(tmpmsg, 512, "%s (%s)", cmdparams->channel->name, cmdparams->param);
|
||||
} else {
|
||||
ircsnprintf(tmpmsg, 512, "%s", cmdparams->channel->name);
|
||||
}
|
||||
addseenentry(cmdparams->source->name, cmdparams->source->user->username, cmdparams->source->user->hostname, cmdparams->source->user->vhost, tmpmsg, SS_PART);
|
||||
return NS_SUCCESS;
|
||||
}
|
||||
|
||||
/*
|
||||
* Kick Events
|
||||
*/
|
||||
int SeenKicked (CmdParams *cmdparams) {
|
||||
char tmpmsg[512];
|
||||
|
||||
if (is_hidden_chan(cmdparams->channel)) {
|
||||
return NS_SUCCESS;
|
||||
}
|
||||
ircsnprintf(tmpmsg, 512, "%s by %s (%s)", cmdparams->channel->name, cmdparams->source->name, cmdparams->param);
|
||||
addseenentry(cmdparams->target->name, cmdparams->target->user->username, cmdparams->target->user->hostname, cmdparams->target->user->vhost, tmpmsg, SS_KICKED);
|
||||
return NS_SUCCESS;
|
||||
}
|
251
install-sh
Normal file
251
install-sh
Normal file
|
@ -0,0 +1,251 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# install - install a program, script, or datafile
|
||||
# This comes from X11R5 (mit/util/scripts/install.sh).
|
||||
#
|
||||
# Copyright 1991 by the Massachusetts Institute of Technology
|
||||
#
|
||||
# Permission to use, copy, modify, distribute, and sell this software and its
|
||||
# documentation for any purpose is hereby granted without fee, provided that
|
||||
# the above copyright notice appear in all copies and that both that
|
||||
# copyright notice and this permission notice appear in supporting
|
||||
# documentation, and that the name of M.I.T. not be used in advertising or
|
||||
# publicity pertaining to distribution of the software without specific,
|
||||
# written prior permission. M.I.T. makes no representations about the
|
||||
# suitability of this software for any purpose. It is provided "as is"
|
||||
# without express or implied warranty.
|
||||
#
|
||||
# Calling this script install-sh is preferred over install.sh, to prevent
|
||||
# `make' implicit rules from creating a file called install from it
|
||||
# when there is no Makefile.
|
||||
#
|
||||
# This script is compatible with the BSD install script, but was written
|
||||
# from scratch. It can only install one file at a time, a restriction
|
||||
# shared with many OS's install programs.
|
||||
|
||||
|
||||
# set DOITPROG to echo to test this script
|
||||
|
||||
# Don't use :- since 4.3BSD and earlier shells don't like it.
|
||||
doit="${DOITPROG-}"
|
||||
|
||||
|
||||
# put in absolute paths if you don't have them in your path; or use env. vars.
|
||||
|
||||
mvprog="${MVPROG-mv}"
|
||||
cpprog="${CPPROG-cp}"
|
||||
chmodprog="${CHMODPROG-chmod}"
|
||||
chownprog="${CHOWNPROG-chown}"
|
||||
chgrpprog="${CHGRPPROG-chgrp}"
|
||||
stripprog="${STRIPPROG-strip}"
|
||||
rmprog="${RMPROG-rm}"
|
||||
mkdirprog="${MKDIRPROG-mkdir}"
|
||||
|
||||
transformbasename=""
|
||||
transform_arg=""
|
||||
instcmd="$mvprog"
|
||||
chmodcmd="$chmodprog 0755"
|
||||
chowncmd=""
|
||||
chgrpcmd=""
|
||||
stripcmd=""
|
||||
rmcmd="$rmprog -f"
|
||||
mvcmd="$mvprog"
|
||||
src=""
|
||||
dst=""
|
||||
dir_arg=""
|
||||
|
||||
while [ x"$1" != x ]; do
|
||||
case $1 in
|
||||
-c) instcmd="$cpprog"
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-d) dir_arg=true
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-m) chmodcmd="$chmodprog $2"
|
||||
shift
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-o) chowncmd="$chownprog $2"
|
||||
shift
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-g) chgrpcmd="$chgrpprog $2"
|
||||
shift
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-s) stripcmd="$stripprog"
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-t=*) transformarg=`echo $1 | sed 's/-t=//'`
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-b=*) transformbasename=`echo $1 | sed 's/-b=//'`
|
||||
shift
|
||||
continue;;
|
||||
|
||||
*) if [ x"$src" = x ]
|
||||
then
|
||||
src=$1
|
||||
else
|
||||
# this colon is to work around a 386BSD /bin/sh bug
|
||||
:
|
||||
dst=$1
|
||||
fi
|
||||
shift
|
||||
continue;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ x"$src" = x ]
|
||||
then
|
||||
echo "install: no input file specified"
|
||||
exit 1
|
||||
else
|
||||
true
|
||||
fi
|
||||
|
||||
if [ x"$dir_arg" != x ]; then
|
||||
dst=$src
|
||||
src=""
|
||||
|
||||
if [ -d $dst ]; then
|
||||
instcmd=:
|
||||
chmodcmd=""
|
||||
else
|
||||
instcmd=mkdir
|
||||
fi
|
||||
else
|
||||
|
||||
# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
|
||||
# might cause directories to be created, which would be especially bad
|
||||
# if $src (and thus $dsttmp) contains '*'.
|
||||
|
||||
if [ -f $src -o -d $src ]
|
||||
then
|
||||
true
|
||||
else
|
||||
echo "install: $src does not exist"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ x"$dst" = x ]
|
||||
then
|
||||
echo "install: no destination specified"
|
||||
exit 1
|
||||
else
|
||||
true
|
||||
fi
|
||||
|
||||
# If destination is a directory, append the input filename; if your system
|
||||
# does not like double slashes in filenames, you may need to add some logic
|
||||
|
||||
if [ -d $dst ]
|
||||
then
|
||||
dst="$dst"/`basename $src`
|
||||
else
|
||||
true
|
||||
fi
|
||||
fi
|
||||
|
||||
## this sed command emulates the dirname command
|
||||
dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
|
||||
|
||||
# Make sure that the destination directory exists.
|
||||
# this part is taken from Noah Friedman's mkinstalldirs script
|
||||
|
||||
# Skip lots of stat calls in the usual case.
|
||||
if [ ! -d "$dstdir" ]; then
|
||||
defaultIFS='
|
||||
'
|
||||
IFS="${IFS-${defaultIFS}}"
|
||||
|
||||
oIFS="${IFS}"
|
||||
# Some sh's can't handle IFS=/ for some reason.
|
||||
IFS='%'
|
||||
set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
|
||||
IFS="${oIFS}"
|
||||
|
||||
pathcomp=''
|
||||
|
||||
while [ $# -ne 0 ] ; do
|
||||
pathcomp="${pathcomp}${1}"
|
||||
shift
|
||||
|
||||
if [ ! -d "${pathcomp}" ] ;
|
||||
then
|
||||
$mkdirprog "${pathcomp}"
|
||||
else
|
||||
true
|
||||
fi
|
||||
|
||||
pathcomp="${pathcomp}/"
|
||||
done
|
||||
fi
|
||||
|
||||
if [ x"$dir_arg" != x ]
|
||||
then
|
||||
$doit $instcmd $dst &&
|
||||
|
||||
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi &&
|
||||
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi &&
|
||||
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi &&
|
||||
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi
|
||||
else
|
||||
|
||||
# If we're going to rename the final executable, determine the name now.
|
||||
|
||||
if [ x"$transformarg" = x ]
|
||||
then
|
||||
dstfile=`basename $dst`
|
||||
else
|
||||
dstfile=`basename $dst $transformbasename |
|
||||
sed $transformarg`$transformbasename
|
||||
fi
|
||||
|
||||
# don't allow the sed command to completely eliminate the filename
|
||||
|
||||
if [ x"$dstfile" = x ]
|
||||
then
|
||||
dstfile=`basename $dst`
|
||||
else
|
||||
true
|
||||
fi
|
||||
|
||||
# Make a temp file name in the proper directory.
|
||||
|
||||
dsttmp=$dstdir/#inst.$$#
|
||||
|
||||
# Move or copy the file name to the temp name
|
||||
|
||||
$doit $instcmd $src $dsttmp &&
|
||||
|
||||
trap "rm -f ${dsttmp}" 0 &&
|
||||
|
||||
# and set any options; do chmod last to preserve setuid bits
|
||||
|
||||
# If any of these fail, we abort the whole thing. If we want to
|
||||
# ignore errors from any of these, just make sure not to ignore
|
||||
# errors from the above "$doit $instcmd $src $dsttmp" command.
|
||||
|
||||
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi &&
|
||||
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi &&
|
||||
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi &&
|
||||
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi &&
|
||||
|
||||
# Now rename the file to the real destination.
|
||||
|
||||
$doit $rmcmd -f $dstdir/$dstfile &&
|
||||
$doit $mvcmd $dsttmp $dstdir/$dstfile
|
||||
|
||||
fi &&
|
||||
|
||||
|
||||
exit 0
|
14
modconfig.h.in
Normal file
14
modconfig.h.in
Normal file
|
@ -0,0 +1,14 @@
|
|||
/* define this to enable debug code for this module */
|
||||
#undef DEBUG
|
||||
|
||||
/* Version number of package */
|
||||
#undef MODULE_VERSION
|
||||
|
||||
/* Major Version */
|
||||
#undef MODULE_MAJOR
|
||||
|
||||
/* Minor Version */
|
||||
#undef MODULE_MINOR
|
||||
|
||||
/* Revision */
|
||||
#undef MODULE_REV
|
542
seen.c
Normal file
542
seen.c
Normal file
|
@ -0,0 +1,542 @@
|
|||
/* SeenServ - Nickname Seen Service - NeoStats Addon Module
|
||||
** Copyright (c) 2004-2005 DeadNotBuried
|
||||
** Portions Copyright (c) 1999-2005, NeoStats
|
||||
**
|
||||
** This program is free software; you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
** the Free Software Foundation; either version 2 of the License, or
|
||||
** (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program; if not, write to the Free Software
|
||||
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
** USA
|
||||
**
|
||||
** SeenServ CVS Identification
|
||||
** $Id$
|
||||
*/
|
||||
|
||||
#include "neostats.h" /* Required for bot support */
|
||||
#include "seenserv.h"
|
||||
|
||||
static list_t *seenlist;
|
||||
|
||||
/*
|
||||
* add new seen entry to list
|
||||
*/
|
||||
void addseenentry(char *nick, char *user, char *host, char *vhost, char *message, int type) {
|
||||
SeenData *sd;
|
||||
|
||||
removepreviousnick(nick);
|
||||
sd = ns_calloc(sizeof(SeenData));
|
||||
strlcpy(sd->nick, nick, MAXNICK);
|
||||
ircsnprintf(sd->userhost, 512, "%s!%s@%s", nick, user, host);
|
||||
ircsnprintf(sd->uservhost, 512, "%s!%s@%s", nick, user, vhost);
|
||||
strlcpy(sd->message, message, BUFSIZE);
|
||||
sd->seentype = type;
|
||||
sd->seentime = me.now;
|
||||
lnode_create_append( seenlist, sd );
|
||||
DBAStore( "seendata", sd->nick,( void * )sd, sizeof( SeenData ) );
|
||||
checkseenlistlimit();
|
||||
}
|
||||
|
||||
/*
|
||||
* Removes SeenData if records past max entries setting
|
||||
*/
|
||||
void checkseenlistlimit(void) {
|
||||
lnode_t *ln;
|
||||
SeenData *sd;
|
||||
|
||||
while (list_count(seenlist) > SeenServ.maxseenentries) {
|
||||
ln = list_first(seenlist);
|
||||
sd = lnode_get(ln);
|
||||
DBADelete( "seendata", sd->nick);
|
||||
ns_free(sd);
|
||||
list_delete(seenlist, ln);
|
||||
lnode_destroy(ln);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Removes SeenData for nickname if exists
|
||||
*/
|
||||
void removepreviousnick(char *nn) {
|
||||
lnode_t *ln;
|
||||
SeenData *sd;
|
||||
|
||||
ln = list_first(seenlist);
|
||||
while (ln != NULL) {
|
||||
sd = lnode_get(ln);
|
||||
if (!ircstrcasecmp(sd->nick, nn)) {
|
||||
DBADelete( "seendata", sd->nick);
|
||||
ns_free(sd);
|
||||
list_delete(seenlist, ln);
|
||||
lnode_destroy(ln);
|
||||
break;
|
||||
} else {
|
||||
ln = list_next(seenlist, ln);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Load Saved Seen Records
|
||||
*/
|
||||
void loadseendata(void) {
|
||||
seenlist = list_create( -1 );
|
||||
DBAFetchRows( "seendata", loadseenrecords );
|
||||
list_sort( seenlist, sortlistbytime );
|
||||
}
|
||||
int loadseenrecords(void *data)
|
||||
{
|
||||
SeenData *sd;
|
||||
|
||||
sd = ns_calloc( sizeof( SeenData ) );
|
||||
os_memcpy( sd, data, sizeof( SeenData ) );
|
||||
lnode_create_append( seenlist, sd );
|
||||
return NS_FALSE;
|
||||
}
|
||||
int sortlistbytime( const void *key1, const void *key2 )
|
||||
{
|
||||
const SeenData *sd1 = key1;
|
||||
const SeenData *sd2 = key2;
|
||||
return (sd1->seentime - sd2->seentime);
|
||||
}
|
||||
|
||||
/*
|
||||
* Destroy Seen List
|
||||
*/
|
||||
void destroyseenlist(void) {
|
||||
list_destroy_auto(seenlist);
|
||||
}
|
||||
|
||||
/*
|
||||
* Seen for wildcarded Host
|
||||
*/
|
||||
int sns_cmd_seenhost(CmdParams *cmdparams) {
|
||||
lnode_t *ln;
|
||||
SeenData *sd;
|
||||
Client *u;
|
||||
int d, h, m, s;
|
||||
char ttxt[4][12];
|
||||
char th[512];
|
||||
char dt[128];
|
||||
char matchstr[512];
|
||||
|
||||
if (!SeenServ.enable && cmdparams->channel == NULL) {
|
||||
return NS_SUCCESS;
|
||||
}
|
||||
if (!SeenServ.enableseenchan && cmdparams->channel != NULL) {
|
||||
return NS_SUCCESS;
|
||||
}
|
||||
for ( d = 0 ; d < 4 ; d++ ) {
|
||||
ttxt[d][0] = '\0';
|
||||
}
|
||||
h = m = s = 0;
|
||||
if (!strchr(cmdparams->av[0], '*') == NULL) {
|
||||
ircsnprintf(matchstr, 512, "%s", cmdparams->av[0]);
|
||||
} else {
|
||||
ircsnprintf(matchstr, 512, "*%s*", cmdparams->av[0]);
|
||||
}
|
||||
|
||||
ln = list_last(seenlist);
|
||||
while (ln != NULL) {
|
||||
sd = lnode_get(ln);
|
||||
if ((match(matchstr, sd->userhost) && cmdparams->source->user->ulevel >= NS_ULEVEL_LOCOPER) || match(matchstr, sd->uservhost) ) {
|
||||
d = (me.now - sd->seentime);
|
||||
if (d) {
|
||||
s = (d % 60);
|
||||
if (s) {
|
||||
ircsnprintf(ttxt[3], 12, "%d Seconds", s);
|
||||
d -= s;
|
||||
}
|
||||
d = (d / 60);
|
||||
}
|
||||
if (d) {
|
||||
m = (d % 60);
|
||||
if (m) {
|
||||
ircsnprintf(ttxt[2], 12, "%d Minutes", m);
|
||||
d -= m;
|
||||
}
|
||||
d = (d / 60);
|
||||
}
|
||||
if (d) {
|
||||
h = (d % 24);
|
||||
if (h) {
|
||||
ircsnprintf(ttxt[1], 12, "%d Hours", h);
|
||||
d -= h;
|
||||
}
|
||||
d = (d / 24);
|
||||
}
|
||||
if (d) {
|
||||
ircsnprintf(ttxt[0], 12, "%d Days", d);
|
||||
}
|
||||
if (d) {
|
||||
ircsnprintf(dt, 128, "%s %s %s %s", ttxt[0], ttxt[1], ttxt[2], ttxt[3]);
|
||||
} else if (h) {
|
||||
ircsnprintf(dt, 128, "%s %s %s", ttxt[1], ttxt[2], ttxt[3]);
|
||||
} else if (m) {
|
||||
ircsnprintf(dt, 128, "%s %s", ttxt[2], ttxt[3]);
|
||||
} else {
|
||||
ircsnprintf(dt, 128, "%s", ttxt[3]);
|
||||
}
|
||||
if ( sd->seentype == SS_CONNECTED ) {
|
||||
u = FindUser(sd->nick);
|
||||
if (u) {
|
||||
ircsnprintf(th, 512, "%s!%s@%s", u->name, u->user->username, u->user->hostname);
|
||||
if (!ircstrcasecmp(sd->userhost, th)) {
|
||||
if (cmdparams->source->user->ulevel >= NS_ULEVEL_LOCOPER && cmdparams->channel == NULL) {
|
||||
irc_prefmsg (sns_bot, cmdparams->source, "%s was last seen connecting %s ago, and is still connected", sd->userhost, dt);
|
||||
} else {
|
||||
if (cmdparams->channel == NULL) {
|
||||
irc_prefmsg (sns_bot, cmdparams->source, "%s was last seen connecting %s ago, and is still connected", sd->uservhost, dt);
|
||||
} else {
|
||||
irc_chanprivmsg (sns_bot, cmdparams->channel->name, "%s was last seen connecting %s ago, and is still connected", sd->uservhost, dt);
|
||||
}
|
||||
}
|
||||
return NS_SUCCESS;
|
||||
}
|
||||
}
|
||||
if (cmdparams->source->user->ulevel >= NS_ULEVEL_LOCOPER && cmdparams->channel == NULL) {
|
||||
irc_prefmsg (sns_bot, cmdparams->source, "%s was last seen connecting %s ago", sd->userhost, dt);
|
||||
} else {
|
||||
if (cmdparams->channel == NULL) {
|
||||
irc_prefmsg (sns_bot, cmdparams->source, "%s was last seen connecting %s ago", sd->uservhost, dt);
|
||||
} else {
|
||||
irc_chanprivmsg (sns_bot, cmdparams->channel->name, "%s was last seen connecting %s ago", sd->uservhost, dt);
|
||||
}
|
||||
}
|
||||
return NS_SUCCESS;
|
||||
} else if ( sd->seentype == SS_QUIT ) {
|
||||
if (cmdparams->source->user->ulevel >= NS_ULEVEL_LOCOPER && cmdparams->channel == NULL) {
|
||||
irc_prefmsg (sns_bot, cmdparams->source, "%s was last seen quiting %s ago, stating %s", sd->userhost, dt, sd->message);
|
||||
} else {
|
||||
if (cmdparams->channel == NULL) {
|
||||
irc_prefmsg (sns_bot, cmdparams->source, "%s was last seen quiting %s ago, stating %s", sd->uservhost, dt, sd->message);
|
||||
} else {
|
||||
irc_chanprivmsg (sns_bot, cmdparams->channel->name, "%s was last seen quiting %s ago, stating %s", sd->uservhost, dt, sd->message);
|
||||
}
|
||||
}
|
||||
return NS_SUCCESS;
|
||||
} else if ( sd->seentype == SS_KILLED ) {
|
||||
if (cmdparams->source->user->ulevel >= NS_ULEVEL_LOCOPER && cmdparams->channel == NULL) {
|
||||
irc_prefmsg (sns_bot, cmdparams->source, "%s was last seen being killed %s ago %s", sd->userhost, dt, sd->message);
|
||||
} else {
|
||||
if (cmdparams->channel == NULL) {
|
||||
irc_prefmsg (sns_bot, cmdparams->source, "%s was last seen being killed %s ago %s", sd->uservhost, dt, sd->message);
|
||||
} else {
|
||||
irc_chanprivmsg (sns_bot, cmdparams->channel->name, "%s was last seen being killed %s ago %s", sd->uservhost, dt, sd->message);
|
||||
}
|
||||
}
|
||||
return NS_SUCCESS;
|
||||
} else if ( sd->seentype == SS_NICKCHANGE ) {
|
||||
if (cmdparams->source->user->ulevel >= NS_ULEVEL_LOCOPER && cmdparams->channel == NULL) {
|
||||
irc_prefmsg (sns_bot, cmdparams->source, "%s was last seen changing Nickname %s ago %s", sd->userhost, dt, sd->message);
|
||||
} else {
|
||||
if (cmdparams->channel == NULL) {
|
||||
irc_prefmsg (sns_bot, cmdparams->source, "%s was last seen changing Nickname %s ago %s", sd->uservhost, dt, sd->message);
|
||||
} else {
|
||||
irc_chanprivmsg (sns_bot, cmdparams->channel->name, "%s was last seen changing Nickname %s ago %s", sd->uservhost, dt, sd->message);
|
||||
}
|
||||
}
|
||||
return NS_SUCCESS;
|
||||
} else if ( sd->seentype == SS_JOIN ) {
|
||||
if (cmdparams->source->user->ulevel >= NS_ULEVEL_LOCOPER && cmdparams->channel == NULL) {
|
||||
irc_prefmsg (sns_bot, cmdparams->source, "%s was last seen Joining %s %s ago", sd->userhost, sd->message, dt);
|
||||
} else {
|
||||
if (cmdparams->channel == NULL) {
|
||||
irc_prefmsg (sns_bot, cmdparams->source, "%s was last seen Joining %s %s ago", sd->uservhost, sd->message, dt);
|
||||
} else {
|
||||
irc_chanprivmsg (sns_bot, cmdparams->channel->name, "%s was last seen Joining %s %s ago", sd->uservhost, sd->message, dt);
|
||||
}
|
||||
}
|
||||
return NS_SUCCESS;
|
||||
} else if ( sd->seentype == SS_PART ) {
|
||||
if (cmdparams->source->user->ulevel >= NS_ULEVEL_LOCOPER && cmdparams->channel == NULL) {
|
||||
irc_prefmsg (sns_bot, cmdparams->source, "%s was last seen Parting %s %s ago", sd->userhost, sd->message, dt);
|
||||
} else {
|
||||
if (cmdparams->channel == NULL) {
|
||||
irc_prefmsg (sns_bot, cmdparams->source, "%s was last seen Parting %s %s", sd->uservhost, sd->message, dt);
|
||||
} else {
|
||||
irc_chanprivmsg (sns_bot, cmdparams->channel->name, "%s was last seen Parting %s %s", sd->uservhost, sd->message, dt);
|
||||
}
|
||||
}
|
||||
return NS_SUCCESS;
|
||||
} else if ( sd->seentype == SS_KICKED ) {
|
||||
if (cmdparams->source->user->ulevel >= NS_ULEVEL_LOCOPER && cmdparams->channel == NULL) {
|
||||
irc_prefmsg (sns_bot, cmdparams->source, "%s was last seen being Kicked From %s %s ago", sd->userhost, sd->message, dt);
|
||||
} else {
|
||||
if (cmdparams->channel == NULL) {
|
||||
irc_prefmsg (sns_bot, cmdparams->source, "%s was last seen Kicked From %s %s", sd->uservhost, sd->message, dt);
|
||||
} else {
|
||||
irc_chanprivmsg (sns_bot, cmdparams->channel->name, "%s was last seen Kicked From %s %s", sd->uservhost, sd->message, dt);
|
||||
}
|
||||
}
|
||||
return NS_SUCCESS;
|
||||
}
|
||||
} else {
|
||||
ln = list_prev(seenlist, ln);
|
||||
}
|
||||
}
|
||||
if (cmdparams->channel == NULL) {
|
||||
irc_prefmsg (sns_bot, cmdparams->source, "Sorry %s, I can't remember seeing anyone matching that mask (%s)", cmdparams->source->name, matchstr);
|
||||
} else {
|
||||
irc_chanprivmsg (sns_bot, cmdparams->channel->name, "Sorry %s, I can't remember seeing anyone matching that mask (%s)", cmdparams->source->name, matchstr);
|
||||
}
|
||||
return NS_SUCCESS;
|
||||
}
|
||||
|
||||
/*
|
||||
* Seen for valid nickname
|
||||
*/
|
||||
int sns_cmd_seennick(CmdParams *cmdparams) {
|
||||
lnode_t *ln;
|
||||
SeenData *sd;
|
||||
Client *u;
|
||||
int d, h, m, s;
|
||||
char ttxt[4][12];
|
||||
char th[512];
|
||||
char dt[128];
|
||||
|
||||
if (!SeenServ.enable && cmdparams->channel == NULL) {
|
||||
return NS_SUCCESS;
|
||||
}
|
||||
if (!SeenServ.enableseenchan && cmdparams->channel != NULL) {
|
||||
return NS_SUCCESS;
|
||||
}
|
||||
if (ValidateNick(cmdparams->av[0]) == NS_FAILURE) {
|
||||
if (cmdparams->channel == NULL) {
|
||||
irc_prefmsg (sns_bot, cmdparams->source, "%s is not a valid nickname", cmdparams->av[0]);
|
||||
} else {
|
||||
irc_chanprivmsg (sns_bot, cmdparams->channel->name, "%s is not a valid nickname", cmdparams->av[0]);
|
||||
}
|
||||
return NS_SUCCESS;
|
||||
}
|
||||
for ( d = 0 ; d < 4 ; d++ ) {
|
||||
ttxt[d][0] = '\0';
|
||||
}
|
||||
h = m = s = 0;
|
||||
ln = list_last(seenlist);
|
||||
while (ln != NULL) {
|
||||
sd = lnode_get(ln);
|
||||
if (!ircstrcasecmp(cmdparams->av[0], sd->nick)) {
|
||||
d = (me.now - sd->seentime);
|
||||
if (d) {
|
||||
s = (d % 60);
|
||||
if (s) {
|
||||
ircsnprintf(ttxt[3], 12, "%d Seconds", s);
|
||||
d -= s;
|
||||
}
|
||||
d = (d / 60);
|
||||
}
|
||||
if (d) {
|
||||
m = (d % 60);
|
||||
if (m) {
|
||||
ircsnprintf(ttxt[2], 12, "%d Minutes", m);
|
||||
d -= m;
|
||||
}
|
||||
d = (d / 60);
|
||||
}
|
||||
if (d) {
|
||||
h = (d % 24);
|
||||
if (h) {
|
||||
ircsnprintf(ttxt[1], 12, "%d Hours", h);
|
||||
d -= h;
|
||||
}
|
||||
d = (d / 24);
|
||||
}
|
||||
if (d) {
|
||||
ircsnprintf(ttxt[0], 12, "%d Days", d);
|
||||
}
|
||||
if (d) {
|
||||
ircsnprintf(dt, 128, "%s %s %s %s", ttxt[0], ttxt[1], ttxt[2], ttxt[3]);
|
||||
} else if (h) {
|
||||
ircsnprintf(dt, 128, "%s %s %s", ttxt[1], ttxt[2], ttxt[3]);
|
||||
} else if (m) {
|
||||
ircsnprintf(dt, 128, "%s %s", ttxt[2], ttxt[3]);
|
||||
} else {
|
||||
ircsnprintf(dt, 128, "%s", ttxt[3]);
|
||||
}
|
||||
if ( sd->seentype == SS_CONNECTED ) {
|
||||
u = FindUser(sd->nick);
|
||||
if (u) {
|
||||
ircsnprintf(th, 512, "%s!%s@%s", u->name, u->user->username, u->user->hostname);
|
||||
if (!ircstrcasecmp(sd->userhost, th)) {
|
||||
if (cmdparams->source->user->ulevel >= NS_ULEVEL_LOCOPER && cmdparams->channel == NULL) {
|
||||
irc_prefmsg (sns_bot, cmdparams->source, "%s was last seen connecting %s ago, and is still connected", sd->userhost, dt);
|
||||
} else {
|
||||
if (cmdparams->channel == NULL) {
|
||||
irc_prefmsg (sns_bot, cmdparams->source, "%s was last seen connecting %s ago, and is still connected", sd->uservhost, dt);
|
||||
} else {
|
||||
irc_chanprivmsg (sns_bot, cmdparams->channel->name, "%s was last seen connecting %s ago, and is still connected", sd->uservhost, dt);
|
||||
}
|
||||
}
|
||||
return NS_SUCCESS;
|
||||
}
|
||||
}
|
||||
if (cmdparams->source->user->ulevel >= NS_ULEVEL_LOCOPER && cmdparams->channel == NULL) {
|
||||
irc_prefmsg (sns_bot, cmdparams->source, "%s was last seen connecting %s ago", sd->userhost, dt);
|
||||
} else {
|
||||
if (cmdparams->channel == NULL) {
|
||||
irc_prefmsg (sns_bot, cmdparams->source, "%s was last seen connecting %s ago", sd->uservhost, dt);
|
||||
} else {
|
||||
irc_chanprivmsg (sns_bot, cmdparams->channel->name, "%s was last seen connecting %s ago", sd->uservhost, dt);
|
||||
}
|
||||
}
|
||||
return NS_SUCCESS;
|
||||
} else if ( sd->seentype == SS_QUIT ) {
|
||||
if (cmdparams->source->user->ulevel >= NS_ULEVEL_LOCOPER && cmdparams->channel == NULL) {
|
||||
irc_prefmsg (sns_bot, cmdparams->source, "%s was last seen quiting %s ago, stating %s", sd->userhost, dt, sd->message);
|
||||
} else {
|
||||
if (cmdparams->channel == NULL) {
|
||||
irc_prefmsg (sns_bot, cmdparams->source, "%s was last seen quiting %s ago, stating %s", sd->uservhost, dt, sd->message);
|
||||
} else {
|
||||
irc_chanprivmsg (sns_bot, cmdparams->channel->name, "%s was last seen quiting %s ago, stating %s", sd->uservhost, dt, sd->message);
|
||||
}
|
||||
}
|
||||
return NS_SUCCESS;
|
||||
} else if ( sd->seentype == SS_KILLED ) {
|
||||
if (cmdparams->source->user->ulevel >= NS_ULEVEL_LOCOPER && cmdparams->channel == NULL) {
|
||||
irc_prefmsg (sns_bot, cmdparams->source, "%s was last seen being killed %s ago %s", sd->userhost, dt, sd->message);
|
||||
} else {
|
||||
if (cmdparams->channel == NULL) {
|
||||
irc_prefmsg (sns_bot, cmdparams->source, "%s was last seen being killed %s ago %s", sd->uservhost, dt, sd->message);
|
||||
} else {
|
||||
irc_chanprivmsg (sns_bot, cmdparams->channel->name, "%s was last seen being killed %s ago %s", sd->uservhost, dt, sd->message);
|
||||
}
|
||||
}
|
||||
return NS_SUCCESS;
|
||||
} else if ( sd->seentype == SS_NICKCHANGE ) {
|
||||
if (cmdparams->source->user->ulevel >= NS_ULEVEL_LOCOPER && cmdparams->channel == NULL) {
|
||||
irc_prefmsg (sns_bot, cmdparams->source, "%s was last seen changing Nickname %s ago %s", sd->userhost, dt, sd->message);
|
||||
} else {
|
||||
if (cmdparams->channel == NULL) {
|
||||
irc_prefmsg (sns_bot, cmdparams->source, "%s was last seen changing Nickname %s ago %s", sd->uservhost, dt, sd->message);
|
||||
} else {
|
||||
irc_chanprivmsg (sns_bot, cmdparams->channel->name, "%s was last seen changing Nickname %s ago %s", sd->uservhost, dt, sd->message);
|
||||
}
|
||||
}
|
||||
return NS_SUCCESS;
|
||||
} else if ( sd->seentype == SS_JOIN ) {
|
||||
if (cmdparams->source->user->ulevel >= NS_ULEVEL_LOCOPER && cmdparams->channel == NULL) {
|
||||
irc_prefmsg (sns_bot, cmdparams->source, "%s was last seen Joining %s %s ago", sd->userhost, sd->message, dt);
|
||||
} else {
|
||||
if (cmdparams->channel == NULL) {
|
||||
irc_prefmsg (sns_bot, cmdparams->source, "%s was last seen Joining %s %s ago", sd->uservhost, sd->message, dt);
|
||||
} else {
|
||||
irc_chanprivmsg (sns_bot, cmdparams->channel->name, "%s was last seen Joining %s %s ago", sd->uservhost, sd->message, dt);
|
||||
}
|
||||
}
|
||||
return NS_SUCCESS;
|
||||
} else if ( sd->seentype == SS_PART ) {
|
||||
if (cmdparams->source->user->ulevel >= NS_ULEVEL_LOCOPER && cmdparams->channel == NULL) {
|
||||
irc_prefmsg (sns_bot, cmdparams->source, "%s was last seen Parting %s %s ago", sd->userhost, sd->message, dt);
|
||||
} else {
|
||||
if (cmdparams->channel == NULL) {
|
||||
irc_prefmsg (sns_bot, cmdparams->source, "%s was last seen Parting %s %s", sd->uservhost, sd->message, dt);
|
||||
} else {
|
||||
irc_chanprivmsg (sns_bot, cmdparams->channel->name, "%s was last seen Parting %s %s", sd->uservhost, sd->message, dt);
|
||||
}
|
||||
}
|
||||
return NS_SUCCESS;
|
||||
} else if ( sd->seentype == SS_KICKED ) {
|
||||
if (cmdparams->source->user->ulevel >= NS_ULEVEL_LOCOPER && cmdparams->channel == NULL) {
|
||||
irc_prefmsg (sns_bot, cmdparams->source, "%s was last seen being Kicked From %s %s ago", sd->userhost, sd->message, dt);
|
||||
} else {
|
||||
if (cmdparams->channel == NULL) {
|
||||
irc_prefmsg (sns_bot, cmdparams->source, "%s was last seen Kicked From %s %s", sd->uservhost, sd->message, dt);
|
||||
} else {
|
||||
irc_chanprivmsg (sns_bot, cmdparams->channel->name, "%s was last seen Kicked From %s %s", sd->uservhost, sd->message, dt);
|
||||
}
|
||||
}
|
||||
return NS_SUCCESS;
|
||||
}
|
||||
} else {
|
||||
ln = list_prev(seenlist, ln);
|
||||
}
|
||||
}
|
||||
if (cmdparams->channel == NULL) {
|
||||
irc_prefmsg (sns_bot, cmdparams->source, "Sorry %s, I can't remember seeing anyone called %s", cmdparams->source->name, cmdparams->av[0]);
|
||||
} else {
|
||||
irc_chanprivmsg (sns_bot, cmdparams->channel->name, "Sorry %s, I can't remember seeing anyone called %s", cmdparams->source->name, cmdparams->av[0]);
|
||||
}
|
||||
return NS_SUCCESS;
|
||||
}
|
||||
|
||||
/*
|
||||
* Remove all matching entries
|
||||
*/
|
||||
int sns_cmd_remove(CmdParams *cmdparams) {
|
||||
lnode_t *ln, *ln2;
|
||||
SeenData *sd;
|
||||
int i;
|
||||
|
||||
i = 0;
|
||||
ln = list_first(seenlist);
|
||||
while (ln != NULL) {
|
||||
sd = lnode_get(ln);
|
||||
if (match(cmdparams->av[0], sd->userhost) || match(cmdparams->av[0], sd->uservhost)) {
|
||||
i++;
|
||||
ns_free(sd);
|
||||
ln2 = list_next(seenlist, ln);
|
||||
list_delete(seenlist, ln);
|
||||
lnode_destroy(ln);
|
||||
ln = ln2;
|
||||
} else {
|
||||
ln = list_next(seenlist, ln);
|
||||
}
|
||||
}
|
||||
if (cmdparams->channel == NULL) {
|
||||
irc_prefmsg (sns_bot, cmdparams->source, "%d matching entries removed", i);
|
||||
} else {
|
||||
irc_chanprivmsg (sns_bot, cmdparams->channel->name, "%d matching entries removed", i);
|
||||
}
|
||||
return NS_SUCCESS;
|
||||
}
|
||||
|
||||
/*
|
||||
* Display Seen Statistics
|
||||
*/
|
||||
int sns_cmd_stats(CmdParams *cmdparams) {
|
||||
lnode_t *ln;
|
||||
SeenData *sd;
|
||||
int sc[10], i;
|
||||
|
||||
for ( i = 0 ; i < 10 ; i++ ) {
|
||||
sc[i] = 0;
|
||||
}
|
||||
ln = list_first(seenlist);
|
||||
while (ln != NULL) {
|
||||
sd = lnode_get(ln);
|
||||
sc[sd->seentype]++;
|
||||
ln = list_next(seenlist, ln);
|
||||
}
|
||||
if (cmdparams->channel == NULL) {
|
||||
irc_prefmsg (sns_bot, cmdparams->source, "Seen Statistics (Current Records Per Type)");
|
||||
irc_prefmsg (sns_bot, cmdparams->source, "%d Connections", sc[SS_CONNECTED]);
|
||||
irc_prefmsg (sns_bot, cmdparams->source, "%d Quits", sc[SS_QUIT]);
|
||||
irc_prefmsg (sns_bot, cmdparams->source, "%d Kills", sc[SS_KILLED]);
|
||||
irc_prefmsg (sns_bot, cmdparams->source, "%d Nick Changes", sc[SS_NICKCHANGE]);
|
||||
irc_prefmsg (sns_bot, cmdparams->source, "%d Channel Joins", sc[SS_JOIN]);
|
||||
irc_prefmsg (sns_bot, cmdparams->source, "%d Channel Parts", sc[SS_PART]);
|
||||
irc_prefmsg (sns_bot, cmdparams->source, "%d Channel Kicks", sc[SS_KICKED]);
|
||||
irc_prefmsg (sns_bot, cmdparams->source, "End Of Statistics");
|
||||
} else {
|
||||
irc_chanprivmsg (sns_bot, cmdparams->channel->name, "Stats command used");
|
||||
irc_chanprivmsg (sns_bot, cmdparams->channel->name, "Seen Statistics (Current Records Per Type)");
|
||||
irc_chanprivmsg (sns_bot, cmdparams->channel->name, "%d Connections", sc[SS_CONNECTED]);
|
||||
irc_chanprivmsg (sns_bot, cmdparams->channel->name, "%d Quits", sc[SS_QUIT]);
|
||||
irc_chanprivmsg (sns_bot, cmdparams->channel->name, "%d Kills", sc[SS_KILLED]);
|
||||
irc_chanprivmsg (sns_bot, cmdparams->channel->name, "%d Nick Changes", sc[SS_NICKCHANGE]);
|
||||
irc_chanprivmsg (sns_bot, cmdparams->channel->name, "%d Channel Joins", sc[SS_JOIN]);
|
||||
irc_chanprivmsg (sns_bot, cmdparams->channel->name, "%d Channel Parts", sc[SS_PART]);
|
||||
irc_chanprivmsg (sns_bot, cmdparams->channel->name, "%d Channel Kicks", sc[SS_KICKED]);
|
||||
irc_chanprivmsg (sns_bot, cmdparams->channel->name, "End Of Statistics");
|
||||
}
|
||||
return NS_SUCCESS;
|
||||
}
|
191
seenserv.c
Normal file
191
seenserv.c
Normal file
|
@ -0,0 +1,191 @@
|
|||
/* SeenServ - Nickname Seen Service - NeoStats Addon Module
|
||||
** Copyright (c) 2004-2005 DeadNotBuried
|
||||
** Portions Copyright (c) 1999-2005, NeoStats
|
||||
**
|
||||
** This program is free software; you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
** the Free Software Foundation; either version 2 of the License, or
|
||||
** (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program; if not, write to the Free Software
|
||||
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
** USA
|
||||
**
|
||||
** SeenServ CVS Identification
|
||||
** $Id$
|
||||
*/
|
||||
|
||||
#include "neostats.h" /* Required for bot support */
|
||||
#include "seenserv.h"
|
||||
|
||||
/** Copyright info */
|
||||
const char *sns_copyright[] = {
|
||||
"Copyright (c) 2004-2005 DeadNotBuried",
|
||||
"Portions Copyright (c) 1999-2005, NeoStats",
|
||||
NULL
|
||||
};
|
||||
|
||||
const char *sns_about[] = {
|
||||
"\2Seen Service\2",
|
||||
"",
|
||||
"Provides access to SEEN command to see when Users were connected.",
|
||||
NULL
|
||||
};
|
||||
|
||||
/*
|
||||
* Commands and Settings
|
||||
*/
|
||||
static bot_cmd sns_commands[]=
|
||||
{
|
||||
{"SEEN", sns_cmd_seenhost, 1, 0, sns_help_seen, sns_help_seen_oneline},
|
||||
{"SEENNICK", sns_cmd_seennick, 1, 0, sns_help_seennick, sns_help_seennick_oneline},
|
||||
{"REMOVE", sns_cmd_remove, 1, NS_ULEVEL_ADMIN, sns_help_remove, sns_help_remove_oneline},
|
||||
{"STATS", sns_cmd_stats, 0, NS_ULEVEL_LOCOPER, sns_help_stats, sns_help_stats_oneline},
|
||||
{NULL, NULL, 0, 0, NULL, NULL}
|
||||
};
|
||||
|
||||
static bot_setting sns_settings[]=
|
||||
{
|
||||
{"EXCLUSIONS", &SeenServ.exclusions, SET_TYPE_BOOLEAN, 0, 0, NS_ULEVEL_ADMIN, NULL, sns_help_set_exclusions, sns_set_exclusions, (void *)1 },
|
||||
{"ENABLE", &SeenServ.enable, SET_TYPE_BOOLEAN, 0, 0, NS_ULEVEL_ADMIN, NULL, sns_help_set_enable, NULL, (void *)0 },
|
||||
{"ENABLESEENCHAN", &SeenServ.enableseenchan, SET_TYPE_BOOLEAN, 0, 0, NS_ULEVEL_ADMIN, NULL, sns_help_set_enableseenchan, NULL, (void *)0 },
|
||||
{"SEENCHANNAME", &SeenServ.seenchan, SET_TYPE_CHANNEL, 0, MAXCHANLEN, NS_ULEVEL_ADMIN, NULL, sns_help_set_seenchan, sns_set_seenchan, (void *)"#Seen" },
|
||||
{"MAXSEENENTRIES", &SeenServ.maxseenentries, SET_TYPE_INT, 100, 100000, NS_ULEVEL_ADMIN, NULL, sns_help_set_maxentries, sns_set_maxentries, (void *)2000 },
|
||||
{NULL, NULL, 0, 0, 0, 0, NULL, NULL, NULL, NULL },
|
||||
};
|
||||
|
||||
/*
|
||||
* Module Info definition
|
||||
*/
|
||||
ModuleInfo module_info = {
|
||||
"SeenServ",
|
||||
"Seen Service Module For NeoStats",
|
||||
sns_copyright,
|
||||
sns_about,
|
||||
NEOSTATS_VERSION,
|
||||
"3.0",
|
||||
__DATE__,
|
||||
__TIME__,
|
||||
0,
|
||||
0,
|
||||
};
|
||||
|
||||
/*
|
||||
* Module event list
|
||||
*/
|
||||
ModuleEvent module_events[] = {
|
||||
{EVENT_SIGNON, SeenSignon, EVENT_FLAG_EXCLUDE_ME},
|
||||
{EVENT_NICKIP, SeenSignon, EVENT_FLAG_EXCLUDE_ME},
|
||||
{EVENT_QUIT, SeenQuit, EVENT_FLAG_EXCLUDE_ME},
|
||||
{EVENT_KILL, SeenKill, EVENT_FLAG_EXCLUDE_ME},
|
||||
{EVENT_LOCALKILL, SeenKill, EVENT_FLAG_EXCLUDE_ME},
|
||||
{EVENT_GLOBALKILL, SeenKill, EVENT_FLAG_EXCLUDE_ME},
|
||||
{EVENT_SERVERKILL, SeenKill, EVENT_FLAG_EXCLUDE_ME},
|
||||
{EVENT_NICK, SeenNickChange, EVENT_FLAG_EXCLUDE_ME},
|
||||
{EVENT_JOIN, SeenJoinChan, EVENT_FLAG_EXCLUDE_ME},
|
||||
{EVENT_PART, SeenPartChan, EVENT_FLAG_EXCLUDE_ME},
|
||||
{EVENT_KICK, SeenKicked, EVENT_FLAG_EXCLUDE_ME},
|
||||
{EVENT_NULL, NULL}
|
||||
};
|
||||
|
||||
/** BotInfo */
|
||||
static BotInfo sns_botinfo =
|
||||
{
|
||||
"SeenServ",
|
||||
"SeenServ1",
|
||||
"Seen",
|
||||
BOT_COMMON_HOST,
|
||||
"Seen Service",
|
||||
BOT_FLAG_SERVICEBOT|BOT_FLAG_PERSIST,
|
||||
sns_commands,
|
||||
sns_settings,
|
||||
};
|
||||
|
||||
/*
|
||||
* Online event processing
|
||||
*/
|
||||
int ModSynch (void)
|
||||
{
|
||||
/* Introduce a bot onto the network */
|
||||
sns_bot = AddBot (&sns_botinfo);
|
||||
if (!sns_bot) {
|
||||
return NS_FAILURE;
|
||||
}
|
||||
if (SeenServ.enableseenchan) {
|
||||
irc_join (sns_bot, SeenServ.seenchan, "+o");
|
||||
irc_chanalert (sns_bot, "Seen Channel Now Available in %s", SeenServ.seenchan);
|
||||
} else {
|
||||
irc_chanalert (sns_bot, "Seen Channel Not Enabled");
|
||||
}
|
||||
return NS_SUCCESS;
|
||||
};
|
||||
|
||||
/*
|
||||
* Init module
|
||||
*/
|
||||
int ModInit( void )
|
||||
{
|
||||
ModuleConfig (sns_settings);
|
||||
loadseendata();
|
||||
return NS_SUCCESS;
|
||||
}
|
||||
|
||||
/*
|
||||
* Exit module
|
||||
*/
|
||||
int ModFini( void )
|
||||
{
|
||||
destroyseenlist();
|
||||
return NS_SUCCESS;
|
||||
}
|
||||
|
||||
/*
|
||||
* Seen Channel Setting
|
||||
*/
|
||||
static int sns_set_seenchan (CmdParams *cmdparams, SET_REASON reason) {
|
||||
if (!SeenServ.enableseenchan) {
|
||||
return NS_SUCCESS;
|
||||
}
|
||||
if (reason == SET_VALIDATE) {
|
||||
irc_prefmsg (sns_bot, cmdparams->source, "Seen Channel changing from %s to %s", SeenServ.seenchan, cmdparams->av[1]);
|
||||
irc_chanalert (sns_bot, "Seen Channel Changing to %s , Parting %s (%s)", cmdparams->av[1], SeenServ.seenchan, cmdparams->source->name);
|
||||
irc_chanprivmsg (sns_bot, SeenServ.seenchan, "\0039%s has changed Channels, Seen functions will now be available in %s", cmdparams->source->name, cmdparams->av[1]);
|
||||
irc_part (sns_bot, SeenServ.seenchan, NULL);
|
||||
return NS_SUCCESS;
|
||||
}
|
||||
if (reason == SET_CHANGE) {
|
||||
irc_join (sns_bot, SeenServ.seenchan, "+o");
|
||||
irc_chanalert (sns_bot, "Seen functions now available in %s", SeenServ.seenchan);
|
||||
return NS_SUCCESS;
|
||||
}
|
||||
return NS_SUCCESS;
|
||||
}
|
||||
|
||||
/*
|
||||
* Change Max Entries Saved
|
||||
*/
|
||||
static int sns_set_maxentries (CmdParams *cmdparams, SET_REASON reason) {
|
||||
if (reason == SET_VALIDATE) {
|
||||
checkseenlistlimit();
|
||||
return NS_SUCCESS;
|
||||
}
|
||||
return NS_SUCCESS;
|
||||
}
|
||||
|
||||
/*
|
||||
* Enable/Disable Global Exclusions
|
||||
*/
|
||||
static int sns_set_exclusions( CmdParams *cmdparams, SET_REASON reason )
|
||||
{
|
||||
if( reason == SET_LOAD || reason == SET_CHANGE )
|
||||
{
|
||||
SetAllEventFlags( EVENT_FLAG_USE_EXCLUDE, SeenServ.exclusions );
|
||||
}
|
||||
return NS_SUCCESS;
|
||||
}
|
92
seenserv.h
Normal file
92
seenserv.h
Normal file
|
@ -0,0 +1,92 @@
|
|||
/* SeenServ - Nickname Seen Service - NeoStats Addon Module
|
||||
** Copyright (c) 2004-2005 DeadNotBuried
|
||||
** Portions Copyright (c) 1999-2005, NeoStats
|
||||
**
|
||||
** This program is free software; you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
** the Free Software Foundation; either version 2 of the License, or
|
||||
** (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program; if not, write to the Free Software
|
||||
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
** USA
|
||||
**
|
||||
** SeenServ CVS Identification
|
||||
** $Id$
|
||||
*/
|
||||
|
||||
Bot *sns_bot;
|
||||
|
||||
struct SeenServ {
|
||||
int exclusions;
|
||||
int enable;
|
||||
int enableseenchan;
|
||||
char seenchan[MAXCHANLEN];
|
||||
int maxseenentries;
|
||||
} SeenServ;
|
||||
|
||||
typedef struct SeenData {
|
||||
char nick[MAXNICK];
|
||||
char userhost[PARAMSIZE];
|
||||
char uservhost[PARAMSIZE];
|
||||
char message[BUFSIZE];
|
||||
int seentype;
|
||||
time_t seentime;
|
||||
} SeenData;
|
||||
|
||||
/* Defines */
|
||||
#define SS_CONNECTED 0x00000001 /* Seen Connection Type */
|
||||
#define SS_QUIT 0x00000002 /* Seen Quit Type */
|
||||
#define SS_KILLED 0x00000003 /* Seen Killed Type */
|
||||
#define SS_NICKCHANGE 0x00000004 /* Seen Nick Change Type */
|
||||
#define SS_JOIN 0x00000005 /* Seen Join Channel Type */
|
||||
#define SS_PART 0x00000006 /* Seen Part Channel Type */
|
||||
#define SS_KICKED 0x00000007 /* Seen Kicked Channel Type */
|
||||
|
||||
/* SeenServ Module Help */
|
||||
extern const char *sns_help_set_exclusions[];
|
||||
extern const char *sns_help_set_enable[];
|
||||
extern const char *sns_help_set_enableseenchan[];
|
||||
extern const char *sns_help_set_seenchan[];
|
||||
extern const char *sns_help_set_maxentries[];
|
||||
extern const char sns_help_seen_oneline[];
|
||||
extern const char sns_help_seennick_oneline[];
|
||||
extern const char sns_help_remove_oneline[];
|
||||
extern const char sns_help_stats_oneline[];
|
||||
extern const char *sns_help_seen[];
|
||||
extern const char *sns_help_seennick[];
|
||||
extern const char *sns_help_remove[];
|
||||
extern const char *sns_help_stats[];
|
||||
|
||||
/* events.c */
|
||||
int SeenSignon (CmdParams *cmdparams);
|
||||
int SeenQuit (CmdParams *cmdparams);
|
||||
int SeenKill (CmdParams *cmdparams);
|
||||
int SeenNickChange (CmdParams *cmdparams);
|
||||
int SeenJoinChan (CmdParams *cmdparams);
|
||||
int SeenPartChan (CmdParams *cmdparams);
|
||||
int SeenKicked (CmdParams *cmdparams);
|
||||
|
||||
/* seenserv.c */
|
||||
static int sns_set_seenchan (CmdParams *cmdparams, SET_REASON reason);
|
||||
static int sns_set_maxentries (CmdParams *cmdparams, SET_REASON reason);
|
||||
static int sns_set_exclusions (CmdParams *cmdparams, SET_REASON reason);
|
||||
|
||||
/* seen.c */
|
||||
void addseenentry(char *nick, char *user, char *host, char *vhost, char *message, int type);
|
||||
void checkseenlistlimit(void);
|
||||
void removepreviousnick(char *nn);
|
||||
void loadseendata(void);
|
||||
int loadseenrecords(void *data);
|
||||
int sortlistbytime(const void *key1, const void *key2);
|
||||
void destroyseenlist(void);
|
||||
int sns_cmd_seenhost(CmdParams *cmdparams);
|
||||
int sns_cmd_seennick(CmdParams *cmdparams);
|
||||
int sns_cmd_remove(CmdParams *cmdparams);
|
||||
int sns_cmd_stats(CmdParams *cmdparams);
|
93
seenserv_help.c
Normal file
93
seenserv_help.c
Normal file
|
@ -0,0 +1,93 @@
|
|||
/* YahtzeeServ - Yahtzee Game Service - NeoStats Addon Module
|
||||
** Copyright (c) 2003-2005 DeadNotBuried
|
||||
** Portions Copyright (c) 1999-2005, NeoStats
|
||||
**
|
||||
** This program is free software; you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
** the Free Software Foundation; either version 2 of the License, or
|
||||
** (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program; if not, write to the Free Software
|
||||
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
** USA
|
||||
**
|
||||
** YahtzeeServ CVS Identification
|
||||
** $Id$
|
||||
*/
|
||||
|
||||
#include "neostats.h" /* Required for bot support */
|
||||
#include "seenserv.h"
|
||||
|
||||
const char *sns_help_set_chan[] = {
|
||||
"\2CHAN <#Channel>\2 - Set Channel Yahtzee Games Play in",
|
||||
NULL
|
||||
};
|
||||
|
||||
const char *sns_help_set_exclusions[] = {
|
||||
"\2EXCLUSIONS <ON|OFF>\2",
|
||||
"Use global exclusion list in addition to local exclusion list",
|
||||
NULL
|
||||
};
|
||||
|
||||
const char *sns_help_set_enable[] = {
|
||||
"\2ENABLE <ON|OFF>\2",
|
||||
"Enable or Disable SEEN and SEENNICK command sent as a message",
|
||||
NULL
|
||||
};
|
||||
|
||||
const char *sns_help_set_enableseenchan[] = {
|
||||
"\2ENABLESEENCHAN <ON|OFF>\2",
|
||||
"Enable SeenServ to join the Seen Channel and accept commands in channel",
|
||||
NULL
|
||||
};
|
||||
|
||||
const char *sns_help_set_seenchan[] = {
|
||||
"\2SEENCHAN <#Channel>\2",
|
||||
"Set Channel SeenServ accepts commands from in channel",
|
||||
NULL
|
||||
};
|
||||
|
||||
const char *sns_help_set_maxentries[] = {
|
||||
"\2MAXENTRIES <entries>\2",
|
||||
"Sets the maximum entries to save",
|
||||
NULL
|
||||
};
|
||||
|
||||
const char sns_help_seen_oneline[] = "Displays Last Seen Nicks";
|
||||
const char sns_help_seennick_oneline[] = "Displays Last Seen Nicks";
|
||||
const char sns_help_remove_oneline[] = "Removes Entries that match nick!user@host";
|
||||
const char sns_help_stats_oneline[] = "Displays Seen Statistics";
|
||||
|
||||
const char *sns_help_seen[] = {
|
||||
"Syntax: \2SEEN <host>\2",
|
||||
"",
|
||||
"Displays the last seen entry of the matching entry.",
|
||||
NULL
|
||||
};
|
||||
|
||||
const char *sns_help_seennick[] = {
|
||||
"Syntax: \2SEEN <nick>\2",
|
||||
"",
|
||||
"Displays the last seen entry of the matching nick.",
|
||||
NULL
|
||||
};
|
||||
|
||||
const char *sns_help_remove[] = {
|
||||
"Syntax: \2REMOVE <entry>\2",
|
||||
"",
|
||||
"Removes any entries matching the nick!user@host provided.",
|
||||
NULL
|
||||
};
|
||||
|
||||
const char *sns_help_stats[] = {
|
||||
"Syntax: \2STATS\2",
|
||||
"",
|
||||
"Displays SEEN entry statistics.",
|
||||
NULL
|
||||
};
|
Reference in a new issue