Beispiel #1
0
def reply_tweet(arg_tweet_id, aeg_reply_text):
    api = config.get_api()
    screen_name = get_screen_name(arg_tweet_id)
    status_str = screen_name + ' ' + aeg_reply_text

    api.update_status(status=str(status_str),
                      in_reply_to_status_id=arg_tweet_id)
Beispiel #2
0
def search_and_follow(arg_search_word):
    if arg_search_word == '':
        # 引数に何も渡されない場合
        word = random.choice(SEARCH_WORD)

    api = config.get_api()

    # 配列を渡すことも出来る
    word = arg_search_word
    set_count = 50
    results = api.search(q=word, count=set_count)

    for result in results:
        username = result.user._json['screen_name']
        user_id = result.id
        print("ユーザーID:" + str(user_id))
        user = result.user.name
        print("ユーザー名:" + user)
        tweet = result.text
        print("ユーザーのコメント:" + tweet)

        try:
            api.create_favorite(user_id)
            api.create_friendship(username)
            print(user + "をフォローと「いいね」をしました\n\n")
        except:
            print(user + "はもうフォローしてます\n\n")
Beispiel #3
0
def retweet(arg_tweet_id):
    api = config.get_api()
    tweet = api.get_status(arg_tweet_id)

    try:
        api.retweet(arg_tweet_id)
        print(str(tweet.text) + " retweet completed. \n\n")
    except:
        print(str(tweet.text) + " is aleady retweet.\n\n")
Beispiel #4
0
def get_api():
    api = config.get_api()
    screen_name = config.SCREEN_NAME
    return api, screen_name
# test_surrogate_pairs

import pytest
import random
import struct
import unicodedata

import config
api = config.get_api()
import twitter

high_surrogates = ('D800', 'DBFF') # including High Private Use Surrogates
high_surrogates_cjk = ('D840', 'D87E') # This covers mostly CJK.
low_surrogates = ('DC00', 'DFFF')

def make_surrogate_pair():
    """Generate one random surrogate pair."""
    # Add one character made up of one codepoint each from
    # (High Surrogates + High Private Use Surrogates) and Low Surrogates.
    # We expect each such pair to behave as a single high-codepoint
    # character.
    return (unicode_char(random.randint(
                int(high_surrogates_cjk[0], 16),
                int(high_surrogates_cjk[1], 16))) +
            unicode_char(random.randint(
                int(low_surrogates[0], 16), int(low_surrogates[1], 16)))
            )

def unicode_char(n):
    """Extend `unichr` for all possible Unicode values (n)."""
    try:
Beispiel #6
0
def get_screen_name(arg_tweet_id):
    api = config.get_api()
    tweet = api.get_status(arg_tweet_id)
    screen_name = '@' + tweet.user.screen_name
    return screen_name
Beispiel #7
0
def destroy_follow(arg_user_id):
    api = config.get_api()
    user = api.get_user(arg_user_id).name

    api.destroy_friendship(arg_user_id)
    print(user + " のフォローを解除しまいした\n\n")
Beispiel #8
0
def follow(arg_user_id):
    api = config.get_api()
    user = api.get_user(arg_user_id).name

    api.create_friendship(arg_user_id)
    print(user + " をFollowしました\n\n")
Beispiel #9
0
import config

api = config.get_api()

print(api.list_direct_messages(count=10))
Beispiel #10
0
def main():
    api = config.get_api()
    print(api.list_direct_messages())