chmullig avatar chmullig committed 8af8328

Initial removing old school execfile extension point. TODO: convert the local.py example to a better example (aside from wolfram-alpha)

Comments (0)

Files changed (4)

 
 * python-irclib
 * pyyaml
-* simplejson or json
+* json (standard library for 2.6+) or simplejson
 * feedparser
 * httplib2
 * sqlite3
 
+The web interface requires cherrypy and jinja2.
+
 Optionally nosetests for the test suite.
 
-The web interface requires cherrypy and jinja2.
-
 Testing
 =======
 We have a basic nose test suite that does some functional tests with an
 Custom Features
 ===============
 
-There are two ways to add a custom feature, either through local python
-scripts or through setuptools entry points.
-
-Python Scripts
---------------
-
-Adding a new feature is easy, you just need to add them to a local_extensions
-file, following the established convention. The files to load are specified
-in the local_extensions configuration setting. All files in the list are run
-with execfile, so they inherit the existing globals. As a result you can
-assume that most things you'll need are already imported, like @command,
-@contains, re, urllib, httplib2 and get_html. There's an example in local.py
-that you can use as the basis for yours..
-
-A command (!g) gets the @command deocator::
-
-  @command("tinytear", aliases=('tt', 'tear', 'cry'), doc="I cry a tiny tear for you.")
-  def tinytear(client, event, channel, nick, rest):
-  	if rest:
-  		return "/me sheds a single tear for %s" % rest
-  	else:
-  		return "/me sits and cries as a single tear slowly trickles down its cheek"
-
-A response (when someone says something) uses the @contains decorator::
-
-  @contains("sqlonrails")
-  def yay_sor(client, event, channel, nick, rest):
-  	karmaChange(botbase.logger.db, 'sql on rails', 1)
-  	return "Only 76,417 lines..."
-
 Setuptools Entry Points Plugin
 ------------------------------
 
 anything at all, but it must be present, and will be called during
 startup.
 
+Within the script you'll want to import the decorates you need to use with:
+`from pmxbot.botbase import command, contains, execdelay, execat`. You'll then
+decorate each function with the appropriate line so pmxbot registers it.
+
+A command (!g) gets the @command decorator::
+
+  @command("tinytear", aliases=('tt', 'tear', 'cry'), doc="I cry a tiny tear for you.")
+  def tinytear(client, event, channel, nick, rest):
+  	if rest:
+  		return "/me sheds a single tear for %s" % rest
+  	else:
+  		return "/me sits and cries as a single tear slowly trickles down its cheek"
+
+A response (when someone says something) uses the @contains decorator::
+
+  @contains("sqlonrails")
+  def yay_sor(client, event, channel, nick, rest):
+  	karmaChange(botbase.logger.db, 'sql on rails', 1)
+  	return "Only 76,417 lines..."
+
 For an example of how to implement a setuptools-based plugin, see
 the `wolframalpha plugin
 <http://bitbucket.org/yougov/pmxbot-wolframalpha>`_.
 server_port: 6667
 bot_nickname: pmxbot
 log_channels: 
-    - "#botone"
+    - "#pmxbot"
 other_channels:
-    - "#bottwo"
-inane_channel: "#botone"
+    - "#pmxbot2"
+inane_channel: "#pmxbot"
 database_dir: "./bot_database"
 places: ["Palo Alto, CA", "Canton, OH", "Washington, DC", "London, England"]
 lunch_choices:
     PA: ["Pasta?", "Thaiphoon", "Pluto's", "Penninsula Creamery", "Kan Zeman"]
-feed_interval: 15 #15 minutes
+feed_interval: 15 #minutes
 feeds:
     - name    : "pmxbot bitbucket"
       channel : "#botone"
       channel : "#bottwo"
       linkurl : "http://search.twitter.com/search?q=pmxbot"
       url     : "http://search.twitter.com/search.atom?q=pmxbot"
-local_extensions: ['local.py']
 librarypaste: http://a.libpa.st/
 
 web_base: /
 try:
 	import simplejson as json
 except ImportError:
-	import json # one last try-- python 2.6?
+	import json # one last try-- python 2.6+
 from saysomething import FastSayer
 from cleanhtml import plaintext
 from xml.etree import ElementTree
 		def rand_bot2(*args):
 			return rand_bot(*args)
 
-    for extension in config.local_extensions:
-        print "Loading", extension
-        execfile(extension)
-
 	_load_library_extensions()
 
 	bot = LoggingCommandBot(config.database_dir, config.server_host, config.server_port, 
     install_requires=[
         "pyyaml",
         "python-irclib",
-        "simplejson",
         "httplib2",
         "feedparser",
 		#for viewer
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.