Example #1
0
def main(user):
	import common
	api = common.api(config.credentials['consumer_key'], config.credentials['consumer_secret'], user['access_token_key'], user['access_token_secret'])
	
	r = api.request('user', {'replies': 'all'})
	for item in r:
		if 'text' in item:
			print(common.f['tweet'] % {'id': item['id'], 'screen_name': item['user']['screen_name'], 'name': item['user']['name'], 'text': html.unescape(item['text'])})
		elif 'friends' in item:
			print(common.friend_list_garbage)
		elif 'event' in item:
			try:
				if item['event'] in ('favorite', 'favorited_retweet'):
					print(common.f['favorite'] % { item['source']['screen_name'], item['event'], item['target_object']['user']['screen_name'], item['target_object']['text']})
				elif item['event'] in ('retweet', 'retweeted_retweet'):
					print(common.f['retweet'] % { item['source']['screen_name'], item['event'], item['target_object']['user']['screen_name'], item['target_object']['text']})
				elif item['event'] == 'follow':
					print(common.f['follow'] % { item['source']['screen_name'], item['event'], item['target']['user']['screen_name']})
				else:
					print(common.f['default'] % { item['source']['screen_name'], item['event'], item['target_object']['user']['screen_name'], item['target_object']['text']})
			except:
				print(item)
				print(sys.exc_info())
		else:
			print(item)
#!/usr/bin/env python3
import concurrent.futures
import json
import sys

from twitter import TwitterError

import common
from common import confirm

api = common.api()
likes = []

with open(sys.argv[-1], encoding='utf-8') as f:
    js = f.read()
    idx = js.index('= [') + 2
    likes = json.loads(js[idx:])

confirmed = confirm('There are %d likes. Are you sure to delete all likes in this archive?' % len(likes),
                    default=False)

if not confirmed:
    exit(0)

executor = concurrent.futures.ThreadPoolExecutor(max_workers=80)

cancelled = False

delete_failed_ids = []

Example #3
0
import config


def get_mentions(since_id):
	r = api.request('statuses/mentions_timeline', {'since_id' : since_id})
	for item in r:
		try:
			print(common.f['tweet'] % {'id': item['id'], 'screen_name': item['user']['screen_name'], 'name': item['user']['name'], 'text': unescape(item['text'])})
		except KeyError:
			print(item)
	try:
		return item['id']
	except:
		return since_id

if __name__ == "__main__":
	user = dict()
	username = list(config.credentials['users'])[0]
	user = config.credentials['users'][username]
	user['name'] = username
	username = None
	api = common.api(config.credentials['consumer_key'], config.credentials['consumer_secret'], user['access_token_key'], user['access_token_secret'])
	since_id = '571110938467921921' # Garbage id need to save it to a file maybe json
	while True:
		old_id = since_id
		since_id = get_mentions(since_id)
		if old_id != since_id:
			print('\033[1mSince_id:\033[0m', since_id)

		sleep(60)
Example #4
0
from os.path import dirname, join, abspath

import requests
import models
import common
import json
import datetime
import schedule
import time

sys.path.insert(0, abspath(join(dirname(__file__), '../')))

from flask_app import beacon
from flask_app.models import redis_helper, mongo_helper

base_url = common.api()


def global_participation_temp():
    print("#" * 30)
    print("Executing global_participation_script")
    data = beacon.get_participation_rate()
    if data:
        participation = data.get('participation')
        insert_data = {
            'epoch': data.get('epoch'),
            'voted_ether': participation.get('votedEther'),
            'global_participation':
            participation.get('globalParticipationRate'),
            'eligible_ether': participation.get('eligibleEther'),
            'timestamp': common.get_current_date_time()