Skip to content

Instantly share code, notes, and snippets.

@NuckChorris
Last active December 12, 2015 13:59
Show Gist options
  • Select an option

  • Save NuckChorris/4782283 to your computer and use it in GitHub Desktop.

Select an option

Save NuckChorris/4782283 to your computer and use it in GitHub Desktop.
require_relative 'sold/module'
class System < Sold::Module
name 'System'
description 'Commands for managing the bot.'
help :restart, 'Restarts the bot.'
command :restart do |args|
respond 'Restarting...'
exit 1
end
help :shutdown, 'Shuts the bot down.'
command :shutdown do |args|
respond 'Shutting down...'
exit 0
end
on :recv_msg do |pkt|
p pkt
end
on :mod_load do
# Connect to database, etc.
end
on :mod_unload do
# Close database connection, collect garbage, etc.
# events and commands are automatically dealt with,
# so you don't have to explicitly clean them up.
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment