-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Chris Larkin
committed
Jul 17, 2023
1 parent
62ed85f
commit 81cbad4
Showing
6 changed files
with
113 additions
and
2 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,9 @@ | ||
# comedian | ||
The tutorial module for Moemate https://www.moemate.io | ||
<p style="text-align: center;"><h1>Moemate Comedian Module</h1></p> | ||
|
||
<p align="center"> | ||
<img src="https://static.wixstatic.com/media/23bb89_f9bd2f871f5c4bafb4a5f377a7f57d11~mv2.png/v1/fit/w_2500,h_1330,al_c/23bb89_f9bd2f871f5c4bafb4a5f377a7f57d11~mv2.png" alt="Moemate"/> | ||
</p> | ||
|
||
This is the full source code for the tutorial module in the [Moemate Companion Documentation](https://docs.moemate.io) | ||
|
||
To use the Moemate companion yourself, head to the [Moemate Website](https://www.moemate.io) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
{ | ||
"name": "comedian", | ||
"title": "Comedian", | ||
"description": "Gives the companion the ability make jokes, memes, silly words, or animated gifs", | ||
"authors": [ | ||
{ | ||
"name": "Webaverse", | ||
"email": "support@webaverse.com", | ||
"url": "https://www.moemate.io" | ||
}, | ||
{ | ||
"name": "{YOUR NAME HERE!}" | ||
} | ||
], | ||
"version": "1.0", | ||
"compatibility": { | ||
"minimum": "0.9.1", | ||
"verified": "0.9.1" | ||
}, | ||
"download": "https://github.com/webaverse-studios/comedian/archive/refs/tags/v1.0.zip", | ||
"models": [ | ||
"models/humor_api.json.hbs" | ||
], | ||
"skills": [ | ||
"skills/joke.json.hbs", | ||
"skills/meme.json.hbs" | ||
], | ||
"scripts": [ | ||
"scripts/comedian.js" | ||
] | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"name": "comedian:humorapi", | ||
"type": "generic", | ||
"url": "https://api.humorapi.com/{{humorApiFunction}}?{{{humorApiQueryString}}}", | ||
"method": "GET", | ||
"headers": { | ||
"Content-Type": "application/json", | ||
"x-api-key": "2f44fac197c44a9da3379e1b40bd46fe" | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/** | ||
* The Comedian Module | ||
* Gives the companion the ability make jokes, memes, silly words, or animated gifs | ||
*/ | ||
|
||
function _handleJokeSkill(keywords) { | ||
const context = { | ||
humorApiFunction:'jokes/random', | ||
humorApiQueryString: `exclude-tags=nsfw,dark,racist,jewish,sexual&include-tags=${keywords.value}` | ||
} | ||
window.models_generic.SetCurrentModel('comedian:humorapi') | ||
window.models_generic.ApplyContextObject(context); | ||
window.models_generic.CallCurrentModel(); | ||
} | ||
|
||
function _handleMemeSkill(keywords) { | ||
const context = { | ||
humorApiFunction:'memes/random', | ||
humorApiQueryString: `media-type=image&keywords=${keywords.value}` | ||
} | ||
window.models_generic.SetCurrentModel('comedian:humorapi') | ||
window.models_generic.ApplyContextObject(context); | ||
window.models_generic.CallCurrentModel(); | ||
} | ||
|
||
function _handleApiResponse(response) { | ||
const responseObj = JSON.parse(response); | ||
const name = window.companion.GetCharacterAttribute('name'); | ||
if (responseObj.url) { | ||
//Is a meme | ||
window.companion.SendMessage({ type: "WEB_IMAGE", user: name, value: responseObj.url, timestamp: Date.now(), alt: responseObj.description}); | ||
} else { | ||
//Is a joke | ||
const joke = JSON.parse(response).joke.replace(/\\/g, ''); | ||
window.hooks.emit('moemate_core:handle_skill_text', {name: name, value: joke}); | ||
} | ||
} | ||
|
||
export function init() { | ||
window.hooks.on('comedian:handle_joke_skill', _handleJokeSkill) | ||
window.hooks.on('comedian:handle_meme_skill', _handleMemeSkill) | ||
window.hooks.on('models:response:comedian:humorapi', _handleApiResponse) | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"name": "TELL_JOKE", | ||
"displayName": "Tell Jokes", | ||
"description": "The companion will occasionally tell a joke.", | ||
"skill": "TELL_JOKE", | ||
"prompt": "You have access to a database of jokes. If you want to tell a joke, create a comma-separated list of tags that the joke should contain. Here is the list of available tags: Clean, Relationship, School, Animal, Deep Thoughts, Food, One Liner, Knock Knock, Political, Sexist, Sport, Chuck Norris, Holiday, Blondes, Yo Momma, Analogy, Law, Christmas, Nerdy, Religious, Kids", | ||
"value": "Clean,Kids", | ||
"format": "{{user}} is telling a joke", | ||
"handlerHook": "comedian:handle_joke_skill" | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"name": "TELL_MEME", | ||
"displayName": "Send Memes", | ||
"description": "The companion will occasionally send you a funny meme", | ||
"skill": "TELL_MEME", | ||
"prompt": "You have access to a database of memes. If you want to send one to the user, create a comma-separated list of keywords that the joke should contain. Make sure to ONLY use the list of keywords and nothing else.", | ||
"value": "Pepe,Smoking", | ||
"format": "{{user}} is sending a meme", | ||
"handlerHook": "comedian:handle_meme_skill" | ||
} |