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