Created
May 21, 2021 17:12
-
-
Save LukasForst/355d72e0195d888b1d63b22ebb76a756 to your computer and use it in GitHub Desktop.
Super simple typescript bot for Wire
This file contains hidden or 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
// noinspection DuplicatedCode | |
import { Application, Router, RouterContext } from 'https://deno.land/x/[email protected]/mod.ts'; | |
const app = new Application(); | |
const router = new Router(); | |
router.post('/roman', async (ctx: RouterContext) => { | |
const body = await ctx.request.body({ type: 'json' }).value; | |
console.log(body); | |
const { type } = body; | |
switch (type) { | |
case 'conversation.new_text': | |
ctx.response.body = { type: 'text', text: { data: `You said: ${body.text.data}` } }; | |
break; | |
} | |
ctx.response.status = 200; | |
}); | |
app.use(router.routes()); | |
app.use(router.allowedMethods()); | |
app.addEventListener('listen', () => console.log('Server up and running on localhost:8080')); | |
await app.listen({ port: 8080 }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment