|
|
@ -11,12 +11,18 @@ from utils.config import get_parameter, init_log, init_mastodon |
|
|
|
|
|
|
|
import requests, os, random, sys, time, json, logging, argparse, re |
|
|
|
|
|
|
|
config_file = "config.txt" |
|
|
|
secrets_filepath = "secrets/secrets.txt" |
|
|
|
log_filepath = "activity.log" |
|
|
|
config_file = "config.txt" |
|
|
|
secrets_filepath = "secrets/secrets.txt" |
|
|
|
log_filepath = "activity.log" |
|
|
|
blacklist_filepath = "blacklist.json" |
|
|
|
log = init_log(log_filepath) |
|
|
|
mastodon = init_mastodon(config_file, secrets_filepath) |
|
|
|
|
|
|
|
blacklist_file = open(blacklist_filepath,'r') |
|
|
|
BLACKLIST = json.loads(blacklist_file.read()) |
|
|
|
blacklist_file.close() |
|
|
|
|
|
|
|
|
|
|
|
def post_img(mastodon, text, log, config): |
|
|
|
img_path = get_parameter("img_path", config) |
|
|
|
file = random.choice(os.listdir(img_path+"/")) |
|
|
@ -50,6 +56,9 @@ class BotListener(StreamListener): |
|
|
|
log.debug("Got a mention") |
|
|
|
if notification["account"]["bot"] == False: |
|
|
|
sender = notification['account']['acct'] # Get sender name |
|
|
|
if sender in BLACKLIST: |
|
|
|
log.info("Service refused to %s" % sender) |
|
|
|
return |
|
|
|
sender_hour_filename = "limiter/hour/" + sender; # Forge file for limiter |
|
|
|
sender_minute_filename = "limiter/minute/" + sender; # Forge file for limiter |
|
|
|
|
|
|
|