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
|
Port on which RPC will listen
|
||||||
|
|
||||||
|
.. cmdoption:: bot.usermodules
|
||||||
|
|
||||||
|
Paths to directories where modules where also be included from
|
||||||
|
|
||||||
.. cmdoption:: connection.server
|
.. cmdoption:: connection.server
|
||||||
|
|
||||||
Hostname or IP of the IRC server to connection to
|
Hostname or IP of the IRC server to connection to
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
"bot":{
|
"bot":{
|
||||||
"datadir":"./data/",
|
"datadir":"./data/",
|
||||||
"rpcbind":"0.0.0.0",
|
"rpcbind":"0.0.0.0",
|
||||||
"rpcport":1876
|
"rpcport":1876,
|
||||||
|
"usermodules": [ "./data/modules/" ]
|
||||||
},
|
},
|
||||||
"connection":{
|
"connection":{
|
||||||
"server":"irc.freenode.net",
|
"server":"irc.freenode.net",
|
||||||
|
@ -11,6 +12,7 @@
|
||||||
},
|
},
|
||||||
"modules":[
|
"modules":[
|
||||||
"PingResponder",
|
"PingResponder",
|
||||||
"Services"
|
"Services",
|
||||||
|
"UserModule"
|
||||||
]
|
]
|
||||||
}
|
}
|
|
@ -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"""
|
"""load modules specified in instance config"""
|
||||||
" append module location to path "
|
" append module location to path "
|
||||||
sys.path.append(os.path.dirname(__file__)+"/modules/")
|
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"]:
|
for modulename in self.botconfig["modules"]:
|
||||||
self.loadmodule(modulename)
|
self.loadmodule(modulename)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue