Chatterino / chatterino2

Chat client for https://twitch.tv
MIT License
2.07k stars 449 forks source link

Deal with Channel::isTwitchChannel #5703

Open Mm2PL opened 2 weeks ago

Mm2PL commented 2 weeks ago

Checklist

Describe your issue

Currently client-side channels are "Twitch" channels for isTwitchChannel and have Twitch in the channel type enum. However they cannot be cast to TwitchChannel.

We should rework channel types, to resolve the type >= Twitch && type < TwitchEnd but can't be cast to TwitchChannel problem.

    enum class Type {
        None, // Unused? empty?
        Direct, // Actually indirect channel, not sure where it's used though
        Twitch, // Normal Twitch channel like #pajlada
        // can execute commands, but not send messages, there are no moderator privileges, no vips, no broadcasters,
        // no stream titles, ...
        TwitchWhispers, 
        TwitchWatching,
        TwitchMentions, // this could be made into a generic channel, there is no point of it being Twitch specifically, it's not a TwitchChannel anyway.
        TwitchLive,
        TwitchAutomod,
        TwitchEnd,
        Misc, // this is for local testing channels, can be left as is
    };

The minimal modifications here would be:

    enum class Type {
        None,
        Direct,
        Twitch, // Normal Twitch channel like #pajlada
        Whispers, 
        Watching,
        Mentions,
        Live,
        Automod,
        Misc, // this is for local testing channels, can be left as is
    };
// make Channel::isTwitchChannel into:
bool Channel::isTwitchChannel() const {
    return this->type_ == Channel::Type::Twitch;
}

There was an idea where instead of having an enum for a channel we instead would have some kind of flags for what traits supports, ex:

enum ChannelFlags {
    PERMISSIONS = (1 << 0), // mods, vips, ...
    TWITCH_COMMANDS = (1<<1), // allow for /w and friends to run
    LOCAL = (1<<2),
    STREAM_TITLE = (1<<3),
    INDIRECT = (1<<4), // collects messages from more than one other channel, 
    // this could be used to add channel links at the start of messages (like /mentions)
};
Channel types would then be: name flags comment
None LOCAL
Direct LOCAL Leave this without INDIRECT flag,
Twitch PERMISSIONS+TWITCH_COMMANDS+STREAM_TITLE
TwitchWhispers LOCAL+TWITCH_COMMANDS
TwitchWatching LOCAL+TWITCH_COMMANDS only one channel, so no need for INDIRECT
TwitchMentions LOCAL+INDIRECT
TwitchLive LOCAL
TwitchAutomod LOCAL+INDIRECT
TwitchEnd N/A A channel of this type shouldn't need to exist
Misc LOCAL

Screenshots

No response

OS and Chatterino Version

commit 5b1ce32a4e0afaa160ca4b6918914216483884b5 (HEAD -> master, origin/master, origin/HEAD)