mylist get list of your lists; give a list name to get tweets
from that list
public get latest public tweets
+ pyprompt start a Python prompt for interacting with the twitter
+ object directly
replies get latest replies to you
search search twitter (Beware: octothorpe, escape it)
set set your twitter status
home directory.
"""
+from __future__ import print_function
+
CONSUMER_KEY='uS6hO2sV6tDKIOeVjhnFnQ'
CONSUMER_SECRET='MEYTOS97VvlHX7K1rwHPEqVpTSqZ71HtvoK4sVuYk'
from getpass import getpass
import re
import os.path
-from configparser import SafeConfigParser
+try:
+ from ConfigParser import SafeConfigParser
+except ImportError:
+ from configparser import ConfigParser as SafeConfigParser
import datetime
-from urllib.parse import quote
+try:
+ from urllib.parse import quote
+except ImportError:
+ from urllib2 import quote
import webbrowser
from .api import Twitter, TwitterError
from .oauth import OAuth, write_token_file, read_token_file
from .oauth_dance import oauth_dance
from . import ansi
+from .util import smrt_input, printNicely
OPTIONS = {
'action': 'friends',
def __call__(self, twitter, options):
raise NoSuchActionError("No such action: %s" %(options['action']))
-def printNicely(string):
- if sys.stdout.encoding:
- print(string.encode(sys.stdout.encoding, 'replace'))
- else:
- print(string.encode('utf-8'))
-
class StatusAction(Action):
def __call__(self, twitter, options):
statuses = self.getStatuses(twitter, options)
# We need to bypass the TwitterCall parameter encoding, so we
# don't encode the plus sign, so we have to encode it ourselves
query_string = "+".join(
- [quote(term.decode(get_term_encoding()))
+ [quote(term)
for term in options['extra_args']])
results = twitter.search(q=query_string)['results']
class SetStatusAction(Action):
def __call__(self, twitter, options):
- statusTxt = (" ".join(options['extra_args']).decode(get_term_encoding())
+ statusTxt = (" ".join(options['extra_args'])
if options['extra_args']
else str(input("message: ")))
- status = (statusTxt.encode('utf8', 'replace'))
- twitter.statuses.update(status=status)
+ twitter.statuses.update(status=statusTxt)
class TwitterShell(Action):
else:
raise SystemExit(0)
+class PythonPromptAction(Action):
+ def __call__(self, twitter, options):
+ try:
+ while True:
+ smrt_input(globals(), locals())
+ except EOFError:
+ pass
+
class HelpAction(Action):
def __call__(self, twitter, options):
print(__doc__)
'help' : HelpAction,
'leave' : LeaveAction,
'public' : PublicAction,
+ 'pyprompt' : PythonPromptAction,
'replies' : RepliesAction,
'search' : SearchAction,
'set' : SetStatusAction,