Add support for user module dir
This commit is contained in:
parent
7543cb604e
commit
e9e21fa051
@ -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
|
||||
|
@ -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"
|
||||
]
|
||||
}
|
15
examples/data/modules/UserModule.py
Executable file
15
examples/data/modules/UserModule.py
Executable 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)
|
@ -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)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user