Created
February 11, 2011 07:44
-
-
Save JakobOvrum/822045 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--Say "Hi!", wait 3 seconds, say "I'm a bot!", wait 10 seconds, repeat | |
do | |
local spamchannel | |
--Think hooks are run once every bot:think(), but can be delayed with the "wait" function. | |
--The "wait" function does not block the rest of the program. | |
Hook "Think" | |
{ | |
enabled = false; --not enabled by default | |
function() | |
send{target = spamchannel, message = bold("Hi!")} | |
wait(3) | |
send{target = spamchannel, message = underline("I'm a bot!")} | |
wait(10) | |
end | |
} | |
--Enable or disable the previous example | |
Command "greeter" | |
{ | |
function(cmd) | |
if cmd == "enable" then | |
enableThink() | |
spamchannel = channel | |
reply("Enabled greeter.") | |
elseif cmd == "disable" then | |
disableThink() | |
spamchannel = nil | |
reply("Disabled greeter.") | |
else | |
reply("Argument must be 'enable' or 'disable'.") | |
end | |
end | |
} | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment