Hide 'client' and 'rate_limit' from 'contrib_bots' bots.

'contribot_bots' should only provide a restricted access to the
client API, yet 'client' and 'rate_limit were fully exposed. While
not fully restricting access to those objects, this commits hides
them with prepending underscores.
This commit is contained in:
Robert Hönig 2017-01-11 17:38:11 +00:00 committed by showell
parent a1c0fa4c3d
commit 02bfb46398
1 changed files with 4 additions and 4 deletions

View File

@ -35,8 +35,8 @@ class RestrictedClient(object):
def __init__(self, client):
# Only expose a subset of our Client's functionality
user_profile = client.get_profile()
self.rate_limit = RateLimit(20, 5)
self.client = client
self._rate_limit = RateLimit(20, 5)
self._client = client
try:
self.full_name = user_profile['full_name']
self.email = user_profile['email']
@ -46,8 +46,8 @@ class RestrictedClient(object):
sys.exit(1)
def send_message(self, *args, **kwargs):
if self.rate_limit.is_legal():
self.client.send_message(*args, **kwargs)
if self._rate_limit.is_legal():
self._client.send_message(*args, **kwargs)
else:
logging.error('-----> !*!*!*MESSAGE RATE LIMIT REACHED, EXITING*!*!*! <-----\n'
'Is your bot trapped in an infinite loop by reacting to'