Add support for user module dir

This commit is contained in:
dpedu 2015-08-08 15:18:58 -07:00
parent 7543cb604e
commit e9e21fa051
4 changed files with 28 additions and 2 deletions

View File

@ -61,6 +61,10 @@ options:
Port on which RPC will listen
.. cmdoption:: bot.usermodules
Paths to directories where modules where also be included from
.. cmdoption:: connection.server
Hostname or IP of the IRC server to connection to

View File

@ -2,7 +2,8 @@
"bot":{
"datadir":"./data/",
"rpcbind":"0.0.0.0",
"rpcport":1876
"rpcport":1876,
"usermodules": [ "./data/modules/" ]
},
"connection":{
"server":"irc.freenode.net",
@ -11,6 +12,7 @@
},
"modules":[
"PingResponder",
"Services"
"Services",
"UserModule"
]
}

View File

@ -0,0 +1,15 @@
#!/usr/bin/env python
"""
.. module:: UserModule
:synopsis: Example userspace module
.. moduleauthor:: Dave Pedu <dave@davepedu.com>
"""
from pyircbot.modulebase import ModuleBase,ModuleHook
class UserModule(ModuleBase):
def __init__(self, bot, moduleName):
ModuleBase.__init__(self, bot, moduleName)

View File

@ -87,6 +87,11 @@ class PyIRCBot:
"""load modules specified in instance config"""
" append module location to path "
sys.path.append(os.path.dirname(__file__)+"/modules/")
" append usermodule dir to beginning of path"
for path in self.botconfig["bot"]["usermodules"]:
sys.path.insert(0, path+"/")
for modulename in self.botconfig["modules"]:
self.loadmodule(modulename)