This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import MemoryBlock from "./memory-block"; | |
import BitmapMemory from "./bitmap-memory"; | |
import LinkedList from "./linked-list"; | |
const PATH_VOLATILE = '.volatile' | |
// The FILE SYSTEM is an extension of a memory architecture which allows data | |
// to be stored in a globally accessible* tree of files and directories. | |
// | |
// * Restrictions on files may be present to prevent malicious access |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const setSessionEntities = (conv: Conv) => { | |
// Create sets for each type of entity type | |
const trackTitles = new Set<string>() | |
const trackGenres = new Set<string>() | |
const trackTags = new Set<string>() | |
conv.data.json.tracks.forEach(track => { | |
trackTitles.add(track.track_title) | |
track.track_genre.forEach(genre => { | |
trackGenres.add(genre) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.intent('Default Welcome Intent', async (conv) => { | |
// … Welcome logic | |
conv.sessionEntities.send() | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const setSessionEntities = (conv: Conv) => { | |
// Create sets for each type of entity type | |
const trackTitles = new Set<string>() | |
const trackGenres = new Set<string>() | |
const trackTags = new Set<string>() | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Conv = DialogflowConversation<TabletopAudioSession> | |
app.middleware(async (conv: Conv) => { | |
await cacheResults(conv) | |
}) | |
async function cacheResults(conv: Conv) { | |
if (!conv.data.json) { | |
const response = await fetch(tabletopAudioUrl) | |
const json: TabletopAudioResponse = await response.json() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { sessionEntitiesHelper } = require('actions-on-google-dialogflow-session-entities-plugin') | |
const app = dialogflow() | |
.use(sessionEntitiesHelper()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.intent('Default Welcome Intent', async (conv: Conv) => { | |
conv.ask(new SimpleResponse({ | |
text: 'Welcome to Tabletop Audio! I can play a specific track, ' + | |
'or start playing based on a genre. What do you want to listen to?', | |
speech: `Welcome to Tabletop Audio! I can play a specific track ` + | |
`like ${conv.data.json.tracks[0].track_title}, or start playing based on a genre like ` + | |
`${conv.data.json.tracks[0].track_genre}. What do you want to listen to?` | |
})) | |
conv.ask(getSuggestions(conv.data.json.tracks)) | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.intent('New', (conv: Conv) => { | |
const newestTracks = conv.data.json.tracks.slice(0, 3) | |
conv.ask('The last three tracks added to Tabletop Audio are: ' + | |
newestTracks.map(track => track.track_title) + | |
'. What do you want to listen to?') | |
conv.ask(new Suggestions(...newestTracks.map(track => track.track_title))) | |
}) | |
app.intent('Help', (conv: Conv) => { | |
conv.ask('Tabletop Audio is the premier advertising-free, free-to-use, and user-supported ' + |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.intent('actions.intent.MEDIA_STATUS', (conv: Conv) => { | |
const mediaStatus = conv.arguments.get('MEDIA_STATUS') | |
let response = 'Unknown media status received.' | |
if (mediaStatus && mediaStatus.status === 'FINISHED') { | |
response = 'Hope you enjoyed that song. What else do you want to listen to?'; | |
} | |
conv.ask(response) | |
conv.ask(new Suggestions('Repeat')) | |
conv.ask(getSuggestions(conv.data.json.tracks)) | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.intent('Current', (conv: Conv) => { | |
const track = conv.data.currentTrack | |
if (!track) { | |
conv.ask('Sorry, I don\'t think anything is playing. What do you want to listen to?') | |
conv.ask(getSuggestions(conv.data.json.tracks)) | |
return | |
} | |
conv.ask(`This is ${track.track_title} from Tabletop Audio. ${track.flavor_text}`) | |
conv.ask(getSuggestions(conv.data.json.tracks)) | |
}) |
NewerOlder