From: Orakaro Date: Fri, 31 Jul 2015 02:10:59 +0000 (+0900) Subject: Merge branch 'master' of github.com:DTVD/rainbowstream X-Git-Url: https://vcs.fsf.org/?p=rainbowstream.git;a=commitdiff_plain;h=36f84afdc308e4c21cd4c2d99bf3d6c3aa792074;hp=321a893a73ae8cd02000a02c9d0898b578df9560 Merge branch 'master' of github.com:DTVD/rainbowstream --- diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..4e16e2f --- /dev/null +++ b/Dockerfile @@ -0,0 +1,4 @@ +FROM python:2.7.9 + +RUN pip install rainbowstream +CMD rainbowstream diff --git a/rainbowstream/rainbow.py b/rainbowstream/rainbow.py index 163a278..ba91268 100644 --- a/rainbowstream/rainbow.py +++ b/rainbowstream/rainbow.py @@ -1961,13 +1961,15 @@ def listen(): c['lock'] = True # Save cmd to global variable and call process g['stuff'] = ' '.join(line.split()[1:]) - # Process the command - process(cmd)() - # Not re-display - if cmd in ['switch', 't', 'rt', 'rep']: - g['prefix'] = False - else: - g['prefix'] = True + # Check tweet length + if check_tweet_length(): + # Process the command + process(cmd)() + # Not re-display + if cmd in ['switch', 't', 'rt', 'rep']: + g['prefix'] = False + else: + g['prefix'] = True # Release the semaphore lock c['lock'] = False except EOFError: @@ -1977,6 +1979,18 @@ def listen(): printNicely(red('OMG something is wrong with Twitter right now.')) +def check_tweet_length(): + """ + Check tweet length (should be <= 140 chars) + """ + length = len(g['stuff']) + if length <= 140: + return True + + printNicely(red("Message is too long: %s chars" % length)) + return False + + def reconn_notice(): """ Notice when Hangup or Timeout