Problem:
* Overly long embedded tweets cause Acrobat to go over the server's
line length limit which causes the message to be silently discarded
because of a lack of error handling in automsg.
Solutions:
* Make each tweet in an embedded tweet chain a seperate message
- this requires getTweet to now return a list
* Did not fix automsg at all
Signed-off-by: Matthew Vernon <matthewv@chiark.greenend.org.uk>
urlstring = urlre.search(cmd).group(1)
if (urlstring.find("twitter.com") !=-1):
urlstring = urlre.search(cmd).group(1)
if (urlstring.find("twitter.com") !=-1):
- stringout = getTweet(urlstring,twitapi)
- bot.automsg(public, nick, stringout)
+ stringsout = getTweet(urlstring,twitapi)
+ for stringout in stringsout:
+ bot.automsg(public, nick, stringout)
def getTweet(urlstring,twitapi,inclusion=False):
unobfuscate_urls=True
expand_included_tweets=True
def getTweet(urlstring,twitapi,inclusion=False):
unobfuscate_urls=True
expand_included_tweets=True
parts = string.split(urlstring,'/')
tweetID = parts[-1]
try:
parts = string.split(urlstring,'/')
tweetID = parts[-1]
try:
if expand_included_tweets and not inclusion:
if rv.hostname == 'twitter.com' and re.search(r'status/\d+',rv.path):
quotedtweet = getTweet(toReplace, twitapi, inclusion=True) # inclusion parameter limits recursion.
if expand_included_tweets and not inclusion:
if rv.hostname == 'twitter.com' and re.search(r'status/\d+',rv.path):
quotedtweet = getTweet(toReplace, twitapi, inclusion=True) # inclusion parameter limits recursion.
- tweetText += " Q{" + quotedtweet + "}"
+ if not quotedtweet:
+ quotedtweet = [""]
+ quotedtweet[0] = "Q{ " + quotedtweet[0]
+ quotedtweet[-1] += " }"
+ stringsout = quotedtweet + stringsout
+
tweetText = tweetText.replace(url.url, toReplace)
tweetText = tweetText.replace(">",">")
tweetText = tweetText.replace(url.url, toReplace)
tweetText = tweetText.replace(">",">")
except Exception:
terror = sys.exc_info()
stringout = "Error: %s" % terror[1].__str__()
except Exception:
terror = sys.exc_info()
stringout = "Error: %s" % terror[1].__str__()
+ stringsout = [stringout] + stringsout
- return stringout # don't want to double-encode it, so just pass it on for now and encode later
- return stringout.encode('UTF-8', 'replace')
+ return stringsout # don't want to double-encode it, so just pass it on for now and encode later
+
+ return map(lambda x: x.encode('UTF-8', 'replace'), stringsout)