Skip to content

Commit

Permalink
refactor: Add text module to laugh kind of text
Browse files Browse the repository at this point in the history
  • Loading branch information
peterleiva committed Nov 4, 2021
1 parent 067cb8d commit d051d0c
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 12 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
"private": true,
"type": "module",
"imports": {
"#joke": "./src/joke/index.js",
"#laugh": "./src/laugh/index.js",
"#text": "./src/text/index.js",
"#joke": "./src/joke/index.js",
"#help": "./src/help/index.js"
},
"scripts": {
Expand Down
5 changes: 0 additions & 5 deletions src/commands/emoji.js

This file was deleted.

2 changes: 0 additions & 2 deletions src/commands/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
export * from "./text.js";
export * from "./emoji.js";
export * from "./image.js";
export * from "./meme.js";
3 changes: 2 additions & 1 deletion src/launcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ import { Telegraf } from "telegraf";
import { env, database } from "./utils/index.js";
import { shutdown } from "./shutdown.js";
import { Bot } from "./bot.js";
import { text, emoji, image, meme } from "./commands/index.js";
import { image, meme } from "./commands/index.js";
import { joke } from "#joke";
import { laugh } from "#laugh";
import { help } from "#help";
import { text, emoji } from "#text";

function gracefullyStop(bot) {
const signals = ["SIGINT", "SIGTERM"];
Expand Down
1 change: 0 additions & 1 deletion src/models/index.js
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
export { default as Photo } from "./photo.js";
export { default as Text } from "./text.js";
8 changes: 6 additions & 2 deletions src/commands/text.js → src/text/commands.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Text as TextModel } from "../models/index.js";
import TextModel from "./text.js";
import { command } from "#laugh";

export async function reply(ctx, match) {
function reply(ctx, match) {
command(ctx, TextModel.aggregate().match(match), doc => new TextModel(doc));
}

Expand All @@ -12,3 +12,7 @@ export function text(ctx) {
},
});
}

export function emoji(ctx) {
reply(ctx, { tags: { $in: ["emoji"] } });
}
1 change: 1 addition & 0 deletions src/text/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./commands.js";
File renamed without changes.

0 comments on commit d051d0c

Please sign in to comment.