Foobot
From winsbydefault wiki
Foobot is an open source cross platform compatible IRC bot, it comes in two versions: 1 and 2
| Tested | |
| Linux | Yes |
| Windows | Yes |
| Compiler | FPC (Free Pascal Compiler) |
Contents |
Version 1
Foobot version 1 was born as a test project to develop a cross platform compatbile IRC bot system in Delphi. The bot features an extremely limited set of commands, most notably a command to execute bash commands, send raw socket information and basic authentication.
Commands
As specified in the README, the 3 type of commands supported are:
| ! | - Executes a command with the BASH shell |
| & | - Sends raw data to the IRC server |
| @ | - Executes a command supported by the core system |
- The only command supported in the 1.x version is @list and it displays all currently logged on users in the active channel
Version 2
Foobot version 2 is a beefed up version of the original, the bot code is almost identical in this early beta stage. The main difference is that Foobot 2 features a library system, which means that the application is capable of dynamically loading/unloading shared libraries (Win: DLL / Linux: SO) during runtime to add or remove functionality.
It has a working (but basic) callback system allowing the shared libraries to access information from the core bot system and make the core execute commands, this effectively allows developers to modify the bot without taking it offline.
SDK
Note: Proper SDK will come later.
- Libraries are not language dependant
Here's an example library (libtest):
library test; uses strings,sysutils; type TCallback = function(mode: integer; data: pchar): pchar; TSendRaw = procedure(data: pchar); var callback: pointer; function lib_main(a: longint): PChar; cdecl; begin writeln('Test library 1.0 loaded, waiting for input'); writeln('Callback found at 0x' + inttohex(a,2)); writeln('Querying host for version info..'); callback := pointer(a); writeln(TCallback(callback)(0,nil)); lib_main := 'libTest 1.0' + #0; end; function get_address(name: pchar): longint; var address: longint; begin // Internal function for retreiving callback address address := integer( TCallback(callback)(1,name) ); get_address := address; end; procedure lib_send_raw(data: pchar); var send_f: pointer; begin // SEND RAW DATA HERE send_f := pointer(get_address('get_raw' + #0)); TSendRaw(send_f)(data); end; procedure lib_get_msg(nick: pchar; host: pchar; msg: pchar; chan: pchar) cdecl; begin if pos('hello',LowerCase(msg)) > 0 then begin lib_send_raw(PChar('PRIVMSG ' + chan + ' :Hello ' + nick)); end; if LowerCase(msg) = 'who am i' then begin lib_send_raw(PChar('PRIVMSG ' + chan + ' :You are ' + nick + '!' + host)); end; end; procedure lib_get_raw(data: pchar) cdecl; begin // Function is triggered every time data is received from IRC end; exports lib_main, lib_get_raw, lib_get_msg; end. |
- If you use FPC, then remember to compile the library with the -Sd -gl flags, otherwise the integers will have incorrect ranges
Known Limitations
- Creating sockets inside the library using lsocket is not possible without the use of threads, there will be a function implemented in the core soon (tm) to allow libraries to create sockets on-demand inside the core that sends all the data received back to the library trough callbacks.
Download
Version 1
Version 2
Will come soon (tm)