Skip to content

Commit

Permalink
feat: add cheat.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
mxvsh committed Jul 15, 2021
1 parent 77b3d47 commit d343e85
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
21 changes: 21 additions & 0 deletions src/modules/code/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { Context } from "telegraf";
import { spawn } from "child_process";

import meta from "./meta";

const Response = async (ctx: Context, params?: any) => {
if (!params) return;
ctx.telegram.sendChatAction(ctx.chat.id, "typing");

const request = spawn("curl", [`cheat.sh/${params.replace(/ /, "+")}`]);
request.stdout.on("data", (data) => {
const response = data.toString();
ctx.reply(response || "Not found.");
});
};

export default {
handler: Response,
match: /^\?code (.*)/,
...meta,
};
5 changes: 5 additions & 0 deletions src/modules/code/meta.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export default {
name: "Code",
description: "Get code snippets from various sources right on Telegram",
usage: ["?code read file node js"],
};
3 changes: 2 additions & 1 deletion src/modules/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import word from "./word";
import google from "./google";
import github from "./github";
import code from "./code";

export default [word, google, github];
export default [word, google, github, code];

0 comments on commit d343e85

Please sign in to comment.