diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000..b25c15b81f --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*~ diff --git a/README.md b/README.md new file mode 100644 index 0000000000..dbee9aedbd --- /dev/null +++ b/README.md @@ -0,0 +1,4 @@ +storyteller-protos +================== +Our shared protos for all of our services and applications. + diff --git a/protos/pubsub-events/pubsub-events.proto b/protos/pubsub-events/pubsub-events.proto new file mode 100644 index 0000000000..d1af518f18 --- /dev/null +++ b/protos/pubsub-events/pubsub-events.proto @@ -0,0 +1,191 @@ +syntax = 'proto2'; + +package storyteller.pubsub; + +// Ingestion platforms are "dumb" and shouldn't have much logic in them. +// (Granted, we might eventually grow to send them back messages.) +// +// The "enricher" is the smarts. It does denylisting, rate limiting, +// service calls, transforms, etc. +// +// What if we need to scale? Several ideas: Sharding (redis db indices), +// brokers with read-once semantics (our own intelligence - UUIDs with +// transactional semantics in MySQL). +// +// Events coming from multiple sources +message PubsubEventPayloadV1 { + + // TODO: This should all be merged in the future, but I need to settle on proto2 vs proto3 + // And I also need to figure out package names, etc. + enum IngestionSourceType { + IST_DO_NOT_USE = 0; + IST_ADMIN_PANEL = 1; + IST_VOCODES_WEBSITE = 2; + IST_TWITCH = 3; + IST_TWITTER = 4; + IST_DISCORD = 5; + IST_YOUTUBE = 6; + IST_REDDIT = 7; + IST_TIKTOK = 8; + } + + // These will differ from the "enriched" types. + enum IngestionPayloadType { + IPT_DO_NOT_USE = 0; + + // Twitch-specific events. + TWITCH_MESSAGE = 100; // This can encode lots of things. + TWITCH_SUBSCRIBED = 101; + + // Twitter-specific events. + TWITTER_FOLLOW = 200; + TWITTER_RETWEET = 201; + TWITTER_MENTION = 202; + + // Discord-specific events. + DISCORD_MESSAGE = 300; + DISCORD_JOINED = 301; + + // YouTube-specific events. + YOUTUBE_SUBSCRIBED = 400; + + // Reddit-specific events. + REDDIT_MESSAGE = 500; + } + + // Source of the event. + optional IngestionSourceType ingestion_source_type = 1; + optional IngestionPayloadType ingestion_payload_type = 2; + + // A binary-encoded proto whose type is based on IngestionSourceType + optional bytes ingestion_source_data = 3; + + // A binary-encoded proto whose type is based on IngestionPayloadType + optional bytes ingestion_payload_data = 4; + + // An optional debug message. + optional string debug_message = 5; +} + +// ============================== SOURCE PROTOS ============================== // + + +message IngestionTwitchMetadata { + // Optional. Fields describing the user that sent the message. + optional int64 user_id = 1; + optional string username = 2; + optional bool user_is_mod = 3; + optional bool user_is_subscribed = 4; + + // Optional. Name of the channel, prefixed with hash. eg. `#vocodes`. + optional string channel = 5; +} + + +message IngestionTwitterMetadata { + // Optional. Fields describing the user that sent the message. + + // TODO: This is a u64. We need to be careful with math to assure non-overflow. + //optional int64 user_id = 1; + + optional string username = 2; + optional string display_name = 3; + optional string avatar_url = 4; +} + + +message IngestionDiscordMetadata { + // Optional. Fields describing the user that sent the message. + optional string username = 1; +} + + +message IngestionYoutubeMetadata { + // Optional. Fields describing the user that sent the message. + optional string username = 1; +} + + +message IngestionRedditMetadata { + // Optional. Fields describing the user that sent the message. + optional string username = 1; +} + + +message IngestionTikTokMetadata { + // Optional. Fields describing the user that sent the message. + optional string username = 1; +} + + +// ============================== TWITCH PAYLOAD PROTOS ============================== // + + +// These are raw messages from Twitch that we send to the PubSub enricher. +message IngestionTwitchMessage { + // TODO: DEPRECATE THESE + optional int64 user_id = 1; + optional string username = 2; + optional bool is_mod = 3; + optional bool is_subscribed = 4; + + // TODO: DEPRECATE THESE + // Name of the channel, prefixed with hash. eg. `#vocodes`. + optional string channel = 5; + + // Actual message. Doesn't need to be trimmed. + optional string message_contents = 6; +} + + +message IngestionTwitchSubscribed { + // Intentionally blank for now +} + + +// ============================== TWITTER PAYLOAD PROTOS ============================== // + + +message IngestionTwitterFollow { + // Intentionally blank for now +} +message IngestionTwitterRetweet { + // Intentionally blank for now + optional string original_text = 1; +} +message IngestionTwitterMention { + // Intentionally blank for now + optional string text = 1; +} + + +// ============================== DISCORD PAYLOAD PROTOS ============================== // + + +message IngestionDiscordMessage { + // Raw message. Needs to be trimmed + optional string message_contents = 6; +} + +message IngestionDiscordJoined { + // Intentionally blank for now +} + + +// ============================== YOUTUBE PAYLOAD PROTOS ============================== // + + +message IngestionYoutubeSubscribed { + // Intentionally blank for now +} + + + +// ============================== REDDIT PAYLOAD PROTOS ============================== // + + +message IngestionRedditMessage { + // Raw message. Needs to be trimmed + optional string message_contents = 6; +} + diff --git a/protos/unreal/unreal.proto b/protos/unreal/unreal.proto new file mode 100644 index 0000000000..1564f412c9 --- /dev/null +++ b/protos/unreal/unreal.proto @@ -0,0 +1,196 @@ +syntax = 'proto3'; + +package storyteller.unreal; + +// The payloads delivered to unreal engine over the pubsub bus. +// These are the "enriched" events. +message UnrealEventPayloadV1 { + + // If people Retweet us or mention us, we should show that in the engine! + enum SourceType { + ST_DO_NOT_USE = 0; + ST_ADMIN_PANEL = 1; + ST_VOCODES_WEBSITE = 2; + ST_TWITCH = 3; + ST_TWITTER = 4; + ST_DISCORD = 5; + ST_YOUTUBE = 6; + ST_REDDIT = 7; + ST_TIKTOK = 8; + } + + enum PayloadType { + PT_DO_NOT_USE = 0; + + // Game events. These can come from many sources (control panel, Twitch, Discord) + VOCODES_TTS = 1; + LEVEL_WARP = 2; + CESIUM_WARP = 3; + CESIUM_TIME_CHANGE = 4; + SPAWN_CREATURE = 5; + //CHANGE_MUSIC = 6; + + // Twitter-specific events. + TWITTER_FOLLOW = 200; + TWITTER_RETWEET = 201; + TWITTER_MENTION = 202; + + // Discord-specific events. + DISCORD_JOINED = 300; + + // YouTube-specific events. + YOUTUBE_SUBSCRIBED = 400; + + // Are there non-chat Reddit events? + } + + // Source of the event. + SourceType source_type = 1; + + // Type of the payload. + PayloadType payload_type = 2; + + // A binary-encoded proto whose type is based on SourceType + bytes source_data = 3; + + // A binary-encoded proto whose type is based on PayloadType + bytes payload_data = 4; + + // An optional debug message. + string debug_message = 5; +} + + +// ============================== SOURCE PROTOS ============================== // + + +message TwitchMetadata { + // Optional. Fields describing the user that sent the message. + int64 user_id = 1; + string username = 2; + bool user_is_mod = 3; + bool user_is_subscribed = 4; + + // Optional. Name of the channel, prefixed with hash. eg. `#vocodes`. + string channel = 5; +} + + +message TwitterMetadata { + // Optional. Fields describing the user that sent the message. + + // TODO: This is a u64. We need to be careful with math to assure non-overflow. + //int64 user_id = 1; + + string username = 2; + string display_name = 3; + string avatar_url = 4; +} + + +message DiscordMetadata { + // Optional. Fields describing the user that sent the message. + string username = 1; +} + + +message YoutubeMetadata { + // Optional. Fields describing the user that sent the message. + string username = 1; +} + + +message RedditMetadata { + // Optional. Fields describing the user that sent the message. + string username = 1; +} + + +message TikTokMetadata { + // Optional. Fields describing the user that sent the message. + string username = 1; +} + + +// ============================== GAME EVENT PROTOS ============================== // + + +// Change time in Cesium. +message CesiumTimeChangeRequest { + // Required + int64 hour = 1; +} + + +// Warp within a Cesium geospatial world. +message CesiumWarpRequest { + // Required + double latitude = 1; + + // Required + double longitude = 2; + + // TODO: Remove these. + // Optional. Fields describing the user that sent the message. + int64 twitch_user_id = 3; + string twitch_username = 4; + bool twitch_user_is_mod = 5; + bool twitch_user_is_subscribed = 6; + + // TODO: Remove these. + // Optional. Name of the channel, prefixed with hash. eg. `#vocodes`. + string twitch_channel = 7; +} + + +// Change the level +message LevelWarpRequest { + // Required. Level to warp to. + string level_slug = 1; +} + + +// Spawn a creature +message SpawnCreatureRequest { + // Required. Name of the creature. + string name_slug = 1; +} + + +// Do text to speech +message VocodesTtsRequest { + // Required. Speaker to use. + string voice_slug = 1; + // Required. Text to speak. + string text = 2; +} + + +// ============================== TWITTER EVENT PROTOS ============================== // + + +message TwitterFollow { + // Intentionally blank +} + +message TwitterRetweet { + string original_text = 1; +} + +message TwitterMention { + string text = 1; +} + + +// ============================== DISCORD EVENT PROTOS ============================== // + +message DiscordJoined { + // Intentionally blank +} + +// ============================== YOUTUBE EVENT PROTOS ============================== // + +message YoutubeSubscribed { + // Intentionally blank +} +