From a49c86fd3f7a53057422d5618dbfda19cd2c8054 Mon Sep 17 00:00:00 2001 From: akrherz Date: Mon, 13 Jan 2025 15:34:02 -0600 Subject: [PATCH 1/4] =?UTF-8?q?=E2=AC=86=EF=B8=8F=20Update=20ruff?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d5a60c2..f17d483 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -2,7 +2,7 @@ ci: autoupdate_schedule: quarterly repos: - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.8.6" + rev: "v0.9.1" hooks: - id: ruff args: [--fix, --exit-non-zero-on-fix] From aebafc5d3891b957f51c7a19cca3ea0bd7f531e0 Mon Sep 17 00:00:00 2001 From: akrherz Date: Mon, 13 Jan 2025 15:42:38 -0600 Subject: [PATCH 2/4] =?UTF-8?q?=F0=9F=93=9D=20Sundry=20python=20lint?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/iembot/basicbot.py | 6 +++--- src/iembot/util.py | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/iembot/basicbot.py b/src/iembot/basicbot.py index 0e922c0..7e9fd19 100644 --- a/src/iembot/basicbot.py +++ b/src/iembot/basicbot.py @@ -1,13 +1,13 @@ """Basic iembot/nwsbot implementation.""" import copy -import datetime import os import pickle import random import re import traceback from collections import namedtuple +from datetime import timedelta from io import StringIO from xml.etree import ElementTree as ET @@ -418,7 +418,7 @@ def compute_daily_caller(self): """Figure out when to be called""" log.msg("compute_daily_caller() called...") # Figure out when to spam all rooms with a timestamp - utcnow = utc() + datetime.timedelta(days=1) + utcnow = utc() + timedelta(days=1) tnext = utcnow.replace(hour=0, minute=0, second=0) log.msg( "Initial Calling daily_timestamp in " @@ -735,7 +735,7 @@ def handle_flood_request(self, elem, bstring): with star trek quotes, yes! """ _from = jid.JID(elem["from"]) - if not re.match(r"^nws-", _from.user): + if not re.match("^nws-", str(_from.user)): msg = "Sorry, you must be NWS to flood a chatroom!" self.send_privatechat(elem["from"], msg) return diff --git a/src/iembot/util.py b/src/iembot/util.py index 12f1639..ec01644 100644 --- a/src/iembot/util.py +++ b/src/iembot/util.py @@ -456,7 +456,7 @@ def twitter_errback(err, bot, user_id, tweettext): disable_twitter_user(bot, user_id, errcode) else: sn = bot.tw_users.get(user_id, {}).get("screen_name", "") - msg = f"User: {user_id} ({sn})\n" f"Failed to tweet: {tweettext}" + msg = f"User: {user_id} ({sn})\nFailed to tweet: {tweettext}" email_error(err, bot, msg) @@ -534,7 +534,7 @@ def mastodon_errback(err, bot, user_id, tweettext): disable_mastodon_user(bot, user_id, errcode) else: sn = bot.md_users.get(user_id, {}).get("screen_name", "") - msg = f"User: {user_id} ({sn})\n" f"Failed to toot: {tweettext}" + msg = f"User: {user_id} ({sn})\nFailed to toot: {tweettext}" email_error(err, bot, msg) From 49807f24806e55a44c29c49dfb54f97def07bc05 Mon Sep 17 00:00:00 2001 From: akrherz Date: Mon, 13 Jan 2025 15:46:43 -0600 Subject: [PATCH 3/4] =?UTF-8?q?=F0=9F=90=9B=20Specify=20connect=20user?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- conftest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conftest.py b/conftest.py index 3cae0d1..daff8e5 100644 --- a/conftest.py +++ b/conftest.py @@ -16,6 +16,6 @@ def bot(): @pytest.fixture() def dbcursor(database): """Yield a cursor for the given database.""" - dbconn, cursor = get_dbconnc(database) + dbconn, cursor = get_dbconnc(database, user="mesonet") yield cursor dbconn.close() From 05a98e7e0beb11ceb06508be8d21bc59eb7978af Mon Sep 17 00:00:00 2001 From: akrherz Date: Mon, 13 Jan 2025 16:14:23 -0600 Subject: [PATCH 4/4] =?UTF-8?q?=F0=9F=94=A5=20Drop=20syndication=20db=20lo?= =?UTF-8?q?ading?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/iembot/basicbot.py | 1 - src/iembot/util.py | 17 ----------------- 2 files changed, 18 deletions(-) diff --git a/src/iembot/basicbot.py b/src/iembot/basicbot.py index 7e9fd19..ca3a00a 100644 --- a/src/iembot/basicbot.py +++ b/src/iembot/basicbot.py @@ -74,7 +74,6 @@ def __init__( self.webhooks_routingtable = {} self.xmlstream = None self.firstlogin = False - self.syndication = {} self.xmllog = DailyLogFile("xmllog", xml_log_path) self.myjid = None self.ingestjid = None diff --git a/src/iembot/util.py b/src/iembot/util.py index ec01644..2b87761 100644 --- a/src/iembot/util.py +++ b/src/iembot/util.py @@ -567,23 +567,6 @@ def load_chatrooms_from_db(txn, bot, always_join): f"{len(rooms)} rooms" ) - # Now we need to load up the syndication - synd = {} - txn.execute( - f"SELECT roomname, endpoint from {bot.name}_room_syndications " - "WHERE roomname is not null and endpoint is not null" - ) - for row in txn.fetchall(): - rm = row["roomname"] - endpoint = row["endpoint"] - if rm not in synd: - synd[rm] = [] - synd[rm].append(endpoint) - bot.syndication = synd - log.msg( - f"... loaded {txn.rowcount} room syndications for {len(synd)} rooms" - ) - # Load up a list of chatrooms txn.execute( f"SELECT roomname, twitter from {bot.name}_rooms "