summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSean B. Palmer <sean@miscoranda.com>2012-07-24 09:11:05 +0100
committerSean B. Palmer <sean@miscoranda.com>2012-07-24 09:11:05 +0100
commitbb40d1ad38ad9754819f46ec7d025fab67c947c0 (patch)
treea0079f041af89d8aec05b27be2660b343d0aa5da
parent9505eae02ec38624c0e2a58247f59b65f87ddb3d (diff)
downloadbot-bb40d1ad38ad9754819f46ec7d025fab67c947c0.tar.gz
bot-bb40d1ad38ad9754819f46ec7d025fab67c947c0.tar.bz2
bot-bb40d1ad38ad9754819f46ec7d025fab67c947c0.zip
Fixed seen.py apos problem, thus thanking Xarthisius
-rwxr-xr-xmodules/seen.py2
-rwxr-xr-xmodules/twitter.py12
2 files changed, 10 insertions, 4 deletions
diff --git a/modules/seen.py b/modules/seen.py
index f04d9c9..8ed41a8 100755
--- a/modules/seen.py
+++ b/modules/seen.py
@@ -27,7 +27,7 @@ def seen(phenny, input):
msg = "I last saw %s at %s on %s" % (nick, t, channel)
phenny.reply(msg)
else: phenny.reply("Sorry, I haven't seen %s around." % nick)
-seen.rule = (['seen'], r'(\S+)')'
+seen.rule = (['seen'], r'(\S+)')
@deprecated
def f_note(self, origin, match, args):
diff --git a/modules/twitter.py b/modules/twitter.py
index 4e7c134..afd1d5c 100755
--- a/modules/twitter.py
+++ b/modules/twitter.py
@@ -16,6 +16,8 @@ r_p = re.compile(r'(?ims)(<p class="js-tweet-text.*?</p>)')
r_tag = re.compile(r'(?ims)<[^>]+>')
r_anchor = re.compile(r'(?ims)(<a.*?</a>)')
r_expanded = re.compile(r'(?ims)data-expanded-url=["\'](.*?)["\']')
+r_whiteline = re.compile(r'(?ims)[ \t]+[\r\n]+')
+r_breaks = re.compile(r'(?ims)[\r\n]+')
def entity(*args, **kargs):
return web.entity(*args, **kargs).encode('utf-8')
@@ -41,8 +43,8 @@ def read_tweet(url):
text = expand(text)
text = r_tag.sub('', text)
text = text.strip()
- text = text.replace('\r', '')
- text = text.replace('\n', '')
+ text = r_whiteline.sub(' ', text)
+ text = r_breaks.sub(' ', text)
return decode(text)
return "Sorry, couldn't get a tweet from %s" % url
@@ -66,7 +68,11 @@ def id_tweet(tid):
return "Sorry, couldn't get a tweet from %s" % link
def twitter(phenny, input):
- arg = input.group(2).strip()
+ arg = input.group(2)
+ if not arg:
+ return phenny.reply("Give me a link, a username, or a tweet id")
+
+ arg = arg.strip()
if isinstance(arg, unicode):
arg = arg.encode('utf-8')