Created
April 26, 2015 20:55
-
-
Save tebemis/18743415bf118cc9371b to your computer and use it in GitHub Desktop.
This file contains 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
require_relative '../../lib/config/runlist' | |
require_relative '../../lib/config/config' | |
require_relative '../../nutella_lib/framework_core' | |
# Framework bots can access all the parameters they need directly | |
# from the configuration file and the runlist, | |
# to which they have full access to. | |
# Access the config file like so: | |
# Nutella.config['broker'] | |
# Access the runs list like so: | |
# Nutella.runlist.all_runs | |
# Initialize this bot as framework component | |
nutella.f.init(Nutella.config['broker'], 'example_framework_bot') | |
# Subscribe to a channel for all runs and create an object store that saves parameters for that run only | |
nutella.f.net.subscribe_to_all_runs('test', lambda do |payload, app_id, run_id, from| | |
# create a store for app_id and run_id | |
store = nutella.f.persist.get_run_json_object_store(app_id, run_id, 'messages') | |
store['last_message'] = payload | |
end) | |
# Does your bot die? If all your bot is doing is waiting for message on the network | |
# and responding to them, the main thread will terminate unless you call... | |
nutella.f.net.listen |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment