izzy / stream-chat

OBS Chat Overlay for StreamerBot
MIT License
28 stars 7 forks source link

Refactor of the add/remove message functions to allow multiple sources #24

Open izzy opened 2 years ago

izzy commented 2 years ago

For now this is specifically for YT comments, but also for general independance in terms of what data sources the overlay can work with, so if a user has a different websocket data source that emits chat messages, it should be as easy as possible to extend the overlay to accept these.

Once this is done, the SB YouTube chat should be integrated as a test.

izzy commented 2 years ago

@andi242 you sorta worked on this already, right? Since I don't really work with YT streaming, could you provide me with some messages(preferably as JSON) that the SB websocket emits here?

andi242 commented 2 years ago

Sorry for the late reply!

I have some example json that should do :)

[
    "Event",
    {
        "timeStamp": "2022-06-02T19:01:39.2554885+02:00",
        "event": {
            "source": "YouTube",
            "type": "Message"
        },
        "data": {
            "message": "mit emote 😀",
            "eventId": "LCC.CikqJwoYVUNMdk1VYmhsb0hvX0k0b3RjZVN0U29nEgtDa1Z0anozcF9yNBI6ChpDUENodkt1ZmpfZ0NGVXZ3d1FvZEQySU1RQRIcQ1BqUjNMdVVqX2dDRlFuZVZRb2Q3RmtPMEEyNA",
            "user": {
                "id": "UCLvMUbhloHo_I4otceStSog",
                "url": "http://www.youtube.com/channel/UCLvMUbhloHo_I4otceStSog",
                "name": "andi242",
                "profileImageUrl": "https://yt3.ggpht.com/U75sKXEC9YdTLqwC2qbzI80QoO4oarJCw9xg66uILq5ndEvRXkOeaLJ03nwGrP1YamLVzQb4Rw=s88-c-k-c0x00ffffff-no-rj",
                "isOwner": true,
                "isModerator": false,
                "isSponsor": false,
                "isVerified": false
            },
            "publishedAt": "2022-06-02T19:01:36.914732+02:00"
        }
    }
]
[
    "Event",
    {
        "timeStamp": "2022-06-02T19:03:30.0217939+02:00",
        "event": {
            "source": "YouTube",
            "type": "Message"
        },
        "data": {
            "message": "messaddd :hydrate::hydrate::hydrate:",
            "eventId": "LCC.CikqJwoYVUNMdk1VYmhsb0hvX0k0b3RjZVN0U29nEgtDa1Z0anozcF9yNBI6ChpDTm1uemVDZmpfZ0NGVFVHMWdBZGVic0paURIcQ1BqUjNMdVVqX2dDRlFuZVZRb2Q3RmtPMEEyNg",
            "user": {
                "id": "UCLvMUbhloHo_I4otceStSog",
                "url": "http://www.youtube.com/channel/UCLvMUbhloHo_I4otceStSog",
                "name": "andi242",
                "profileImageUrl": "https://yt3.ggpht.com/U75sKXEC9YdTLqwC2qbzI80QoO4oarJCw9xg66uILq5ndEvRXkOeaLJ03nwGrP1YamLVzQb4Rw=s88-c-k-c0x00ffffff-no-rj",
                "isOwner": true,
                "isModerator": false,
                "isSponsor": false,
                "isVerified": false
            },
            "publishedAt": "2022-06-02T19:03:28.343049+02:00"
        }
    }
]
andi242 commented 2 years ago

in addition, I got all the events that can be subscribed to as json the tricky thing was to find out what events to subscribe to, when using YT. the event is youTube which might be a typo on SB side. YouTube did not work... not sure if they fixed this in the meantime.

{
    "id": "obs-chat",
    "events": {
        "general": [
            "Custom"
        ],
        "twitch": [
            "Follow",
            "Cheer",
            "Sub",
            "ReSub",
            "GiftSub",
            "GiftBomb",
            "Raid",
            "HypeTrainStart",
            "HypeTrainUpdate",
            "HypeTrainLevelUp",
            "HypeTrainEnd",
            "RewardRedemption",
            "RewardCreated",
            "RewardUpdated",
            "RewardDeleted",
            "CommunityGoalContribution",
            "CommunityGoalEnded",
            "StreamUpdate",
            "Whisper",
            "FirstWord",
            "SubCounterRollover",
            "BroadcastUpdate",
            "StreamUpdateGameOnConnect",
            "PresentViewers",
            "PollCreated",
            "PollUpdated",
            "PollCompleted",
            "PredictionCreated",
            "PredictionUpdated",
            "PredictionCompleted",
            "PredictionCanceled",
            "PredictionLocked",
            "ChatMessage",
            "Host",
            "ChatMessageDeleted",
            "UserTimedOut",
            "UserBanned"
        ],
        "streamlabs": [
            "Donation",
            "Merchandise"
        ],
        "speechToText": [
            "Dictation",
            "Command"
        ],
        "command": [
            "Message",
            "Whisper",
            "MessageCooldown"
        ],
        "fileWatcher": [
            "Changed",
            "Created",
            "Deleted",
            "Renamed"
        ],
        "quote": [
            "Added",
            "Show"
        ],
        "misc": [
            "TimedAction",
            "PyramidSuccess",
            "PyramidBroken"
        ],
        "raw": [
            "Action",
            "SubAction"
        ],
        "websocketClient": [
            "Open",
            "Close",
            "Message"
        ],
        "streamElements": [
            "Tip",
            "Merch"
        ],
        "websocketCustomServer": [
            "Open",
            "Close",
            "Message"
        ],
        "donorDrive": [
            "Donation",
            "ProfileUpdated"
        ],
        "youTube": [
            "BroadcastStarted",
            "BroadcastEnded",
            "Message",
            "MessageDeleted",
            "UserBanned",
            "SuperChat",
            "SuperSticker",
            "NewSponsor",
            "MemberMileStone",
            "NewSponsorOnlyStarted",
            "NewSponsorOnlyEnded",
            "StatisticsUpdated",
            "BroadcastUpdated"
        ],
        "pulsoid": [
            "HeartRatePulse"
        ],
        "hypeRate": [
            "HeartRatePulse"
        ],
        "kofi": [
            "Donation",
            "Subscription",
            "Resubscription",
            "ShopOrder",
            "Commission"
        ],
        "patreon": [
            "FollowCreated",
            "FollowDeleted",
            "PledgeCreated",
            "PledgeUpdated",
            "PledgeDeleted"
        ],
        "application": [
            "ActionAdded",
            "ActionUpdated",
            "ActionDeleted"
        ],
        "tipeeeStream": [
            "Donation"
        ],
        "treatStream": [
            "Treat"
        ]
    },
    "status": "ok"
}

I had a hard time finding this out, since I had no idea how to get to this :D