move api def to the only context that uses it, rename twitter_object var

This commit is contained in:
jesopo 2019-05-22 19:49:55 +01:00
parent aa75f4ef05
commit 000b264d6d

View file

@ -79,7 +79,6 @@ class Module(ModuleManager.BaseModule):
if target: if target:
target = target.message target = target.message
if target: if target:
api = self._get_api()
url_match = re.search(REGEX_TWITTERURL, target) url_match = re.search(REGEX_TWITTERURL, target)
if url_match or target.isdigit(): if url_match or target.isdigit():
tweet_id = url_match.group(1) if url_match else target tweet_id = url_match.group(1) if url_match else target
@ -87,8 +86,9 @@ class Module(ModuleManager.BaseModule):
else: else:
if target.startswith("@"): if target.startswith("@"):
target = target[1:] target = target[1:]
api = self._get_api()
try: try:
tweet = twitter_object.statuses.user_timeline( tweet = api.statuses.user_timeline(
screen_name=target, count=1)[0] screen_name=target, count=1)[0]
except: except:
traceback.print_exc() traceback.print_exc()