/******************************************************************************* Module Bot0 Server part Version: 3.1 Authors: Sylvain Huet & Sebastien DENEUX Last update: 21/05/2001 Bot Module *******************************************************************************/ /******************************************************************************* add "nameBot" by iri, 10/2004 *******************************************************************************/ /* >>>>> PLEASE DO NOT CHANGE THE FOLLOWING FONCTIONS <<<<<<< */ typeof nameBot = S;; fun Broad(text) = _DMSevent this nil "broadMsg" text nil ;; fun Private(cli,text)= _DMSevent this cli "privateMsg" text nil ;; fun UserEvent(event,cli,param)= _DMSevent this cli event param nil ;; /* >>>>> PLEASE INSERT ONLY HERE YOUR OWN CODE <<<<<<< */ /******************************************************************************* this function is called when someone is in from -> DMI : not used user -> User : the user that run the action (that has spoken) action -> S : not used param -> S : the text the user said others -> [User r1] : not used tag -> Tag : not used <- I : nothing special *******************************************************************************/ fun cbHear (from, user, action, param, others, tag) = let UtoC user -> cli in let hd strextr param -> [first[second _]] in if !strcmp first "foo" then ( Private cli strcatn nameBot::" "::(_loc this "BAR" nil)::nil; 0 ) else if !strcmp first "time" then ( Broad strcatn nameBot::" "::(ctime time)::nil; 0 ) else if !strcmp first "square" then let atoi second -> x in ( Broad strcatn nameBot::" "::(itoa x*x)::"\n"::nil; 0 ) else UserEvent first cli second ;; /******************************************************************************* this function is called when someone register the module from -> DMI : not used user -> User : the user that run the action action -> S : not used param -> S : not used others -> [User r1] : not used tag -> Tag : not used <- I : nothing special *******************************************************************************/ fun cbRegister (from, user, action, param, others, tag) = let UtoC user -> cli in ( Broad strcatn nameBot::" "::(_loc this "HELLO" nil)::" "::( _DMSgetLogin cli)::"\n"::nil; Private cli strcatn nameBot::" "::(_loc this "CAN" nil)::nil ) ;; /******************************************************************************* this function is called when someone is out from -> DMI : not used user -> User : the user that run the action action -> S : not used param -> S : not used others -> [User r1] : not used tag -> Tag : not used <- I : nothing special *******************************************************************************/ fun cbUnregister (from, user, action, param, others, tag) = let UtoC user -> cli in Broad strcatn nameBot::" "::(_loc this "BYE" nil)::" "::(_DMSgetLogin cli)::"\n"::nil ;; /******************************************************************************* main function, called when the server part of the module is initialized file -> S : not used <- I : nothing special *******************************************************************************/ fun IniDMI(file)= let strextr _getpack _checkpack file -> l in set nameBot = getInfo l "nameBot"; _DMSdefineActions this (["register" @cbRegister ]):: (["unregister" @cbUnregister ]):: (["!hear" @cbHear ]):: nil ;;