-
-
Notifications
You must be signed in to change notification settings - Fork 38
feat: enhance service cogs with improved functionality #959
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Reviewer's GuideThis PR augments existing service cogs by enriching InfluxDB logging with guild stats, streamlining database interactions in the levels service, simplifying status-role loading, strengthening gif-limiter task handling, and introduces a new ReminderService implementing a priority‐queue–driven scheduling loop for user reminders. Sequence diagram for scheduling and sending reminders in ReminderServicesequenceDiagram
participant User
participant ReminderService
participant DatabaseController as DB
participant Discord as DiscordAPI
User->>ReminderService: Create reminder (via command)
ReminderService->>DB: Store reminder
DB-->>ReminderService: Confirmation
ReminderService->>ReminderService: schedule_reminder(reminder)
Note over ReminderService: Reminder added to priority queue
ReminderService->>ReminderService: reminder_processor loop triggers
ReminderService->>ReminderService: send_reminder(reminder)
ReminderService->>DiscordAPI: Send DM to user
alt DM fails
ReminderService->>DiscordAPI: Send in channel
end
ReminderService->>DB: Delete reminder by ID
Class diagram for the new ReminderService and ScheduledReminderclassDiagram
class ReminderService {
- Tux bot
- DatabaseController db
- bool _initialized
- list~ScheduledReminder~ _reminder_queue
- asyncio.Lock _queue_lock
- set~asyncio.Task~ _reminder_tasks
+ __init__(bot: Tux)
+ _create_reminder_task(coro, name)
+ cog_unload()
+ reminder_processor()
+ before_reminder_processor()
+ on_reminder_processor_error(error)
+ schedule_reminder(reminder: Reminder)
+ send_reminder(reminder: Reminder)
+ on_ready()
}
class ScheduledReminder {
+ float timestamp
+ Reminder reminder
}
ReminderService --> ScheduledReminder
ReminderService --> Reminder
ScheduledReminder --> Reminder
Class diagram for updated InfluxLogger (InfluxDB logging)classDiagram
class InfluxLogger {
- Tux bot
- DatabaseController db
- Any|None influx_write_api
- str influx_org
+ __init__(bot: Tux)
+ init_influx() bool
+ _log_guild_stats()
+ before_log_guild_stats()
+ on_log_guild_stats_error(error)
+ logger()
+ before_logger()
+ on_logger_error(error)
+ cog_unload()
}
Class diagram for updated Levels service integrationclassDiagram
class LevelsService {
+ xp_listener(message: discord.Message)
+ process_xp_gain(member: discord.Member, guild: discord.Guild, user_level_data: Levels|None)
+ is_on_cooldown(last_message_time)
+ calculate_xp_increment(member)
}
class Levels {
+ float xp
+ int level
+ bool blacklisted
+ datetime last_message
}
LevelsService --> Levels : uses
Class diagram for updated StatusRoles cogclassDiagram
class StatusRoles {
- Bot bot
- status_roles
+ __init__(bot)
+ on_ready()
+ check_and_update_roles(member)
}
Class diagram for updated GifLimiter cogclassDiagram
class GifLimiter {
+ on_message(message: discord.Message)
+ old_gif_remover()
+ before_old_gif_remover()
+ on_old_gif_remover_error(error)
+ cog_unload()
}
File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
Codecov ReportAttention: Patch coverage is
✅ All tests successful. No failed tests found. Additional details and impacted files@@ Coverage Diff @@
## main #959 +/- ##
========================================
+ Coverage 9.26% 9.33% +0.06%
========================================
Files 123 124 +1
Lines 10390 10514 +124
Branches 1276 1291 +15
========================================
+ Hits 963 981 +18
- Misses 9325 9424 +99
- Partials 102 109 +7
*This pull request uses carry forward flags. Click here to find out more.
☔ View full report in Codecov by Sentry. |
- Add new reminders service - Update levels service integration - Improve influxdb logging capabilities - Enhance gif limiter and status roles
3298959
to
13e1fd4
Compare
Deploying tux with
|
Latest commit: |
13e1fd4
|
Status: | ✅ Deploy successful! |
Preview URL: | https://8cd63c4a.tux-afh.pages.dev |
Branch Preview URL: | https://03-services-split.tux-afh.pages.dev |
Depends on: #957 |
Description
Please include a summary of the changes and the related issue. Please also include relevant motivation and context. List any dependencies that are required for this change. If this change fixes any issues please put "Fixes #XX" in the description. Please also ensure to add the appropriate labels to the PR.
Guidelines
My code follows the style guidelines of this project (formatted with Ruff)
I have performed a self-review of my own code
I have commented my code, particularly in hard-to-understand areas
I have made corresponding changes to the documentation if needed
My changes generate no new warnings
I have tested this change
Any dependent changes have been merged and published in downstream modules
I have added all appropriate labels to this PR
I have followed all of these guidelines.
How Has This Been Tested? (if applicable)
Please describe how you tested your code. e.g describe what commands you ran, what arguments, and any config stuff (if applicable)
Screenshots (if applicable)
Please add screenshots to help explain your changes.
Additional Information
Please add any other information that is important to this PR.
Summary by Sourcery
Add a full-featured reminders service and enhance existing service cogs with improved background tasks, error handling, and configuration checks to strengthen InfluxDB logging, leveling, status roles, and GIF limiting functionality
New Features:
Enhancements: