Skip to content

Instantly share code, notes, and snippets.

@JakobOvrum
Created February 11, 2011 07:44
Show Gist options
  • Save JakobOvrum/822045 to your computer and use it in GitHub Desktop.
Save JakobOvrum/822045 to your computer and use it in GitHub Desktop.
--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