#include "module.h" #include #define AUTHOR "SGR" #define VERSION "1.00" /* ----------------------------------------------------------- * Name: he_time * Author: SGR * Date: 14/10/2004 * ----------------------------------------------------------- * Functions: tell_the_time * Limitations: None known * Tested: Ultimate(2.8.x), Unreal(3.2), Viagra, Bahamut * ----------------------------------------------------------- * This version has been tested on Ultimate2.8.6, viagra * Unreal and Bahamut. * * * ----------------------------------------------------------- * * Changes: * * 1: Works * * ----------------------------------------------------------- */ /* ---------------------------------------------------------------------- */ /* START OF CONFIGURATION BLOCK - please read the comments :) */ /* ---------------------------------------------------------------------- */ /* If you want to prefix the time given with something, set it below */ #define TIME_STRING_PREFIX "The time is: " /* ---------------------------------------------------------------------- */ /* DO NOT EDIT BELOW THIS LINE UNLESS YOU KNOW WHAT YOU ARE DOING */ /* ---------------------------------------------------------------------- */ int tell_the_time(User * u); static char *my_asctime(const struct tm *timeptr); int AnopeInit(int argc, char **argv) { Command *c; c = createCommand("TIME", tell_the_time, NULL, -1,-1,-1,-1,-1); alog("Loading module he_logo.so [Status: %d]",moduleAddCommand(HELPSERV, c, MOD_UNIQUE)); alog("[he_time] New command: /msg %s TIME", s_HelpServ); alog("[he_time] Yayness!(tm) - MODULE LOADED AND ACTIVE"); moduleAddAuthor(AUTHOR); moduleAddVersion(VERSION); return MOD_CONT; } void AnopeFini(void) { alog("Unloading he_time.so"); } int tell_the_time(User * u) { char *timex; time_t moo = time(NULL); timex = my_asctime(localtime(&moo)); #ifdef TIME_STRING_PREFIX notice(s_HelpServ, u->nick, "%s%s", TIME_STRING_PREFIX, timex); #else notice(s_HelpServ, u->nick, "%s", timex); #endif return MOD_CONT; } static char *my_asctime(const struct tm *timeptr) { static char wday_name[7][3] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" }; static char mon_name[12][3] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; static char result[26]; sprintf(result, "%.2d:%.2d:%.2d (%.3s,%3d %.3s %d)\n", timeptr->tm_hour, timeptr->tm_min, timeptr->tm_sec, wday_name[timeptr->tm_wday], timeptr->tm_mday, mon_name[timeptr->tm_mon], 1900 + timeptr->tm_year); return result; }