<commit_before>#include <ctime>
#include <iomanip>
#include <utils.h>
#include "command.h"
#include "../CommandHandler.h"
#include "../OptionParser.h"

/* full name of the command */
CMDNAME("submit");
/* description of the command */
CMDDESCR("submit a message to the streamer");
/* command usage synopsis */
CMDUSAGE("$submit MSG");

/* submit: submit a message to the streamer */
std::string CommandHandler::submit(char *out, struct command *c)
{
	std::string output = "@" + std::string(c->nick) + ", ";
	const std::string path = utils::configdir() + utils::config("submit");
	std::ofstream writer(path, std::ios::app);
	time_t t;
	std::tm tm;

	int opt;
	OptionParser op(c->fullCmd, "");
	static struct OptionParser::option long_opts[] = {
		{ "help", NO_ARG, 'h' },
		{ 0, 0, 0 }
	};

	while ((opt = op.getopt_long(long_opts)) != EOF) {
		switch (opt) {
		case 'h':
			return HELPMSG(CMDNAME, CMDUSAGE, CMDDESCR);
		case '?':
			return std::string(op.opterr());
		default:
			return "";
		}
	}

	if (op.optind() == c->fullCmd.length())
		return USAGEMSG(CMDNAME, CMDUSAGE);

	t = time(nullptr);
#ifdef __linux__
	tm = *localtime(&t);
#endif
#ifdef _WIN32
	localtime_s(&tm, &t);
#endif
	writer << "[" << std::put_time(&tm, "%Y-%m-%d %R") << "] ";
	writer << c->nick << ": " << c->fullCmd.substr(op.optind()) << std::endl;

	return output + "your topic has been submitted. Thank you.";
}
<commit_msg>submit: update command format<commit_after>#include <time.h>
#include <utils.h>
#include "command.h"
#include "../CommandHandler.h"
#include "../option.h"

#define MAX_PATH 512

/* full name of the command */
_CMDNAME("submit");
/* description of the command */
_CMDDESCR("submit a message to the streamer");
/* command usage synopsis */
_CMDUSAGE("$submit MSG");

/* submit: submit a message to the streamer */
std::string CommandHandler::submit(char *out, struct command *c)
{
	char path[MAX_PATH];
	char buf[MAX_MSG];
	time_t t;
	struct tm msgtm;
	FILE *f;

	int opt;
	static struct option long_opts[] = {
		{ "help", NO_ARG, 'h' },
		{ 0, 0, 0 }
	};

	opt_init();
	while ((opt = getopt_long(c->argc, c->argv, "", long_opts)) != EOF) {
		switch (opt) {
		case 'h':
			_HELPMSG(out, _CMDNAME, _CMDUSAGE, _CMDDESCR);
			return "";
		case '?':
			_sprintf(out, MAX_MSG, "%s", opterr());
			return "";
		default:
			return "";
		}
	}

	if (optind == c->argc) {
		_USAGEMSG(out, _CMDNAME, _CMDUSAGE);
		return "";
	}

	_sprintf(path, MAX_PATH, "%s%s", utils::configdir().c_str(),
			utils::config("submit").c_str());
	if (!(f = fopen(path, "a"))) {
		_sprintf(out, MAX_MSG, "%s: could not open submission file",
				c->argv[0]);
		perror(path);
		return "";
	}

	t = time(nullptr);

#ifdef __linux__
	msgtm = *localtime(&t);
#endif
#ifdef _WIN32
	localtime_s(&msgtm, &t);
#endif
	strftime(buf, MAX_MSG, "%Y-%m-%d %R", &msgtm);
	fprintf(f, "[%s] ", buf);
	argvcat(buf, c->argc, c->argv, optind, 1);
	fprintf(f, "%s: %s\n", c->nick, buf);
	fclose(f);

	_sprintf(out, MAX_MSG, "@%s, your topic has been submitted. Thank you.",
			c->nick);
	return "";
}

{'fraction_non_alphanumeric': 0.20249017038007863, 'fraction_numerical': 0.0049148099606815205, 'mean_word_length': 4.2010221465076665, 'pattern_counts': {'":': 1, '<': 22, '<?xml version=': 0, '>': 21, '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': '4468345', 'n_tokens_mistral': 1231, 'n_tokens_neox': 1185, 'n_words': 294}