Пример #1
0
import sys
import time
import os
from bot import Twitter
from db_mongo import Database

db_name = os.environ.get("DB_MOCKTHISTWEET")

db = Database()
db.connect_db(db_name)
db.select_col('environment')

consumer_key = db.find_object('consumer_key')
consumer_secret = db.find_object('consumer_secret')
access_token = db.find_object('access_token')
access_token_secret = db.find_object('access_token_secret')


def main(ck, cs, at, ats):
    bot = Twitter(ck, cs, at, ats)
    db = Database()
    db.connect_db(db_name)
    db.select_col('tweet')

    minute_wait = 5

    while True:
        l = db.find_last_object()
        last_id = l['tweet_last_id']

        since_id = bot.get_mention_tweet(last_id)
Пример #2
0
import tweepy
from db_mongo import Database

db = Database()
db.connect_db('mockthistweet_test')
db.select_col('environment')

consumer_key = db.find_object('consumer_key')
consumer_secret = db.find_object('consumer_secret')

auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
print('Please visit: ' + auth.get_authorization_url())

oauth_token = auth.request_token['oauth_token']
oauth_token_secret = auth.request_token['oauth_token_secret']

auth.request_token['oauth_token'] = oauth_token
auth.request_token['oauth_token_secret'] = oauth_token_secret
verifier = input('Verifier code: ')

try:
    a = auth.get_access_token(verifier)
    db.find_and_modify('access_token', a[0])
    db.find_and_modify('access_token_secret', a[1])
except tweepy.TweepError as e:
    print(e)