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