Fix up tweets.py
This commit is contained in:
parent
23fbc2cb95
commit
a9e49fd36b
1 changed files with 15 additions and 12 deletions
|
@ -15,7 +15,6 @@ class Module(object):
|
|||
|
||||
def __init__(self, bot, events, exports):
|
||||
self.bot = bot
|
||||
self.url_shortener_enabled = "bitly" in self.bot.modules.modules
|
||||
self.events = events
|
||||
|
||||
events.on("received").on("command").on("tweet", "tw"
|
||||
|
@ -67,16 +66,19 @@ class Module(object):
|
|||
linked_id = tweet["id"]
|
||||
username = "@%s" % tweet["user"]["screen_name"]
|
||||
|
||||
url_shortener_link = ""
|
||||
if self.url_shortener_enabled:
|
||||
chopped_uname = username[1:]
|
||||
tweet_link = "https://twitter.com/%s/status/%s" % (
|
||||
url_shortener_link = False
|
||||
chopped_uname = username[1:]
|
||||
tweet_link = "https://twitter.com/%s/status/%s" % (
|
||||
chopped_uname, linked_id)
|
||||
|
||||
url_shortener_link = " -- " + self.events.on("get").on(
|
||||
url_shortener_link = self.events.on("get").on(
|
||||
"shortlink").call(
|
||||
url=tweet_link)[0]
|
||||
|
||||
url_shortener_link = "" if url_shortener_link == False else \
|
||||
"-- " + url_shortener_link
|
||||
|
||||
|
||||
if "retweeted_status" in tweet:
|
||||
original_username = "@%s" % tweet["retweeted_status"
|
||||
]["user"]["screen_name"]
|
||||
|
@ -93,12 +95,13 @@ class Module(object):
|
|||
original_text,
|
||||
url_shortener_link))
|
||||
else:
|
||||
event["stdout"].write("(%s, %s) %s %s" % (username,
|
||||
self.make_timestamp(
|
||||
tweet[
|
||||
"created_at"]),
|
||||
tweet["text"],
|
||||
url_shortener_link)
|
||||
event["stdout"].write("(%s, %s) %s %s" %
|
||||
(username,
|
||||
self.make_timestamp(
|
||||
tweet["created_at"]
|
||||
),
|
||||
tweet["text"],
|
||||
url_shortener_link)
|
||||
)
|
||||
else:
|
||||
event["stderr"].write("Invalid tweet identifiers provided")
|
||||
|
|
Loading…
Reference in a new issue