Example #1
0
def main():
    api = oauthpost.getTweepyApi(tweet_as_user)

    last_id = get_last_id(last_id_file)

    try:
        results = api.search("#sydneytraffic")
    except Exception, e:  # quit on error here
        print e
        sys.exit(1)
Example #2
0
def try_it(result):
    api = oauthpost.getTweepyApi(tweet_as_user)

    last_id = get_last_id(last_id_file)
    if result.id > last_id:
        print "Got new tweet with id: %d" % result.id
        try:
            careful_retweet(api, result)
        except HTTPError, e:
            print e.code()
            print e.read()
        except Exception, e:
            print 'e: %s' % e
            print repr(e)
Example #3
0
def retweet_by_id(i):
    api = oauthpost.getTweepyApi(tweet_as_user)
    print i
    return api.retweet(id=i)
Example #4
0
#!/usr/bin/python

import tweepy
import string
import shelve
from oauthpost import getTweepyApi

from hashlib import sha1

post_account = "sydtraffic_cs"
moderator_account = "akent"
api = getTweepyApi(post_account)
history = shelve.open(".histfile-moderator")

def msg_hash(text):
	return sha1(text).hexdigest()[:7]

def ask(text):
	hash_str = msg_hash(text)
	to_send = "%s %s" % (hash_str, text)[:140]
	sent = api.send_direct_message(screen_name = moderator_account, text = to_send)
	history[hash_str] = text

def take_action(action, text):
	print "Got %s on text: %s" % (action, text)

def parse_response(text, user):
	spl = text.split(" ", 2)
	if (len(spl) < 2): return
	hash = spl[0]
	action = spl[1]
Example #5
0
#!/usr/bin/python

import tweepy
import string
import shelve
from oauthpost import getTweepyApi

from hashlib import sha1

post_account = "sydtraffic_cs"
moderator_account = "akent"
api = getTweepyApi(post_account)
history = shelve.open(".histfile-moderator")


def msg_hash(text):
    return sha1(text).hexdigest()[:7]


def ask(text):
    hash_str = msg_hash(text)
    to_send = "%s %s" % (hash_str, text)[:140]
    sent = api.send_direct_message(screen_name=moderator_account, text=to_send)
    history[hash_str] = text


def take_action(action, text):
    print "Got %s on text: %s" % (action, text)


def parse_response(text, user):
Example #6
0
        sys.exit(1)

    for result in results:
        if (not post_search_filter(result)):
            print "discarding: %s %s" % (result.from_user, result.text)
            continue
        text = "%s %s" % (result.from_user, result.text.strip())
        category = classifier.process(text)
        if category == "traffic":
            useful.append(result)
        elif category == "unsure":
            unsure.append(result)
        elif category == "useless":
            useless.append(result)

api = oauthpost.getTweepyApi("sydtraffic_cs")

for search in searches:
    do_one_search(search[0], search[1])

useful.sort(key=lambda result: result.id)
unsure.sort(key=lambda result: result.id)
useless.sort(key=lambda result: result.id)


print "Traffic:"
for result in useful:
    print "%s %s %s" % (result.id, result.from_user, result.text)

print "\n\nUnsure:"
for result in unsure: