File tree Expand file tree Collapse file tree 2 files changed +17
-2
lines changed
Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change 1+ import time
2+ outputs = []
3+
4+ def canary ():
5+ #NOTE: you must add a real channel ID for this to work
6+ outputs .append (["D12345678" , "bot started: " + str (time .time ())])
7+
8+ canary ()
Original file line number Diff line number Diff line change @@ -44,15 +44,19 @@ def output(self):
4444 for plugin in self .bot_plugins :
4545 for output in plugin .do_output ():
4646 channel = self .slack_client .server .channels .find (output [0 ])
47- channel .send_message ("%s" % output [1 ])
47+ if channel != None :
48+ channel .send_message ("%s" % output [1 ])
49+ else :
50+ raise UnknownChannel
4851 def crons (self ):
4952 for plugin in self .bot_plugins :
5053 plugin .do_jobs ()
5154 def load_plugins (self ):
5255 path = os .path .dirname (sys .argv [0 ])
5356 for plugin in glob .glob (path + '/plugins/*' ):
5457 sys .path .insert (0 , plugin )
55- for plugin in glob .glob (path + '/plugins/*/*.py' ):
58+ sys .path .insert (0 , path + '/plugins/' )
59+ for plugin in glob .glob (path + '/plugins/*.py' ) + glob .glob (path + '/plugins/*/*.py' ):
5660 print plugin
5761 name = plugin .split ('/' )[- 1 ][:- 2 ]
5862# try:
@@ -115,6 +119,9 @@ def check(self):
115119 self .lastrun = time .time ()
116120 pass
117121
122+ class UnknownChannel (Exception ):
123+ pass
124+
118125
119126if __name__ == "__main__" :
120127 config = yaml .load (file ('rtmbot.conf' , 'r' ))
You can’t perform that action at this time.
0 commit comments