1616from cloudbot .plugin import PluginManager
1717from cloudbot .event import Event , CommandEvent , RegexEvent , EventType
1818from cloudbot .util import botvars , formatting
19- from cloudbot .irc . client import IrcClient
19+ from cloudbot .clients . irc import IrcClient
2020
2121logger = logging .getLogger ("cloudbot" )
2222
@@ -71,15 +71,9 @@ def __init__(self, loop=asyncio.get_event_loop()):
7171 self .config = Config (self )
7272 logger .debug ("Config system initialised." )
7373
74- # log developer mode
75- if cloudbot .dev_mode .get ("plugin_reloading" ):
76- logger .info ("Enabling developer option: plugin reloading." )
77- if cloudbot .dev_mode .get ("config_reloading" ):
78- logger .info ("Enabling developer option: config reloading." )
79- if cloudbot .dev_mode .get ("console_debug" ):
80- logger .info ("Enabling developer option: console debug." )
81- if cloudbot .dev_mode .get ("file_debug" ):
82- logger .info ("Enabling developer option: file debug" )
74+ # set values for reloading
75+ self .plugin_reloading_enabled = self .config .get ("reloading" , {}).get ("plugin_reloading" , False )
76+ self .config_reloading_enabled = self .config .get ("reloading" , {}).get ("config_reloading" , True )
8377
8478 # this doesn't REALLY need to be here but it's nice
8579 self .user_agent = self .config .get ('user_agent' , 'CloudBot/3.0 - CloudBot Refresh '
@@ -91,6 +85,7 @@ def __init__(self, loop=asyncio.get_event_loop()):
9185 self .db_factory = sessionmaker (bind = self .db_engine )
9286 self .db_session = scoped_session (self .db_factory )
9387 self .db_metadata = MetaData ()
88+
9489 # set botvars.metadata so plugins can access when loading
9590 botvars .metadata = self .db_metadata
9691 logger .debug ("Database system initialised." )
@@ -101,7 +96,7 @@ def __init__(self, loop=asyncio.get_event_loop()):
10196 # create bot connections
10297 self .create_connections ()
10398
104- if cloudbot . dev_mode . get ( "plugin_reloading" ) :
99+ if self . plugin_reloading_enabled :
105100 self .reloader = PluginReloader (self )
106101
107102 self .plugin_manager = PluginManager (self )
@@ -122,40 +117,39 @@ def run(self):
122117
123118 def create_connections (self ):
124119 """ Create a BotConnection for all the networks defined in the config """
125- for conf in self .config ['connections' ]:
120+ for config in self .config ['connections' ]:
126121 # strip all spaces and capitalization from the connection name
127- readable_name = conf ['name' ]
128- name = clean_name (readable_name )
129- nick = conf ['nick' ]
130- server = conf ['connection' ]['server' ]
131- port = conf ['connection' ].get ('port' , 6667 )
132- local_bind = (conf ['connection' ].get ('bind_addr' , False ), conf ['connection' ].get ('bind_port' , 0 ))
122+ name = clean_name (config ['name' ])
123+ nick = config ['nick' ]
124+ server = config ['connection' ]['server' ]
125+ port = config ['connection' ].get ('port' , 6667 )
126+ local_bind = (config ['connection' ].get ('bind_addr' , False ), config ['connection' ].get ('bind_port' , 0 ))
133127 if local_bind [0 ] is False :
134128 local_bind = False
135129
136- self .connections .append (IrcClient (self , name , nick , config = conf , channels = conf ['channels' ],
137- readable_name = readable_name , server = server , port = port ,
138- use_ssl = conf [ 'connection' ]. get ( 'ssl' , False ), local_bind = local_bind ))
139- logger .debug ("[{}] Created connection." .format (readable_name ))
130+ self .connections .append (IrcClient (self , name , nick , config = config , channels = config ['channels' ],
131+ server = server , port = port , use_ssl = config [ 'connection' ]. get ( 'ssl' , False ) ,
132+ local_bind = local_bind ))
133+ logger .debug ("[{}] Created connection." .format (name ))
140134
141135 @asyncio .coroutine
142136 def stop (self , reason = None , * , restart = False ):
143137 """quits all networks and shuts the bot down"""
144138 logger .info ("Stopping bot." )
145139
146- if cloudbot . dev_mode . get ( "config_reloading" ) :
140+ if self . config_reloading_enabled :
147141 logger .debug ("Stopping config reloader." )
148142 self .config .stop ()
149143
150- if cloudbot . dev_mode . get ( "plugin_reloading" ) :
144+ if self . plugin_reloading_enabled :
151145 logger .debug ("Stopping plugin reloader." )
152146 self .reloader .stop ()
153147
154148 for connection in self .connections :
155149 if not connection .connected :
156150 # Don't quit a connection that hasn't connected
157151 continue
158- logger .debug ("[{}] Closing connection." .format (connection .readable_name ))
152+ logger .debug ("[{}] Closing connection." .format (connection .name ))
159153
160154 connection .quit (reason )
161155
@@ -186,7 +180,7 @@ def _init_routine(self):
186180 logger .info ("Killed while loading, exiting" )
187181 return
188182
189- if cloudbot . dev_mode . get ( "plugin_reloading" ) :
183+ if self . plugin_reloading_enabled :
190184 # start plugin reloader
191185 self .reloader .start (os .path .abspath ("plugins" ))
192186
0 commit comments