Skip to content

Commit

Permalink
Merge pull request #103 from akrherz/bump
Browse files Browse the repository at this point in the history
Bump ruff
  • Loading branch information
akrherz authored Jan 13, 2025
2 parents 1a70523 + 05a98e7 commit 8e2a708
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
7 changes: 3 additions & 4 deletions src/iembot/basicbot.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -418,7 +417,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 "
Expand Down Expand Up @@ -735,7 +734,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
Expand Down
21 changes: 2 additions & 19 deletions src/iembot/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down Expand Up @@ -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)


Expand Down Expand Up @@ -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 "
Expand Down

0 comments on commit 8e2a708

Please sign in to comment.