You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
54 lines
2.1 KiB
Python
54 lines
2.1 KiB
Python
from mastodon import Mastodon
|
|
from pprint import pprint
|
|
import os
|
|
import time
|
|
import datetime
|
|
from pprint import pprint
|
|
|
|
today = datetime.date.today()
|
|
text_file = open("dms_results.txt", "a+")
|
|
text_file.write("Data collected on : "+str(today)+"\n"+"\n")
|
|
|
|
instances = ["https://todon.nl/", "https://quey.org/"]
|
|
|
|
#toots token order is also the same
|
|
#FOR EXAMPLE
|
|
#toot_id[0] goes with instances[0] and now goes with line nr1 from txt file
|
|
with open('token.txt', 'r') as token:
|
|
for n, token_line in enumerate(token.readlines()):
|
|
base_url = instances[n]
|
|
print(token_line, base_url)
|
|
# token_line is one of the token.txt
|
|
# You are reading in token.readlines() and there is no need to read again
|
|
# you can use var token_line
|
|
mastodon = Mastodon(access_token=token_line.replace('\n', ''),
|
|
api_base_url=(str(base_url)))
|
|
|
|
'''
|
|
mastodon direct messages, are the same as toots: *status updates*
|
|
With the difference that their visibility rathern than
|
|
being public / unlisted / private, are direct status updates
|
|
'''
|
|
|
|
my_credentials = mastodon.account_verify_credentials()
|
|
my_id = my_credentials['id']
|
|
my_statuses = mastodon.account_statuses(id=my_id)
|
|
|
|
for status in my_statuses:
|
|
if status['visibility'] == 'direct': # filter only direct msgs
|
|
|
|
avatar = (status['account']['avatar'])
|
|
name = (status['account']['display_name'])
|
|
bot = (status['account']['bot'])
|
|
content = (status['content'])
|
|
|
|
pprint("Avatar:" + "\n" + str(avatar) + "\n" + "\n")
|
|
pprint("Name:" + "\n" + str(name) + "\n" + "\n")
|
|
pprint("Bot:" + "\n" + str(bot) + "\n" + "\n")
|
|
pprint("Content:" + "\n" + str(content) + "\n" + "\n")
|
|
|
|
text_file.write("Avatar:" + "\n" + str(avatar) + "\n" + "\n")
|
|
text_file.write("Name:" + "\n" + str(name) + "\n" + "\n")
|
|
text_file.write("Bot:" + "\n" + str(bot) + "\n" + "\n")
|
|
text_file.write("Content:" + "\n" + str(content) + "\n" + "\n" + "\n")
|