Commit graph

126 commits

Author SHA1 Message Date
Mish
4c3775d7c0
Bring back AI titles! (#109)
* Rewrite ticket title gen to use the new HC AI

* Use implicit string concatenation

* Use async OpenAI

* Guard against single-letter or all-whitespace AI responses

* Add a singular space
2025-11-16 12:45:47 +00:00
Mish
c2b73dcb96
Add a perf_timer() utility for timing blocks of code (#108)
* Add a perf_timer() utility for timing blocks of code

It has replaced raw perf_counter() calls in some files.

* Use perf_timer in ticket_status_pie.py

* Use perf_timer() for app home performance logging

* Remove plt.show() call

That was never meant to be there :pf:

* Print performance logs as debug logs
2025-11-15 21:46:14 +00:00
Mish
bb0fd03907
Fix log level logic being the wrong way around (#103) 2025-11-15 15:47:21 +00:00
Mish
68b2eb1e41
Make logging level configurable with an ENV var (#102) 2025-11-15 15:32:09 +00:00
Mish
8230f8560b
That's Leo, not Mish! (#101) 2025-11-15 15:13:55 +00:00
Mish
9e20174062
Split nephthys/events/message.py into procedures (#100)
* Extract some of the message handler into functions

* Add a send_user_facing_message function

* Improve type hints

* Remove redundant if statement check

* Remove unnecessary indentation

* Declare constant outside of function

* Add docstrings to 2 functions

Credit to GH Copilot :P

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Fix docstrings

* Add send_ticket_message docstring

* Fix profile_pic being set to "" instead of None

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-11-11 03:13:38 +00:00
Mish
accd86610e
Add a Docker healthcheck (#99)
* Add a Docker healthcheck

* Fix regexp

* Add --start-period to healthcheck
2025-11-11 02:28:28 +00:00
Chase Naples
20f7e8571b
chore: fill pyproject description (#98) 2025-11-10 12:37:33 +00:00
Amber
ea871bbc5d
update midnight faq (#95) 2025-11-08 21:18:17 +00:00
MMK21
415ee8576f
Rename "i get it now" button to "Mark as resolved" (#94)
* Add resolve_ticket_button to transcript

I also set "Mark as resolved" as the default wording for all instances

* Change button text back to "i get it now" for SoM and Identity

Backwards compatibility!
I think Midnight would be fine with the new default
2025-11-04 20:41:22 +00:00
Amber
76d6fa41a1
import midnight transcript (#91) 2025-11-03 18:42:02 +00:00
Leo
e857fe5b1e
add midnight transcript (#90) 2025-11-03 18:19:46 +00:00
MMK21
b54694e62d
Add a Prometheus metrics endpoint (#84)
* Add a Prometheus metrics endpoint

* Add starlette_exporter metrics

* Add Prisma metrics  to `/metrics`
2025-10-28 23:42:32 +00:00
MMK21
1a3818e413
Ensure the bot maintainer is always an admin (#88) 2025-10-28 23:16:49 +00:00
MMK21
c2f2584101
Make the header in app home configurable (#87)
* Add an app_title env var

* Use app_title in app home

* Fix header being wrapped in a tuple
2025-10-28 22:38:30 +00:00
MMK21
8f96d64267
Add files:write scope to app manifest (#86) 2025-10-28 22:37:25 +00:00
MMK21
f4fe7c3e9e
Improve response time when a new help message is sent (#82)
* Add a bunch of performance logs to on_message

* Remove duplicate DB user lookup

* Ensure Slack user info is only fetched once

* Make AI title generation happen after the FAQ message has been sent

* Make the performance logging debug-level

* Fix some perf calculations being incorrect

* Add type hint
2025-10-27 20:45:35 +00:00
MMK21
4e68152d08
Add a transcript for Flavortown (#80)
* Write v1 of the Flavortown transcript

* Remove summer reference from bot manifest

* Mrkdwn doesn't support bullet points, are we fr?

* Actually link help channel in resolve message
2025-10-26 17:01:18 +00:00
MMK21
228f70f835
Document ?reopen (#79) 2025-10-26 16:53:15 +00:00
MMK21
a10d0d4627
Proper fix for deleting messages in the backend channel (#78)
* Actually fix deleting messages in the backend channel

* Always impersonate in backend channel

- Yeah turns out deleting impersonated messages still works with a bot token
- Partially reverts #74
2025-10-26 16:11:54 +00:00
Shreyas Deo
b53e1c57fa
Add reopen macro (#76)
* Add reopen macro

* Move reopen message to transcript.py

* Remove duplicate run_macro calls
2025-10-26 16:08:09 +00:00
MMK21
fcd07e3080
Only impersonate if admin perms are present (#74)
* Implement env.workspace_admin_available()

* Only impersonate if admin perms are present

* Ensure we're accessing `self`'s properties

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-10-25 21:45:47 +00:00
MMK21
6ce7f7dd3e
Add a Dockerignore file (#72)
* Add required library libatomic1 to Dockerfile

* Add a dockerignore file

It used to take like 3 seconds to copy all the files into the Docker image because `.venv` was included.

That isn't needed because we `uv sync` within the container, so builds are slightly faster during development now.
2025-10-25 08:33:57 +00:00
MMK21
bed6f313ca
Overhaul deleted message handling (#73)
* Update DB when unthreaded messages are deleted

* Add required library libatomic1 to Dockerfile (#71)

* Handle quick message deletions

This is a quick and dirty way to handle the bug, but it works.

I also realised that handle_question_deletion() doesn't delete it in #tickets

* Create a system for tracking bot messages attached to tickets

* Ensure resolved message is added to userFacingMsgs

TODO I''ll need to make a function that all the macros can use to send a user-facing message

* Add a reply_to_ticket() helper for updating the DB
while replying to a ticket

* Fix type errors in reply_to_ticket()

* Use reply_to_ticket when resolving tickets

* Fix type errors in message.py

* Create delete_replies_to_ticket()

* Remove unused parameter in delete_replies_to_ticket

* Rename BotMessage.msgTs to BotMessage.ts

* Write a stub delete_and_clean_up_ticket function

* Partially implement delete_and_clean_up_ticket

* Delete "ticket" message in delete_and_clean_up_ticket()

* Use the new ticket methods where appropriate

* Make function name clearer ("delete_bot_replies")

* Log if a question is deleted but not present in DB

* Fix error when normal messages are deleted

* Actually include userFacingMsgs in the query when deleting bot replies

* Add success heartbeat to delete queue

* Document the deletion queue needing workspace admin

* Don't use delete queue in ticket_methods.py

This is because the delete queue requires an admin token, ew

* Fix deleting the backend message on ticket deletion

* Always preserve support threads with >3 bot messages

This is so that if someone runs ?faq, the ticket still counts as being resolved in the DB.

* Debug-log message event data instead of printing

* Use the reply_to_ticket util in macros

---------

Co-authored-by: RandomSearch <101704343+RandomSearch18@users.noreply.github.com>
2025-10-25 07:52:21 +00:00
MMK21
eeb5c3d739
Add required library libatomic1 to Dockerfile (#71) 2025-10-22 22:37:01 +00:00
MMK21
8a83580fe8
Delete bot messages and database entries if a thread is deleted (#69)
* Differentiate between message creation and deletion

* Add a comment to explain thread_broadcast

* If top-level message gets deleted, then delete bot messages

* Ensure top-level messages being deleted don't cause errors

It would previously freak out when the tombstone message gets deleted :P

* Remove deleted tickets from DB

* Actually delete the correct ticket

* Ensure unexpected SlackApiErrors are re-raised

* refactor: Move deleted message handling into its own file
2025-10-21 20:51:43 +00:00
MMK21
feb251de91
Fix tags (#67)
* Update readme re tags and stale

* Enable messages tab for the Slack app

This makes tags actually function as intended
2025-10-21 14:59:54 +00:00
MMK21
1dc54555c8
Ignore bot messages in the support channel (#60) 2025-10-21 14:40:55 +00:00
MMK21
5e5cc49b6e
Improve performance of pie chart generation by using db.ticket.count() (#62)
* Add some logging for time spent generating the Dashboard

* Start adding perf logging to get_ticket_status_pie_chart

* Add more detailed logs to ticket_status_pie

* Use db.ticket.count() instead of fetching all tickets for pie chart

Querying the database used to take 0.25s avg, now the query takes 0.028s avg (tested with 20k records)

Generating pie chart used to take 1.3s, now it's 0.74s. That's a 43% speedup I think! Although the pie chart isn't the only thing that takes time to load on the dashboard.

* Remove status_counts dict

I think the code reads nicer without the extra dict. Now we just have each variable listed inline in a list, which matches how the labels and colours are defined.

* Downgrade profiling logs to DEBUG level
2025-10-21 09:37:46 +00:00
MMK21
3029ca9627
Add a VSCode launch.json (#64)
This makes debugging with breakpoints etc easier in VSC
2025-10-21 09:31:45 +00:00
MMK21
e3daf55718
Add a script for creating dummy DB records (#63)
* Add a script for creating dummy DB records

* Note that add_dummy_data takes a while to run

* Change the dummy data range to 2 weeks

* Ensure the dummy data script sets all the timestamps

Previously it wouldn't set assignedAt, closedAt, etc, despite the ticket being marked as closed
2025-10-20 23:06:36 +00:00
MMK21
ced679ea96
Configure CodeQL scans using YAML (#65)
This is so that we can run CodeQL scans on PRs from forks (which doesn't happen by default)
2025-10-20 23:03:29 +00:00
transcental
bfe65d8ff2
don't count self-closed tickets & show if helper 2025-10-06 13:58:55 +01:00
transcental
7106145255
user stats api 2025-10-06 13:50:16 +01:00
transcental
cb7f7908c0
add config to disable daily summary 2025-09-29 00:46:29 +01:00
twonfi
22c859915a Update ?thread explanation
It now removes reactions and Nephthys messages from the thread

No copilot, I don't want you to vibe write a commit message
2025-08-31 16:35:42 +01:00
twonfi
872c8aeeb4 fix: Return once macro run 2025-08-31 16:35:42 +01:00
twonfi
d1c2aaf4cb Delete own messages and remove reaction instead
https://github.com/hackclub/nephthys/pull/50#pullrequestreview-3166968776
2025-08-31 16:35:42 +01:00
twonfi
218ebeb14a feat: Add ?thread to ask to use Slack threads
This also reacts to the message with the thread emoji (de-facto standard practice on Slack)

closes #22
2025-08-31 16:35:42 +01:00
Amber
fe392885a5
migrate from litterbox to bucky for temporary image hosting 2025-08-29 15:16:49 +01:00
Arca Ege Cengiz
e03c325576 Added ?fraud and ?shipcertqueue to README 2025-08-28 14:08:43 +01:00
transcental
d8d2f16e3c
move to upload files v2 for daily stats 2025-08-27 14:49:41 +01:00
transcental
8a7fef02db add graph to daily stats 2025-08-26 11:40:43 +00:00
transcental
fe5c151577
don't show all closed tickets in the graph, just last week 2025-08-22 17:08:43 +01:00
Oliver Potter
7b2a99bcff fix: run pre-commit 2025-08-11 14:21:25 +01:00
Oliver Potter
ecad7cbf0a feat: fraud and shipcertqueue macros 2025-08-11 14:21:25 +01:00
MMK21Hub
3649ac9371 Add average hang time to the stats endpoint 2025-08-11 14:20:18 +01:00
MMK21Hub
1b9e12d790 Add SLACK_HELP_CHANNEL to .env.sample 2025-08-11 14:16:15 +01:00
MMK21Hub
49bdd9a706 Remove reference to YOUR_URL
The manifest.yml doesn't contain the phrase YOUR_URL (any more?)
2025-08-11 14:16:15 +01:00
MMK21Hub
e3188b96bc Mention that you need a postgres db 2025-08-11 14:16:15 +01:00