From bb91e84f241c5d01643451895e5eee5ad42169e5 Mon Sep 17 00:00:00 2001 From: extreme4all <40169115+extreme4all@users.noreply.github.com> Date: Sun, 17 Nov 2024 21:36:21 +0100 Subject: [PATCH] cleanup --- .env-example | 1 + .pre-commit-config.yaml | 10 ---- deployment.yaml | 24 -------- src/jobs/banbroadcaster/functions.py | 86 ++++++++++++++-------------- src/jobs/kafka/players/main.py | 2 +- 5 files changed, 46 insertions(+), 77 deletions(-) delete mode 100644 .pre-commit-config.yaml delete mode 100644 deployment.yaml diff --git a/.env-example b/.env-example index f83e37b..dd93b85 100644 --- a/.env-example +++ b/.env-example @@ -8,6 +8,7 @@ JMOD_TAG = SERVER_LOGIN = SERVER_PASSWORD = SERVER_ADDRESS = +SERVER_PORT=3306 DATABASE = GRAVEYARD_WEBHOOK = diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml deleted file mode 100644 index 06de33f..0000000 --- a/.pre-commit-config.yaml +++ /dev/null @@ -1,10 +0,0 @@ -repos: - - repo: https://github.com/psf/black - rev: 23.10.1 - hooks: - - id: black - - repo: https://github.com/pycqa/isort - rev: 5.12.0 - hooks: - - id: isort - args: ["--profile", "black"] diff --git a/deployment.yaml b/deployment.yaml deleted file mode 100644 index 27bf6c4..0000000 --- a/deployment.yaml +++ /dev/null @@ -1,24 +0,0 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - name: bd-automations -spec: - selector: - matchLabels: - app: bd-automations - replicas: 1 - template: - metadata: - labels: - app: bd-automations - spec: - containers: - - name: bd-automations - image: hub.osrsbotdetector.com/bot-detector/bd-automations:latest - imagePullPolicy: Always - resources: - limits: - cpu: "500m" - memory: "750Mi" - imagePullSecrets: - - name: regcred diff --git a/src/jobs/banbroadcaster/functions.py b/src/jobs/banbroadcaster/functions.py index 73cbe0a..887badf 100644 --- a/src/jobs/banbroadcaster/functions.py +++ b/src/jobs/banbroadcaster/functions.py @@ -2,11 +2,13 @@ import operator import time from collections import namedtuple -from datetime import datetime + +# from datetime import datetime from typing import List import mysql.connector -import tweepy + +# import tweepy from discord_webhook import DiscordWebhook from discord_webhook.webhook import DiscordEmbed @@ -16,11 +18,11 @@ logger = logging.getLogger(__name__) -AUTH = tweepy.OAuthHandler( - consumer_key=config.CONSUMER_KEY, consumer_secret=config.CONSUMER_SECRET -) -AUTH.set_access_token(key=config.ACCESS_TOKEN, secret=config.ACCESS_TOKEN_SECRET) -TWITTER_API = tweepy.API(AUTH, wait_on_rate_limit=True) +# AUTH = tweepy.OAuthHandler( +# consumer_key=config.CONSUMER_KEY, consumer_secret=config.CONSUMER_SECRET +# ) +# AUTH.set_access_token(key=config.ACCESS_TOKEN, secret=config.ACCESS_TOKEN_SECRET) +# TWITTER_API = tweepy.API(AUTH, wait_on_rate_limit=True) config_players = { @@ -175,57 +177,57 @@ def broadcast_names(names_list: List[str]): time.sleep(5) -def post_bans_tweet(num_bans: int): - logger.debug("Posting Ban Tweet") - msg = f"BANS ALERT - {datetime.now().strftime('%d-%m-%Y')}: {num_bans:,d} accounts our system has detected as bots have been banned in the past 24 hours." - TWITTER_API.update_status(msg) +# def post_bans_tweet(num_bans: int): +# logger.debug("Posting Ban Tweet") +# msg = f"BANS ALERT - {datetime.now().strftime('%d-%m-%Y')}: {num_bans:,d} accounts our system has detected as bots have been banned in the past 24 hours." +# TWITTER_API.update_status(msg) -def post_breakdown_tweets(predictions: List[str]): - logger.debug("Posting Breakdown Tweet") - tweets = generate_breakdown_tweets(predictions) +# def post_breakdown_tweets(predictions: List[str]): +# logger.debug("Posting Breakdown Tweet") +# tweets = generate_breakdown_tweets(predictions) - if len(tweets) == 0: - return +# if len(tweets) == 0: +# return - previous_status = None +# previous_status = None - for i, tweet in enumerate(tweets): - tweet += f"({i+1}/{len(tweets)})" +# for i, tweet in enumerate(tweets): +# tweet += f"({i+1}/{len(tweets)})" - if i == 0: - previous_status = TWITTER_API.update_status(tweet) - else: - previous_status = TWITTER_API.update_status( - tweet, in_reply_to_status_id=previous_status.id - ) +# if i == 0: +# previous_status = TWITTER_API.update_status(tweet) +# else: +# previous_status = TWITTER_API.update_status( +# tweet, in_reply_to_status_id=previous_status.id +# ) - time.sleep(3) +# time.sleep(3) - return +# return -def generate_breakdown_tweets(predictions: List[str]): - logger.info("Generating Breakdown Tweet") - predictions_groupings = group_predictions(predictions) +# def generate_breakdown_tweets(predictions: List[str]): +# logger.info("Generating Breakdown Tweet") +# predictions_groupings = group_predictions(predictions) - tweets = [] +# tweets = [] - current_tweet = "Bans by Category:\n" +# current_tweet = "Bans by Category:\n" - for pred, count in predictions_groupings.items(): - pred_string = f"{pred}: {count}\n" +# for pred, count in predictions_groupings.items(): +# pred_string = f"{pred}: {count}\n" - if (len(current_tweet) + len(pred_string)) >= 240: - tweets.append(current_tweet) - current_tweet = pred_string - else: - current_tweet += pred_string +# if (len(current_tweet) + len(pred_string)) >= 240: +# tweets.append(current_tweet) +# current_tweet = pred_string +# else: +# current_tweet += pred_string - # Grab the leftovers! - tweets.append(current_tweet) +# # Grab the leftovers! +# tweets.append(current_tweet) - return tweets +# return tweets def group_predictions(predictions: List[str]): diff --git a/src/jobs/kafka/players/main.py b/src/jobs/kafka/players/main.py index a8c0194..8f1a086 100644 --- a/src/jobs/kafka/players/main.py +++ b/src/jobs/kafka/players/main.py @@ -243,4 +243,4 @@ async def main(): def get_players_to_scrape(): - asyncio.ensure_future(main()) + asyncio.run(main())