Merge branch 'master' of github.com:DTVD/rainbowstream
[rainbowstream.git] / rainbowstream / rainbow.py
index a5cc190b858f175121cf5596a001077684b57899..ba91268d0db72e0c0f9e038a0462143a676361e0 100644 (file)
@@ -72,11 +72,6 @@ def parse_arguments():
         '--color-24bit',
         action='store_true',
         help='Display images using 24bit color codes.')
-    parser.add_argument(
-        '-hr',
-        '--higher-resolution',
-        action='store_true',
-        help='Display images in high(er) resolution.')
     parser.add_argument(
         '-ph',
         '--proxy-host',
@@ -186,7 +181,8 @@ def upgrade_center():
         url = 'https://raw.githubusercontent.com/DTVD/rainbowstream/master/setup.py'
         readme = requests.get(url).text
         latest = readme.split('version = \'')[1].split('\'')[0]
-        if current != latest:
+        g['using_latest'] = current == latest
+        if not g['using_latest']:
             notice = light_magenta('RainbowStream latest version is ')
             notice += light_green(latest)
             notice += light_magenta(' while your current version is ')
@@ -198,7 +194,7 @@ def upgrade_center():
             notice = light_yellow('You are running latest version (')
             notice += light_green(current)
             notice += light_yellow(')')
-            printNicely(notice)
+            notice += '\n'
     except:
         pass
 
@@ -246,9 +242,6 @@ def init(args):
     set_config('IMAGE_ON_TERM', str(c['IMAGE_ON_TERM']))
     # Use 24 bit color
     c['24BIT'] = args.color_24bit
-    # Print images using half height blocks
-    c['HIGHER_RESOLUTION'] = args.higher_resolution
-    set_config('HIGHER_RESOLUTION', str(c['HIGHER_RESOLUTION']))
     # Check type of ONLY_LIST and IGNORE_LIST
     if not isinstance(c['ONLY_LIST'], list):
         printNicely(red('ONLY_LIST is not a valid list value.'))
@@ -1741,6 +1734,16 @@ def quit():
     sys.exit()
 
 
+def changelog_notify():
+    # For v1.2.8. Hardcoded here but will improve later
+    notice = light_yellow('Hey! RS just ')
+    notice += light_green('doubled ')
+    notice += light_yellow('pixels for higher image resolution. Upgrade and try')
+    notice += light_green(' -iot ')
+    notice += light_yellow('and you will like it for sure :)')
+    printNicely(notice)
+
+
 def reset():
     """
     Reset prefix of line
@@ -1750,6 +1753,8 @@ def reset():
             printNicely(red('Your ~/.rainbow_config.json is messed up:'))
             printNicely(red('>>> ' + c['USER_JSON_ERROR']))
             printNicely('')
+        if not g['using_latest']:
+            changelog_notify()
         printNicely(magenta('Need tips ? Type "h" and hit Enter key!'))
     g['reset'] = False
     try:
@@ -1956,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:
@@ -1972,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