Skip to content

feat: Add configurable join/leave templates and role-based /smite command#447

Open
AhmedMoustafaa wants to merge 1 commit intoshazow:masterfrom
AhmedMoustafaa:feature/custom-announcements
Open

feat: Add configurable join/leave templates and role-based /smite command#447
AhmedMoustafaa wants to merge 1 commit intoshazow:masterfrom
AhmedMoustafaa:feature/custom-announcements

Conversation

@AhmedMoustafaa
Copy link
Copy Markdown

Summary

This PR introduces three new CLI flags to allow server administrators to customize the user experience and generalizes the /smite command to work for any designated operator.

Changes

  • New CLI Flags:
    • --op-hubris: Enables a specialized bold/yellow prefix for Operator join and leave events.
    • --announce-join: Allows custom string templates for join messages (e.g., "Mortal %s has entered."). Defaults to the original %s joined..
    • --announce-leave: Allows custom string templates for leave messages. Defaults to the original %s left..
  • Generalized /smite Command:
    • Removed hardcoded username checks.
    • The command now uses the internal isOp validation, allowing any admin (defined via --admin) to utilize the smite functionality.
  • Interface Compliance & Stability:
    • Updated the Member struct in chat/room.go to fully implement the set.Item interface by adding Key() string and Value() interface{} methods.
    • This ensures safe type-assertion during room events and prevents panics when retrieving members from the internal set.

Technical Details

The implementation uses fmt.Sprintf to inject the username into the provided templates. By providing default values in the Options struct, this change is fully backwards compatible; existing users will see no change in behavior unless they explicitly use the new flags.

Why this is useful

Different communities (gaming, technical, or private teams) often want to theme their chat servers. These flags allow for complete branding and "flavor" of the server announcements without requiring a custom fork or hardcoding strings into the binary.


Note: Compiled and tested on Ubuntu with Go 1.20+. Compliance with the set library interface has been verified to prevent runtime panics.

@shazow
Copy link
Copy Markdown
Owner

shazow commented Mar 21, 2026

Hi Ahmed, appreciate you messing around with the codebase but ssh-chat v1 is currently in maintenance mode, so I won't be merging new features in this branch. But if you'd like to maintain a fork with additional feature, I'd love to link to it!

@AhmedMoustafaa
Copy link
Copy Markdown
Author

Hi Ahmed, appreciate you messing around with the codebase but ssh-chat v1 is currently in maintenance mode, so I won't be merging new features in this branch. But if you'd like to maintain a fork with additional feature, I'd love to link to it!

Thanks for the context, Shazow! Totally understood. I'll keep the fork going and clean it up properly. Would love to have it linked here. Appreciate you taking the time to look at it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants