示例#1
0
def main():
    f = open("/sys/class/thermal/thermal_zone0/temp")
    data = f.read()
    f.close()
    temp = data[0:len(data) - 4] + "." + data[len(data) - 4] + "°C"
    twitter = getauth.getclass(1)
    twitter.tweet("CPU: " + temp + "  time: " + str(datetime.datetime.today()))
示例#2
0
def main():
    option = int(input("what command? 1.tweet 2.timeline 3.mention 4.search 5.streaming 6.user: "******"what account?: "))
    twitter = getauth.getclass(account)
    if option == 1:
        tweet = str(input("what tweet?: "))
        twitter.tweet(tweet)

    elif option == 2:
        timeline = twitter.timeline()
        for data in timeline:
            disptweet(data)

    elif option == 3:
        mention = twitter.mention()
        for data in mention:
            disptweet(data)

    elif option == 4:
        text = str(input("search text?: "))
        search = twitter.search(text)
        for data in search["statuses"]:
            disptweet(data)

    elif option == 5:
        stream = twitter.streaming()
        for data in stream:
            if "text" in data:
                disptweet(data)
            elif "event" in data:
                if data["event"] == "favorite":
                    print(
                        "★>> from: "
                        + data["source"]["screen_name"]
                        + " | "
                        + data["target_object"]["user"]["screen_name"]
                        + ": "
                        + data["target_object"]["text"]
                        + "\n"
                    )
                else:
                    print("event: " + data["event"] + "\n")
            elif "delete" in data:
                print("deleted>> " + str(data["delete"]["status"]["user_id"]) + "\n")
            else:
                print(str(data) + "\n")

    elif option == 6:
        screen = str(input("screenName?: "))
        user = twitter.getuser(screen)
        print(user)
示例#3
0
def main():
    account = int(input('what account?: '))
    archive = str(input('Please ZIP name: '))
    twitter = getauth.getclass(account)
    with zipfile.ZipFile(archive) as tweetsZip:
        rowCount = 0
        with tweetsZip.open("tweets.csv", "r") as tweetsFile:
            tweetsTextIo = io.TextIOWrapper(tweetsFile)
            tweetsCsv = csv.DictReader(tweetsTextIo)
            for row in tweetsCsv:
                rowCount += 1
        with tweetsZip.open("tweets.csv", "r") as tweetsFile:
            tweetsTextIo = io.TextIOWrapper(tweetsFile)
            tweetsCsv = csv.DictReader(tweetsTextIo)
            num = 0
            division = int(rowCount / 100)
            for row in tweetsCsv:
                num += 1
                status = int(row['tweet_id'])
                twitter.delete(status)
                if (num % division == 0):
                    print("%d / %d (%d %%) tweets deleted." % (num, rowCount, num / rowCount * 100))
    print("ended successfully.")
def main():
    if len(sys.argv) != 3:
        print("account number and list name not found")
        return
    account = int(sys.argv[1])
    listName = sys.argv[2].split("/")
    twitter = getauth.getclass(account)
    cursor = None
    followUsers = []
    while cursor != 0:
        followList = twitter.getFollow(cursor)
        followUsers += followList["users"]
        cursor = followList["next_cursor"]
    followScreens = set([user["screen_name"] for user in followUsers])

    cursor = None
    listUsers = []
    while cursor != 0:
        followList = twitter.getListFollow(listName[0], listName[1], cursor)
        listUsers += followList["users"]
        cursor = followList["next_cursor"]
    listScreens = set([user["screen_name"] for user in listUsers])

    # not follow, but listed
    # exclude owner
    notFollowListScreens = listScreens - followScreens - set([listName[0]])

    # exclude ignore users
    pas = path.join(path.abspath(path.dirname(__file__)), ":".join(listName) + ".json")
    dataFile = open(pas, mode="r")
    previousScreens = json.loads(dataFile.readline())
    dataFile.close()
    previousListScreens = set(previousScreens["list"])
    ignoreScreens = set(previousScreens["ignore"])

    # not in list but follow, unignored
    notListFollowScreens = followScreens - listScreens - ignoreScreens

    # previous: listed, new: unlisted users
    newIgnoreScreens = notListFollowScreens & previousListScreens

    newUnListScreens = notFollowListScreens
    for screenName in newUnListScreens:
        twitter.removeFromList(listName[0], listName[1], screenName)
    newListScreens = notListFollowScreens - newIgnoreScreens
    for screenName in newListScreens:
        twitter.followInList(listName[0], listName[1], screenName)

    # previous: ignored, new: listed users
    newUnIgnoreScreens = ignoreScreens & listScreens

    newIgnoreList = (ignoreScreens | newIgnoreScreens) - newUnIgnoreScreens
    newListFollow = (listScreens | newListScreens) - newUnListScreens

    newScreensJson = json.dumps({"list": list(newListFollow), "ignore": list(newIgnoreList)})

    # initial -> after create empty json, '{"list": [], "ignore": []}'
    # newScreensJson = json.dumps({"list": list(listScreens), "ignore": list(followScreens - listScreens)})

    dataFile = open(pas, mode="w")
    dataFile.write(newScreensJson)
    dataFile.close()