The LDPL IRC Bot Library is a super easy to use IRC bot library for LDPL. It lets you write LDPL programs that connect to IRC servers, join channels, send messages and react to received messages in the simplest way possible. This library requires LDPL 4.3 or greater.
You can install this library by hand or using LPM.
Open a terminal and write lpm install ldpl_irc_bot
. Once downloaded, include it in your LDPL project by adding the line:
using package ldpl_irc_bot
before the data
and procedure
sections of your source file. The library is ready to be used.
Include the library into your LDPL project by copying the folder ldpl-irc-bot to your project directory and then adding the line:
include "ldpl-irc-bot/ldpl_irc_bot.ldpl"
before the data
and procedure
sections of your source file. The library is
ready to be used.
This library adds five new statements to the language:
irc set nick <text>
sets<text>
as the nick of your IRC bot.irc set server <text> on port <text>
sets the server and port your bot will connect to.irc add channel <text>
adds a channel to the list of channels your bot will join when it connects to the server.irc start bot
connects your bot to the IRC server and then joins all the specified channels.irc send <text> to <text>
sends<text>
to the channel or user named<text>
.
This library also requires you to define the following subprocedures:
This sub is executed when your bot receives a message (both privately or on a channel). msg_text
contains the message that was received, msg_from
contains the nick of the user who sent the message and msg_channel
contains the name of the channel the message was sent to (or the nick of your bot if it was a direct message).
sub ircbot.onmessage
parameters:
msg_text is text
msg_from is text
msg_channel is text
procedure:
# ...
end sub
This sub is executed when someone joins a channel your bot is in. join_name
contains the nick of the user who joined and join_channel
contains the name of the channel they joined.
sub ircbot.onjoin
parameters:
join_name is text
join_channel is text
procedure:
# ...
end sub
This sub is executed when someone leaves a channel your bot is in. part_name
contains the nick of the user who left and part_channel
contains the name of the channel they parted from.
sub ircbot.onpart
parameters:
part_name is text
part_channel is text
procedure:
# ...
end sub
The file example-bot.ldpl
contains an example bot written using this library.
If you add any features to the library that you'd like to share, be sure to ring us with a pull request and we'll add them to the library! Every contribution is welcome!
The LDPL IRC Bot Library is heavily based on SirLogsalot by Gokberk Yaltirakli. His code is released under the MIT License and so is this library.