
My Jassbot :)
for the
online cardgame on www.mohrenbraeu.at
on 05.12 i decided to write some kind of IRC-B0t for the
game...
27 hours later it was finished, doing everything i
imagined ;)
how it works:
the bot looks on certain keywords. if one of these is
entered by a user, it does some actions:
Keywords:
!showcommands - shows
all available commands for the bot
!uptime - shows the date and
time when the bot was restarted the last time
!leavemsg username message - leaves
a message for the user username. the user will receive the message when he
enters the chat the next time.
Example: !leavemsg Hanswurst hallo Hanswurst :)
It's important that you correctly
enter the name, also capital letters... if the users name is Hanswurst, he won't
get any message u leave for the user hanswurst.

here is a little portion of its sourcecode...
procedure tchatform.processChatMsg(buffor:string); var s,s2: string; i,j : integer; begin buffor:=copy(buffor,pos('Tischauswahl',buffor)+16,length(buffor)); s:=copy (buffor,0,pos(#0,buffor)-1); buffor := copy (buffor,pos('data',buffor)+10,length(buffor)); if buffor[length(buffor)] = #0 then buffor := copy(buffor,0,length(buffor)-1); if pos('$',buffor) > 0 then buffor := convertumlaute(buffor); buffor := hypertrim(buffor); with memo3.SelAttributes do color := clred; memo3.lines.add(timestamp + ' <' + s + '> ' + buffor); write2logfile(timestamp + ' <' + s + '> ' + buffor, 2); if buffor = '!showcommands' then begin // sendchatmessage('**************** JassB0t 0.1 Kommandos:'); // sendchatmessage(' !showcommands : Übersicht über die verfügbaren Befehle'); sendchatmessage(' !uptime : Zeigt Uptime des Jassb0t '); sendchatmessage(' !countidleusers : Zeigt an wieviele Spieler grade nicht spielen.'); sendchatmessage(' !leavemsg Empfängername nachricht: Hinterlässt eine Nachricht für username, die ihm/ihr beim nächsten Betreten des Raumes angezeigt wird.'); // sendchatmessage('****************'); end; if buffor = '!uptime' then sendchatmessage('Jassb0t online since ' + startdate); if buffor = '!countidleusers' then begin j:=0; for i := 1 to memo1.lines.count do if pos('@',memo1.lines[i]) = 0 then inc(j); sendchatmessage('CountidleUsers: ' + inttostr(j) + ' users are idling.'); end; if copy(buffor,0,9) = '!leavemsg' then begin if length(buffor) > 11 then begin buffor:=copy(buffor,11,length(buffor)); if pos(' ',buffor) > 0 then begin inc(numberofjobs); if numberofjobs <= 1000 then begin userjobs[numberofjobs].Added := DateTimeToStr(Now); userjobs[numberofjobs].Absender := s; userjobs[numberofjobs].Erledigt := false; s2:=copy(buffor,0,pos(' ',buffor)-1); userjobs[numberofjobs].Empfaenger := s2; userjobs[numberofjobs].Nachricht := copy(buffor,pos(' ',buffor)+1,length(buffor)); sendchatmessage('Added Job, ID:'+ inttostr(numberofjobs) + ',Abs=' + s + ' Empf=' +userjobs[numberofjobs].Empfaenger + ' Msg='+userjobs[numberofjobs].Nachricht); end else sendchatmessage('S0rRy, maXima1e ANzahl an BoTsChaFten schon GeSpEichErT.'); end; end; end; end; |
(C) 2004 by rofl (at) krazz.net