Skip to content
This repository has been archived by the owner on Sep 16, 2021. It is now read-only.

Commit

Permalink
get access to public methods of the hangups Client
Browse files Browse the repository at this point in the history
the client methods can be accessed via ```bot._client.<method>``` and now also via ```bot.<method>```

If a method with the same name is implemented in the ```HangupsBot``` class, the method will be used instead.

e.x.:
calling ```bot._client.upload_image(<args>)``` is an access to a private member of ```bot```, however the method ```image_upload``` is a common method and an access should not violate any permission. It can be accessed now via ```bot.image_upload```.
  • Loading branch information
das7pad committed Jun 5, 2017
1 parent 3548f45 commit c9a321a
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions hangupsbot/hangupsbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,23 @@ def user_self(self):

return myself

def __getattr__(self, attr):
"""bridge base requests to the hangups client
Args:
attr: string, method name of hangups.client.Client
Returns:
callable, the requested method if it is not private
Raises:
NotImplementedError: the method is private or not implemented
"""
if attr and attr[0] != "_" and hasattr(self._client, attr):
return getattr(self._client, attr)
raise NotImplementedError()


def configure_logging(args):
"""Configure Logging
Expand Down

0 comments on commit c9a321a

Please sign in to comment.