mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-03 21:43:21 +00:00 
			
		
		
		
	bots: Check existance of config file in get_config_info().
This commit is contained in:
		@@ -12,13 +12,6 @@ import re
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
GIPHY_TRANSLATE_API = 'http://api.giphy.com/v1/gifs/translate'
 | 
					GIPHY_TRANSLATE_API = 'http://api.giphy.com/v1/gifs/translate'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if not os.path.exists(os.path.join(os.path.dirname(os.path.realpath(__file__)), 'giphy.conf')):
 | 
					 | 
				
			||||||
    print('Giphy bot config file not found, please set it up in this bot\'s folder '
 | 
					 | 
				
			||||||
          'with the name \'giphy.conf\'\n\nUsing format:\n\n[giphy-config]\nkey=<giphy'
 | 
					 | 
				
			||||||
          'API key here>\n\n')
 | 
					 | 
				
			||||||
    sys.exit(1)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
class GiphyHandler(object):
 | 
					class GiphyHandler(object):
 | 
				
			||||||
    '''
 | 
					    '''
 | 
				
			||||||
    This plugin posts a GIF in response to the keywords provided by the user.
 | 
					    This plugin posts a GIF in response to the keywords provided by the user.
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -102,7 +102,7 @@ class BotHandlerApi(object):
 | 
				
			|||||||
            our_dir, '..', 'bots', bot_name, bot_name + '.conf'))
 | 
					            our_dir, '..', 'bots', bot_name, bot_name + '.conf'))
 | 
				
			||||||
        section = section or bot_name
 | 
					        section = section or bot_name
 | 
				
			||||||
        config = configparser.ConfigParser()
 | 
					        config = configparser.ConfigParser()
 | 
				
			||||||
        config.read(conf_file_path)
 | 
					        config.readfp(open(conf_file_path))
 | 
				
			||||||
        return dict(config.items(section))
 | 
					        return dict(config.items(section))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user