Merge branch 'master' of github.com:DTVD/rainbowstream
authorOrakaro <nhatminh_179@hotmail.com>
Fri, 31 Jul 2015 02:10:59 +0000 (11:10 +0900)
committerOrakaro <nhatminh_179@hotmail.com>
Fri, 31 Jul 2015 02:10:59 +0000 (11:10 +0900)
Dockerfile [new file with mode: 0644]
rainbowstream/rainbow.py

diff --git a/Dockerfile b/Dockerfile
new file mode 100644 (file)
index 0000000..4e16e2f
--- /dev/null
@@ -0,0 +1,4 @@
+FROM python:2.7.9
+
+RUN pip install rainbowstream
+CMD rainbowstream
index 163a278..ba91268 100644 (file)
@@ -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