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)
1  2 
rainbowstream/rainbow.py

diff --combined rainbowstream/rainbow.py
index 163a278ec66948dd3db635fc6a5e392bd531c5d7,bed82fb4964408fb590cf189734ac4c9aabec22d..ba91268d0db72e0c0f9e038a0462143a676361e0
@@@ -72,6 -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',
@@@ -181,8 -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 ')
              notice = light_yellow('You are running latest version (')
              notice += light_green(current)
              notice += light_yellow(')')
 -            printNicely(notice)
 +            notice += '\n'
      except:
          pass
  
@@@ -242,6 -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.'))
@@@ -1734,16 -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
              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:
@@@ -1961,13 -1956,15 +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:
              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