make plugins dir based
This commit is contained in:
parent
29fbb30c75
commit
3d07cf6ecf
4 changed files with 14 additions and 31 deletions
|
|
@ -1,9 +0,0 @@
|
||||||
import time
|
|
||||||
crontable = []
|
|
||||||
outputs = []
|
|
||||||
|
|
||||||
#crontable.append([.5,"add_number"])
|
|
||||||
crontable.append([5,"say_time"])
|
|
||||||
|
|
||||||
def say_time():
|
|
||||||
outputs.append(["D030GJLM2", time.time()])
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
import time
|
|
||||||
crontable = []
|
|
||||||
outputs = []
|
|
||||||
|
|
||||||
def process_message(data):
|
|
||||||
if data['channel'].startswith("D"):
|
|
||||||
outputs.append([data['channel'], "from repeat1: " + data['text']])
|
|
||||||
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
import time
|
|
||||||
crontable = []
|
|
||||||
outputs = []
|
|
||||||
|
|
||||||
def process_message(data):
|
|
||||||
if data['channel'].startswith("D"):
|
|
||||||
outputs.append([data['channel'], "from repeat2: " + data['text']])
|
|
||||||
|
|
||||||
18
rtmbot.py
18
rtmbot.py
|
|
@ -1,5 +1,8 @@
|
||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
|
|
||||||
|
import sys
|
||||||
|
sys.dont_write_bytecode = True
|
||||||
|
|
||||||
import glob
|
import glob
|
||||||
import yaml
|
import yaml
|
||||||
import json
|
import json
|
||||||
|
|
@ -47,13 +50,15 @@ class RtmBot(object):
|
||||||
plugin.do_jobs()
|
plugin.do_jobs()
|
||||||
def load_plugins(self):
|
def load_plugins(self):
|
||||||
path = os.path.dirname(sys.argv[0])
|
path = os.path.dirname(sys.argv[0])
|
||||||
sys.path.insert(0, path + "/plugins")
|
for plugin in glob.glob(path+'/plugins/*'):
|
||||||
for plugin in glob.glob(path+'/plugins/*.py'):
|
sys.path.insert(0, plugin)
|
||||||
|
for plugin in glob.glob(path+'/plugins/*/*.py'):
|
||||||
|
print plugin
|
||||||
name = plugin.split('/')[-1][:-2]
|
name = plugin.split('/')[-1][:-2]
|
||||||
try:
|
# try:
|
||||||
self.bot_plugins.append(Plugin(name))
|
self.bot_plugins.append(Plugin(name))
|
||||||
except:
|
# except:
|
||||||
print "error loading plugin %s" % name
|
# print "error loading plugin %s" % name
|
||||||
|
|
||||||
class Plugin(object):
|
class Plugin(object):
|
||||||
def __init__(self, name):
|
def __init__(self, name):
|
||||||
|
|
@ -69,7 +74,10 @@ class Plugin(object):
|
||||||
print self.module.crontable
|
print self.module.crontable
|
||||||
def do(self, function_name, data):
|
def do(self, function_name, data):
|
||||||
if function_name in dir(self.module):
|
if function_name in dir(self.module):
|
||||||
|
# try:
|
||||||
eval("self.module."+function_name)(data)
|
eval("self.module."+function_name)(data)
|
||||||
|
# except:
|
||||||
|
# dbg("problem in module")
|
||||||
def do_jobs(self):
|
def do_jobs(self):
|
||||||
for job in self.jobs:
|
for job in self.jobs:
|
||||||
job.check()
|
job.check()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue