X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~matthewv/git?a=blobdiff_plain;f=commands.py;h=f7444d1d52b09eb4bf13c71fd5f33d3bb17a1990;hb=bf16788e8f843447ef0b0d5649d76a83188b522a;hp=86d0d2331acd6c8374219c9c740c82b40fe5e2c3;hpb=7ee220de38369037fa786e21af681ed7aa111268;p=irc.git diff --git a/commands.py b/commands.py index 86d0d23..f7444d1 100755 --- a/commands.py +++ b/commands.py @@ -498,13 +498,15 @@ def twitterq(bot,cmd,nick,conn,public,twitapi): 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 - + stringsout=[] + parts = string.split(urlstring,'/') tweetID = parts[-1] try: @@ -577,7 +579,12 @@ def getTweet(urlstring,twitapi,inclusion=False): 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(">",">") @@ -591,6 +598,8 @@ def getTweet(urlstring,twitapi,inclusion=False): except Exception: terror = sys.exc_info() stringout = "Error: %s" % terror[1].__str__() + stringsout = [stringout] + stringsout if inclusion: - 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)