Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of IrcBot by
Diff: IrcBot.h
- Revision:
- 2:e4c74eb20586
- Parent:
- 1:cf586c9bbb52
- Child:
- 3:19b779ac2398
--- a/IrcBot.h Sat Aug 02 12:17:28 2014 +0000 +++ b/IrcBot.h Sat Aug 02 12:57:57 2014 +0000 @@ -5,27 +5,62 @@ #include "EthernetInterface.h" #include <vector> +/** + * IrcBot responds to commands on IRC using message users' handlers + */ class IrcMessage { public: + /** Create empty IrcMessage */ IrcMessage(); - IrcMessage(char *, char *, char *); + + /** Create an IrcMessage + * @param from The user sending the message. + * @param to The user/channel receiving the message. + * @param message The message. + */ + IrcMessage(char * from, char * to, char * message); char from[32], to[32], msg[256]; }; +/** + * Base MessageHandler class. + * Users should write classes inheriting from MessageHandler to parse and + * respond to incoming IRC messages. + */ class MessageHandler { public: MessageHandler() {}; virtual IrcMessage handle(IrcMessage msg) {return IrcMessage();} }; -class Irc { +/** + * IrcBot connects to an IRC network and joins a channel. Users can add message + * handlers which parse incoming private messages and respond to them. + */ +class IrcBot { public: - Irc(char *, char *, int, char *); + /** Create an IrcBot + * + * @param nickname Bot's nickname + * @param network IRC network to join + * @param port Port to connect to network on + * @param channel Channel to connect to + */ + IrcBot(char * nickname, char * network, int port, char * channel); + /** Connect to the network. + * + * Users should have already created a network interface + * (Ethernet/Wifi/3G/whatever) to carry the connection. + */ void connect(); + /// Disconnect from the network. void disconnect(); + /// Add a handler for incoming messages. void add(MessageHandler *); - void identify(char *); - void join(char *); + + /** Read data from internet connection, parse input and handle any + * incoming private messages + */ bool read(); private: void handle(IrcMessage);