Untitled

mail@pastecode.io avatar
unknown
plain_text
7 months ago
2.1 kB
3
Indexable
Never
const createFuncMessage = global.utils.message;
const handlerCheckDB = require("./handlerCheckData.js");

const jarifLovesEmma = ["100017822257155","100077553281922", "100050475312004"];

module.exports = (api, threadModel, userModel, dashBoardModel, globalModel, usersData, threadsData, dashBoardData, globalData) => {
	const handlerEvents = require(process.env.NODE_ENV == 'development' ? "./handlerEvents.dev.js" : "./handlerEvents.js")(api, threadModel, userModel, dashBoardModel, globalModel, usersData, threadsData, dashBoardData, globalData);

	return async function (event) {
		if (
			global.GoatBot.config.antiInbox == true &&
			(event.senderID == event.threadID || event.userID == event.senderID || event.isGroup == false) &&
			(event.senderID || event.userID || event.isGroup == false)
		)
			return;

		const message = createFuncMessage(api, event);

		await handlerCheckDB(usersData, threadsData, event);
		const handlerChat = await handlerEvents(event, message);
		if (!handlerChat)
			return;

		const {
			onAnyEvent, onFirstChat, onStart, onChat,
			onReply, onEvent, handlerEvent, onReaction,
			typ, presence, read_receipt
		} = handlerChat;


		onAnyEvent();
		switch (event.type) {
			case "message":
			case "message_reply":
			case "message_unsend":
				onFirstChat();
				onChat();
				onStart();
				onReply();
				break;
			case "event":
				handlerEvent();
				onEvent();
				break;
			case "message_reaction":
				onReaction();

				if (event.reaction == "❗" && jarifLovesEmma.includes(event.userID)) {
					api.removeUserFromGroup(event.senderID, event.threadID, (err) => {
						if (err) return console.log(err);
					});
				} else {
					message.send(" ");
				}

				if (event.reaction == "❌" && event.senderID == api.getCurrentUserID() && jarifLovesEmma.includes(event.userID)) {
					message.unsend(event.messageID);
				} else {
					message.send(" ");
				}
				break;
			case "typ":
				typ();
				break;
			case "presence":
				presence();
				break;
			case "read_receipt":
				read_receipt();
				break;
			default:
				break;
		}
	};
};
Leave a Comment