swapagarwal / JARVIS-on-Messenger

:speech_balloon: A community-driven python bot that aims to be as simple as possible to serve humans with their everyday tasks
https://m.me/J.A.R.V.I.S.on.Messenger
MIT License
1.35k stars 989 forks source link

Add an api key wrapper #264

Open swapagarwal opened 7 years ago

swapagarwal commented 7 years ago

This extraction https://github.com/swapagarwal/JARVIS-on-Messenger/blob/master/modules/src/dictionary.py#L9 would be abstracted out to a util class.

edadesd commented 7 years ago

I've started working on this. As it stands, I instantiate the class and then call a class method passing the name of the key or the data file variable name. The method then needs to retrieve the key from the environment, or failing that, from config.

edadesd commented 7 years ago

Another way to do it would be to take the key name as a constructor argument and have the constructor store the key as an object variable which could then be retrieved from the object.

Do you have any thoughts on which you would prefer?

key_getter = util.GetConfig()
key = key_getter.retrieve_key("KEY_NAME")
assert(key)

vs.

key_getter = util.GetConfig("KEY_NAME")
key = key_getter.retrieved_key
assert(key)
luxorv commented 6 years ago

Is this still an issue? I would like to work on this.

edadesd commented 6 years ago

PR #266 is currently opened to address it. You could comment on that, or even open up your own PR if you want to implement it in a different way.

luxorv commented 6 years ago

@edadesd seems like #266 solves the issue, I don't think more action is needed but to fix the test not passing in the code. Thanks for the quick response :)

Abdullah-alfadhel commented 4 years ago

Hello, I was wondering if you want an Arabic translator? so the project can reach a wider audience.