[NeoStats-Devel] [Commits] r28 - trunk

[email protected]
Newsgroups gmane.comp.neostats.devel
Message-ID <[email protected]>
Author: Mark
Date: Tue May  3 01:26:09 2005
New Revision: 28

Modified:
   trunk/seen.c
   trunk/seenserv.h
Log:
restore oper reports accidentally removed in rev 25 and additional type checking

Modified: trunk/seen.c
==============================================================================
--- trunk/seen.c	(original)
+++ trunk/seen.c	Tue May  3 01:26:09 2005
@@ -211,7 +211,7 @@
 /*
  * Check For Seen Records
 */
-int CheckSeenData(CmdParams *cmdparams, int checktype)
+int CheckSeenData(CmdParams *cmdparams, SEEN_CHECK checktype)
 {
 	lnode_t *ln;
 	SeenData *sd;
@@ -319,14 +319,23 @@
 					if (!ircstrcasecmp(sdo->userhost, u->user->userhostmask)) {
 						ircsnprintf(cc, SS_GENCHARLEN, ", %s is currently connected", u->name);
 					}
-				}
-				seen_report( cmdparams, "%s%s was last seen connecting %s ago%s", nickstr, sdo->nick, dt, cc );
+				}
+				if (cmdparams->source->user->ulevel >= NS_ULEVEL_LOCOPER && cmdparams->channel == NULL)
+					irc_prefmsg (sns_bot, cmdparams->source, "%s%s was last seen connecting %s ago%s", nickstr, sdo->userhost, dt, cc);
+				else
+					seen_report( cmdparams, "%s%s was last seen connecting %s ago%s", nickstr, sdo->nick, dt, cc );
 				break;
 			case SS_QUIT:
-				seen_report( cmdparams, "%s%s was last seen quiting %s ago, stating %s", nickstr, sdo->uservhost, dt, sdo->message);
+				if (cmdparams->source->user->ulevel >= NS_ULEVEL_LOCOPER && cmdparams->channel == NULL)
+					irc_prefmsg (sns_bot, cmdparams->source, "%s%s was last seen quiting %s ago, stating %s", nickstr, sdo->userhost, dt, sdo->message);
+				else
+					seen_report( cmdparams, "%s%s was last seen quiting %s ago, stating %s", nickstr, sdo->uservhost, dt, sdo->message);
 				break;
 			case SS_KILLED:
-				seen_report( cmdparams, "%s%s was last seen being killed %s ago %s", nickstr, sdo->uservhost, dt, sdo->message );
+				if (cmdparams->source->user->ulevel >= NS_ULEVEL_LOCOPER && cmdparams->channel == NULL)
+					irc_prefmsg (sns_bot, cmdparams->source, "%s%s was last seen being killed %s ago %s", nickstr, sdo->userhost, dt, sdo->message);
+				else
+					seen_report( cmdparams, "%s%s was last seen being killed %s ago %s", nickstr, sdo->uservhost, dt, sdo->message );
 				break;
 			case SS_NICKCHANGE:
 				u = FindUser(sdo->message);
@@ -335,7 +344,10 @@
 						ircsnprintf(cc, SS_GENCHARLEN, ", %s is currently connected", u->name);
 					}
 				}
-				seen_report( cmdparams, "%s%s was last seen changing Nickname %s ago to %s%s", nickstr, sdo->uservhost, dt, sdo->message, cc );
+				if (cmdparams->source->user->ulevel >= NS_ULEVEL_LOCOPER && cmdparams->channel == NULL)
+					irc_prefmsg (sns_bot, cmdparams->source, "%s%s was last seen changing Nickname %s ago to %s%s", nickstr, sdo->userhost, dt, sdo->message, cc);
+				else
+					seen_report( cmdparams, "%s%s was last seen changing Nickname %s ago to %s%s", nickstr, sdo->uservhost, dt, sdo->message, cc );
 				break;
 			case SS_JOIN:
 				u = FindUser(sdo->nick);
@@ -349,13 +361,22 @@
 						}
 					}
 				}
-				seen_report( cmdparams, "%s%s was last seen Joining %s %s ago%s", nickstr, sdo->uservhost, sdo->message, dt, cc );
+				if (cmdparams->source->user->ulevel >= NS_ULEVEL_LOCOPER && cmdparams->channel == NULL)
+					irc_prefmsg (sns_bot, cmdparams->source, "%s%s was last seen Joining %s %s ago%s", nickstr, sdo->userhost, sdo->message, dt, cc);
+				else
+					seen_report( cmdparams, "%s%s was last seen Joining %s %s ago%s", nickstr, sdo->uservhost, sdo->message, dt, cc );
 				break;
 			case SS_PART:
-				seen_report( cmdparams, "%s%s was last seen Parting %s %s ago", nickstr, sdo->uservhost, sdo->message, dt );
+				if (cmdparams->source->user->ulevel >= NS_ULEVEL_LOCOPER && cmdparams->channel == NULL)
+					irc_prefmsg (sns_bot, cmdparams->source, "%s%s was last seen Parting %s %s ago", nickstr, sdo->userhost, sdo->message, dt);
+				else
+					seen_report( cmdparams, "%s%s was last seen Parting %s %s ago", nickstr, sdo->uservhost, sdo->message, dt );
 				break;
 			case SS_KICKED:
-				seen_report( cmdparams, "%s%s was last seen Kicked From %s %s", nickstr, sdo->uservhost, sdo->message, dt);
+				if (cmdparams->source->user->ulevel >= NS_ULEVEL_LOCOPER && cmdparams->channel == NULL)
+					irc_prefmsg (sns_bot, cmdparams->source, "%s%s was last seen being Kicked From %s %s ago", nickstr, sdo->userhost, sdo->message, dt);
+				else
+					seen_report( cmdparams, "%s%s was last seen Kicked From %s %s", nickstr, sdo->uservhost, sdo->message, dt);
 				break;
 		}
 		ns_free(sdo);
@@ -406,30 +427,28 @@
 */
 int sns_cmd_status(CmdParams *cmdparams)
 {
+	int seenstats[SEEN_TYPE_MAX];
 	lnode_t *ln;
 	SeenData *sd;
-	int sc[10], i;
 
 	if ( SeenServ.verbose == 1 ) {
 		irc_chanalert (sns_bot, "Stats Command used by %s (STATS)", cmdparams->source->name);
 	}
-	for ( i = 0 ; i < 10 ; i++ ) {
-		sc[i] = 0;
-	}
+	os_memset( seenstats, 0, sizeof( seenstats ) );
 	ln = list_first(seenlist);
 	while (ln != NULL) {
 		sd = lnode_get(ln);
-		sc[sd->seentype]++;
+		seenstats[ sd->seentype ]++;
 		ln = list_next(seenlist, ln);
 	}
 	seen_report( cmdparams, "Seen Statistics (Current Records Per Type)" );
-	seen_report( cmdparams, "%d Connections", sc[SS_CONNECTED] );
-	seen_report( cmdparams, "%d Quits", sc[SS_QUIT] );
-	seen_report( cmdparams, "%d Kills", sc[SS_KILLED] );
-	seen_report( cmdparams, "%d Nick Changes", sc[SS_NICKCHANGE] );
-	seen_report( cmdparams, "%d Channel Joins", sc[SS_JOIN] );
-	seen_report( cmdparams, "%d Channel Parts", sc[SS_PART] );
-	seen_report( cmdparams, "%d Channel Kicks", sc[SS_KICKED] );
+	seen_report( cmdparams, "%d Connections", seenstats[SS_CONNECTED] );
+	seen_report( cmdparams, "%d Quits", seenstats[SS_QUIT] );
+	seen_report( cmdparams, "%d Kills", seenstats[SS_KILLED] );
+	seen_report( cmdparams, "%d Nick Changes", seenstats[SS_NICKCHANGE] );
+	seen_report( cmdparams, "%d Channel Joins", seenstats[SS_JOIN] );
+	seen_report( cmdparams, "%d Channel Parts", seenstats[SS_PART] );
+	seen_report( cmdparams, "%d Channel Kicks", seenstats[SS_KICKED] );
 	seen_report( cmdparams, "End Of Statistics");
 	return NS_SUCCESS;
 }

Modified: trunk/seenserv.h
==============================================================================
--- trunk/seenserv.h	(original)
+++ trunk/seenserv.h	Tue May  3 01:26:09 2005
@@ -21,16 +21,24 @@
 */
 
 /* Defines */
-#define SS_CHECK_WILDCARD	0x00000001	/* WildCard Entry Check */
-#define SS_CHECK_NICK		0x00000002	/* Nick Entry Check */
-
-#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 */
+typedef enum SEEN_CHECK
+{
+	SS_CHECK_WILDCARD,	/* WildCard Entry Check */
+	SS_CHECK_NICK,		/* Nick Entry Check */
+	SEEN_CHECK_TYPE_MAX,
+} SEEN_CHECK;
+
+typedef enum SEEN_TYPE
+{
+	SS_CONNECTED,	/* Seen Connection Type */
+	SS_QUIT,		/* Seen Quit Type */
+	SS_KILLED,		/* Seen Killed Type */
+	SS_NICKCHANGE,	/* Seen Nick Change Type */
+	SS_JOIN,		/* Seen Join Channel Type */
+	SS_PART,		/* Seen Part Channel Type */
+	SS_KICKED,		/* Seen Kicked Channel Type */
+	SEEN_TYPE_MAX,
+} SEEN_TYPE;
 
 #define SS_MESSAGESIZE		300 /* Message Field Size */
 #define SS_GENCHARLEN		128 /* General Character Field Length */
@@ -60,7 +68,7 @@
 	char userhost[USERHOSTLEN];
 	char uservhost[USERHOSTLEN];
 	char message[SS_MESSAGESIZE];
-	int seentype;
+	SEEN_TYPE seentype;
 	time_t seentime;
 } SeenData;
 
@@ -118,6 +126,6 @@
 void destroyseenlist(void);
 int sns_cmd_seenhost(CmdParams *cmdparams);
 int sns_cmd_seennick(CmdParams *cmdparams);
-int CheckSeenData(CmdParams *cmdparams, int checktype);
+int CheckSeenData(CmdParams *cmdparams, SEEN_CHECK checktype);
 int sns_cmd_del(CmdParams *cmdparams);
 int sns_cmd_status(CmdParams *cmdparams);
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.