<commit_before>'use strict';

// Utils
const { link, scheduleDeletion } = require('../../utils/tg');

// Bot
const { replyOptions } = require('../../bot/options');

// DB
const { getUser, getWarns } = require('../../stores/user');

const getWarnsHandler = async ({ message, reply, state }) => {
	const { isAdmin } = state;
	if (!isAdmin) return null;

	const mentionedUser = message.reply_to_message
		? message.reply_to_message.from
		: message.commandMention
			? message.commandMention
			: null;
	if (!mentionedUser) {
		return reply(
			'ℹ️ <b>Reply to a message or mention a user.</b>',
			replyOptions
		).then(scheduleDeletion);
	}

	const theUser = await getUser({ id: mentionedUser.id });

	if (theUser.status === 'admin') {
		return reply(
			`⭐️ ${link(theUser)} <b>is admin.</b>`,
			replyOptions
		).then(scheduleDeletion);
	}

	let i = 0;
	const warns = await getWarns(theUser);
	const warnsMessage = warns
		? '⚠️ <b>Warns:</b>\n' +
		warns
			.map(warn => ++i + '. ' + warn)
			.join('\n')
		: '✅ <b>no warns</b>';

	if (theUser.status === 'banned') {
		return reply(
			`🚫 ${link(theUser)} <b>is banned for:</b>\n` +
			`${theUser.banReason}\n\n` +
			warnsMessage,
			replyOptions
		);
	}

	return reply(
		`ℹ️ ${link(theUser)} <b>is a member of network.</b>\n\n` +
		warnsMessage,
		replyOptions
	);
};

module.exports = getWarnsHandler;<commit_msg>members can use /user to get their status<commit_after>'use strict';

// Utils
const { link, scheduleDeletion } = require('../../utils/tg');

// Bot
const { replyOptions } = require('../../bot/options');

// DB
const { getUser, getWarns } = require('../../stores/user');

const getWarnsHandler = async ({ message, reply, state }) => {
	const { isAdmin } = state;

	const mentionedUser = message.reply_to_message
		? message.reply_to_message.from
		: message.commandMention
			? message.commandMention
			: state.user;

	if (!isAdmin && mentionedUser.id !== state.user.id) return null;

	const theUser = await getUser({ id: mentionedUser.id });

	if (theUser.status === 'admin') {
		return reply(
			`⭐️ ${link(theUser)} <b>is admin.</b>`,
			replyOptions
		).then(scheduleDeletion);
	}

	let i = 0;
	const warns = await getWarns(theUser);
	const warnsMessage = warns
		? '⚠️ <b>Warns:</b>\n' +
		warns
			.map(warn => ++i + '. ' + warn)
			.join('\n')
		: '✅ <b>no warns</b>';

	if (theUser.status === 'banned') {
		return reply(
			`🚫 ${link(theUser)} <b>is banned for:</b>\n` +
			`${theUser.banReason}\n\n` +
			warnsMessage,
			replyOptions
		).then(scheduleDeletion);
	}

	return reply(
		`ℹ️ ${link(theUser)} <b>is a member of network.</b>\n\n` +
		warnsMessage,
		replyOptions
	).then(scheduleDeletion);
};

module.exports = getWarnsHandler;
{'fraction_non_alphanumeric': 0.1910195068089805, 'fraction_numerical': 0.000736105999263894, 'mean_word_length': 3.4123376623376624, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4118622', 'n_tokens_mistral': 1079, 'n_tokens_neox': 1010, 'n_words': 223}