From 11b831b5b2e9acedf0760f4ef13bd9f2b4a47471 Mon Sep 17 00:00:00 2001 From: Lynne Date: Sat, 20 Jul 2019 11:13:12 +1000 Subject: [PATCH] remove unneeded files and dependencies --- reply.py | 128 ---------------------------------------- requirements.txt | 1 - systemd-example.service | 16 ----- 3 files changed, 145 deletions(-) delete mode 100644 reply.py delete mode 100644 systemd-example.service diff --git a/reply.py b/reply.py deleted file mode 100644 index 5e7488b..0000000 --- a/reply.py +++ /dev/null @@ -1,128 +0,0 @@ -#!/usr/bin/env python3 -# Copyright (C) 2019 Lynne (@lynnesbian@fedi.lynnesbian.space) - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published -# by the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. - -from mastodon import Mastodon, StreamListener -from bs4 import BeautifulSoup - -# use multiprocessing to run multiple reply listener threads at once -# this means we can handle more than one reply at a time! -from multiprocessing import Pool -import os, random, re, json, re, sys - -try: - cfg = json.load(open('config.json', 'r')) -except: - print("Couldn't load config.json. Make sure you run login.py first!\n-----") - raise -meta = json.load(open('meta.json', 'r')) - -print("Logging in...") - -client = Mastodon( - client_id=cfg['client']['id'], - client_secret=cfg['client']['secret'], - access_token=cfg['secret'], - api_base_url=cfg['site']) - -# extract the handle (the @username@instance part) -handle = "@{}@{}".format(client.account_verify_credentials()['username'], re.match("https://([^/]*)/?", cfg['site']).group(1)).lower() - -# convert the text of the status to plain text -# this part's a bit of a mess!! -def extract_toot(toot): - toot = toot.replace("'", "'") #convert HTML stuff to normal stuff - toot = toot.replace(""", '"') #ditto - soup = BeautifulSoup(toot, "html.parser") - for lb in soup.select("br"): #replace
with linebreak - lb.insert_after("\n") - lb.decompose() - - for p in soup.select("p"): #ditto for

- p.insert_after("\n") - p.unwrap() - - for ht in soup.select("a.hashtag"): #make hashtags no longer links, just text - ht.unwrap() - - for link in soup.select("a"): #convert