Skip to content

Commit d086f5d

Browse files
authored
Merge pull request #33 from Local-Connectivity-Lab/py313
Porting to python3.13 and the latest packages
2 parents e5dbe3f + 637b6ad commit d086f5d

File tree

16 files changed

+455
-44
lines changed

16 files changed

+455
-44
lines changed

.github/workflows/python-app.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ jobs:
1919

2020
steps:
2121
- uses: actions/checkout@v3
22-
- name: Set up Python 3.11
22+
- name: Set up Python 3.13
2323
uses: actions/setup-python@v3
2424
with:
25-
python-version: "3.11"
25+
python-version: "3.13"
2626
- name: Install dependencies
2727
run: |
2828
python -m pip install --upgrade pip

.python-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.13

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM python:3.11
1+
FROM python:3.13
22

33
WORKDIR /usr/src/app
44

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@ run: venv
1919
venv: $(VENV)/bin/activate
2020

2121
$(VENV)/bin/activate: requirements.txt
22-
python3.11 -m venv $(VENV)
22+
python3 -m venv $(VENV)
2323
$(PIP) install --upgrade pip
2424
$(PIP) install -r requirements.txt
25+
#$(PIP) install --upgrade dateparser humanize IMAPClient py-cord python-dotenv requests audioop-lts
2526

2627
test: $(VENV)/bin/activate
2728
$(PYTHON) -m tests

main.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
def main():
2+
print("Hello from netbot!")
3+
4+
5+
if __name__ == "__main__":
6+
main()

netbot/cog_tickets.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -438,12 +438,13 @@ async def assign(self, ctx: discord.ApplicationContext, ticket_id:int, member:di
438438

439439

440440
async def create_thread(self, ticket:Ticket, ctx:discord.ApplicationContext):
441-
log.info(f"creating a new thread for ticket #{ticket.id} in channel: {ctx.channel}")
441+
log.info(f"creating a new thread for ticket #{ticket.id} in channel: {ctx.channel.name}")
442442
thread_name = f"Ticket #{ticket.id}: {ticket.subject}"
443443
if isinstance(ctx.channel, discord.Thread):
444-
log.debug(f"creating thread in parent channel {ctx.channel.parent}, for {ticket}")
444+
log.debug(f"creating thread in parent channel {ctx.channel.parent.name}, for {ticket}")
445445
thread = await ctx.channel.parent.create_thread(name=thread_name, type=discord.ChannelType.public_thread)
446446
else:
447+
log.debug(f"creating thread in channel {ctx.channel.name}, for {ticket}")
447448
thread = await ctx.channel.create_thread(name=thread_name, type=discord.ChannelType.public_thread)
448449
# ticket-614: Creating new thread should post the ticket details to the new thread
449450
await thread.send(self.bot.formatter.format_ticket_details(ticket))
@@ -520,10 +521,11 @@ async def thread(self, ctx: discord.ApplicationContext, ticket_id:int):
520521

521522
# check if sync data exists for a different channel
522523
synced = ticket.get_sync_record()
523-
if synced and synced.channel_id != ctx.channel_id:
524+
if synced and synced.channel_id != ctx.channel.id:
524525
thread = self.bot.get_channel(synced.channel_id)
525526
if thread:
526-
await ctx.respond(f"Ticket {ticket_link} already synced with {thread.jump_url}")
527+
url = thread.jump_url
528+
await ctx.respond(f"Ticket {ticket_link} already synced with {url}")
527529
return # stop processing
528530
else:
529531
log.info(f"Ticket {ticket_id} synced with unknown thread ID {synced.channel_id}. Recovering.")
@@ -533,14 +535,17 @@ async def thread(self, ctx: discord.ApplicationContext, ticket_id:int):
533535

534536
# create the thread...
535537
thread = await self.create_thread(ticket, ctx)
538+
url = thread.jump_url
536539

537540
# update the discord flag on tickets, add a note with url of thread; thread.jump_url
538-
note = f"Created Discord thread: {thread.name}: {thread.jump_url}"
541+
name = thread.name
542+
note = f"Created Discord thread: {name}: {url}"
539543
user = self.redmine.user_mgr.find_discord_user(ctx.user.name)
540-
self.redmine.enable_discord_sync(ticket.id, user, note)
544+
self.redmine.ticket_mgr.enable_discord_sync(ticket.id, user, note)
541545

542546
# ticket-614: add ticket link to thread response
543-
await ctx.respond(f"Created new thread {thread.jump_url} for ticket {ticket_link}")
547+
log.info('CTX5 %s', vars(ctx))
548+
await ctx.respond(f"Created new thread {url} for ticket {ticket_link}")
544549
else:
545550
await ctx.respond(f"ERROR: Unkown ticket ID: {ticket_id}")
546551

pyproject.toml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[project]
2+
name = "netbot"
3+
version = "0.1.0"
4+
description = "Add your description here"
5+
readme = "README.md"
6+
requires-python = ">=3.13"
7+
dependencies = [
8+
"aiohttp>=3.11.12",
9+
"audioop",
10+
"dateparser>=1.2.1",
11+
"discord>=2.3.2",
12+
"humanize>=4.12.0",
13+
"python-dotenv>=1.0.1",
14+
"requests>=2.32.3",
15+
]

redmine/redmine.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -134,14 +134,3 @@ def find_ticket_from_str(self, string:str) -> Ticket:
134134
else:
135135
log.debug(f"Unable to match ticket number in: {string}")
136136
return []
137-
138-
139-
def enable_discord_sync(self, ticket_id, user, note):
140-
fields = {
141-
"note": note, #f"Created Discord thread: {thread.name}: {thread.jump_url}",
142-
"cf_1": "1", # TODO: read from custom fields via
143-
}
144-
145-
self.ticket_mgr.update(ticket_id, fields, user.login)
146-
# currently doesn't return or throw anything
147-
# todo: better error reporting back to discord

redmine/tickets.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -514,13 +514,13 @@ def get_notes_since(self, ticket_id:int, timestamp:dt.datetime=None) -> list[Tic
514514
return ticket.get_notes(since=timestamp)
515515

516516

517-
def enable_discord_sync(self, ticket_id, user, note):
517+
def enable_discord_sync(self, ticket_id:int, user:User, note:str) -> Ticket:
518518
fields = {
519-
"note": note, #f"Created Discord thread: {thread.name}: {thread.jump_url}",
519+
"note": note,
520520
"cf_1": "1", # TODO: lookup in self.get_field_id
521521
}
522522

523-
self.update(ticket_id, fields, user.login)
523+
return self.update(ticket_id, fields, user.login)
524524
# currently doesn't return or throw anything
525525
# todo: better error reporting back to discord
526526

requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
dateparser==1.2.1
22
humanize==4.12.0
33
IMAPClient==3.0.1
4-
py-cord==2.4.1
4+
py-cord==2.6.1
55
python-dotenv==1.0.1
66
requests==2.32.3
7+
audioop-lts==0.2.1
78
coverage==7.6.12

0 commit comments

Comments
 (0)