Better structure
This commit is contained in:
parent
aa6f2d5ca7
commit
78dd58f109
3 changed files with 7 additions and 5 deletions
|
@ -1,8 +1,7 @@
|
|||
import { Composer } from "grammy";
|
||||
|
||||
import Archive from "models/archive";
|
||||
|
||||
const commands = new Composer();
|
||||
const env = process.env;
|
||||
|
||||
commands.command("start", (ctx) => {
|
||||
ctx.reply("Welcome to my magical mailbox 🪄");
|
||||
|
|
|
@ -5,6 +5,7 @@ import Archive from "models/archive";
|
|||
const messages = new Composer();
|
||||
const env = process.env;
|
||||
|
||||
// Handle reply messages
|
||||
messages.on("message", async (ctx, next) => {
|
||||
if (!ctx.msg.reply_to_message) {
|
||||
return next();
|
||||
|
@ -31,6 +32,7 @@ messages.on("message", async (ctx, next) => {
|
|||
}
|
||||
});
|
||||
|
||||
// Handle messaging
|
||||
messages.on("message", async (ctx) => {
|
||||
try {
|
||||
const msg = await ctx.api.copyMessage(env.admin!, ctx.from.id, ctx.msgId);
|
||||
|
@ -44,6 +46,7 @@ messages.on("message", async (ctx) => {
|
|||
}
|
||||
});
|
||||
|
||||
// Handle reaction on messages
|
||||
messages.on("message_reaction", async (ctx) => {
|
||||
try {
|
||||
const record: any = await Archive.findOne({
|
||||
|
|
|
@ -4,16 +4,16 @@ import database from "database";
|
|||
|
||||
const Archive = database.define("Archive", {
|
||||
msgId: {
|
||||
type: DataTypes.STRING,
|
||||
type: DataTypes.INTEGER,
|
||||
primaryKey: true,
|
||||
allowNull: false,
|
||||
},
|
||||
senderId: {
|
||||
type: DataTypes.STRING,
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
},
|
||||
senderMsgId: {
|
||||
type: DataTypes.STRING,
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
},
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue