Skip to content

Instantly share code, notes, and snippets.

@LukasForst
Created May 21, 2021 17:12
Show Gist options
  • Save LukasForst/355d72e0195d888b1d63b22ebb76a756 to your computer and use it in GitHub Desktop.
Save LukasForst/355d72e0195d888b1d63b22ebb76a756 to your computer and use it in GitHub Desktop.
Super simple typescript bot for Wire
// noinspection DuplicatedCode
import { Application, Router, RouterContext } from 'https://deno.land/x/oak@v6.5.0/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