From a10ee598533ea21ffd5e119b29fa49fd0046897d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20H=C3=B6nig?= Date: Sun, 18 Jun 2017 17:06:07 +0200 Subject: [PATCH] bots: Update foursquare bot to use get_config_info(). --- .../{foursquare.config => foursquare.conf} | 0 bots/foursquare/foursquare.py | 28 ++----------------- 2 files changed, 2 insertions(+), 26 deletions(-) rename bots/foursquare/{foursquare.config => foursquare.conf} (100%) diff --git a/bots/foursquare/foursquare.config b/bots/foursquare/foursquare.conf similarity index 100% rename from bots/foursquare/foursquare.config rename to bots/foursquare/foursquare.conf diff --git a/bots/foursquare/foursquare.py b/bots/foursquare/foursquare.py index e43d763..0e776eb 100644 --- a/bots/foursquare/foursquare.py +++ b/bots/foursquare/foursquare.py @@ -4,26 +4,11 @@ from __future__ import absolute_import import datetime as dt import re import requests -from os.path import expanduser -from six.moves import configparser as cp from six.moves import range -home = expanduser('~') -CONFIG_PATH = home + '/zulip/api/bots/foursquare/foursquare.config' - -def get_api_key(): - # foursquare.config must have been moved from - # ~/zulip/api/bots/foursquare/foursquare.config into - # ~/foursquare.config for program to work - # see readme.md for more information - with open(CONFIG_PATH) as settings: - config = cp.ConfigParser() - config.readfp(settings) - return config.get('Foursquare', 'api_key') - class FoursquareHandler(object): - def __init__(self): - self.api_key = get_api_key() + def initialize(self, bot_handler): + self.api_key = bot_handler.get_config_info('foursquare', 'Foursquare')['api_key'] def usage(self): return ''' @@ -112,12 +97,3 @@ Example Inputs: return handler_class = FoursquareHandler - -def test_get_api_key(): - # must change to your own api key for test to work - result = get_api_key() - assert result == 'abcdefghijksm' - -if __name__ == '__main__': - test_get_api_key() - print('Success')