2022-08-21 20:00:02 +02:00
|
|
|
import os
|
|
|
|
import sys
|
2023-04-13 18:01:18 +02:00
|
|
|
from app.libraries.setup import Setup
|
|
|
|
from app.libraries.database import Database
|
|
|
|
from app.libraries.domainblocks import DomainBlocks
|
2022-08-21 20:00:02 +02:00
|
|
|
from mastodon import Mastodon
|
|
|
|
|
2023-04-13 18:01:18 +02:00
|
|
|
# main
|
2022-08-21 20:00:02 +02:00
|
|
|
|
2023-04-13 18:01:18 +02:00
|
|
|
if __name__ == '__main__':
|
2022-08-21 20:00:02 +02:00
|
|
|
|
2023-04-13 18:01:18 +02:00
|
|
|
setup = Setup()
|
2022-08-21 20:00:02 +02:00
|
|
|
|
2023-04-13 18:01:18 +02:00
|
|
|
db = Database()
|
2022-08-21 20:00:02 +02:00
|
|
|
|
2023-04-13 18:01:18 +02:00
|
|
|
blocker = DomainBlocks()
|
2022-08-21 20:00:02 +02:00
|
|
|
|
2023-04-13 18:01:18 +02:00
|
|
|
mastodon = Mastodon(
|
|
|
|
access_token = setup.mastodon_app_token,
|
|
|
|
api_base_url= setup.mastodon_hostname
|
2022-08-21 20:00:02 +02:00
|
|
|
)
|
|
|
|
|
2022-08-21 20:59:54 +02:00
|
|
|
soft_list = 'software.txt'
|
|
|
|
|
|
|
|
soft_file = open(soft_list, 'r')
|
|
|
|
|
|
|
|
Lines = soft_file.readlines()
|
2022-08-21 20:00:02 +02:00
|
|
|
|
2022-08-31 08:12:27 +02:00
|
|
|
for softline in Lines:
|
2022-08-21 20:59:54 +02:00
|
|
|
|
2022-08-31 08:12:27 +02:00
|
|
|
split_char = ' '
|
|
|
|
|
|
|
|
software = softline.partition(split_char)[0]
|
|
|
|
|
|
|
|
private_comment = softline.partition(split_char)[2]
|
|
|
|
|
|
|
|
public_comment = softline.partition(split_char)[2]
|
2022-08-21 20:59:54 +02:00
|
|
|
|
|
|
|
print(f'checking software {software}...')
|
|
|
|
|
2023-04-13 18:01:18 +02:00
|
|
|
servers_list = db.get_servers(software)
|
2022-08-21 20:00:02 +02:00
|
|
|
|
2022-08-21 20:59:54 +02:00
|
|
|
for server in servers_list:
|
2022-08-21 20:00:02 +02:00
|
|
|
|
2023-04-13 18:01:18 +02:00
|
|
|
blocker.domain_blocks_create(server, private_comment, public_comment)
|
2022-08-21 20:00:02 +02:00
|
|
|
|
|
|
|
|
|
|
|
|