#include <bits/stdc++.h>
// 定义星野粉色ANSI颜色代码
#define PINK_START "\033[38;5;218m"
#define BLUE_START "\033[38;5;117m"
#define CYAN_START "\033[38;5;51m"
#define RESET_COLOR "\033[0m"
class ShittinBoxAI {
private:
std::string userName;
// 获取当前时间并返回问候语[2]^
std::string getGreeting() {
std::time_t now = std::time(nullptr);
std::tm* localTime = std::localtime(&now);
int hour = localTime->tm_hour;
if (hour >= 5 && hour < 12) {
return "早上好,老师!今天也要充满活力哦~";
} else if (hour >= 12 && hour < 18) {
return "中午好,老师!午饭吃了吗?";
} else if (hour >= 18 && hour < 22) {
return "晚上好,老师!今天辛苦了~";
} else {
return "夜深了,老师!要注意休息哦~";
}
}
// 获取带格式的当前时间[2]
std::string getCurrentTime(bool detailed = false) {
auto now = std::chrono::system_clock::now();
std::time_t timeT = std::chrono::system_clock::to_time_t(now);
std::tm* localTime = std::localtime(&timeT);
std::stringstream ss;
if (detailed) {
// 获取毫秒部分[5]^
auto ms = std::chrono::duration_cast<std::chrono::milliseconds>(
now.time_since_epoch()) % 1000;
ss << std::put_time(localTime, "%Y年%m月%d日 %H:%M:%S");
ss << "." << std::setfill('0') << std::setw(3) << ms.count();
} else {
ss << std::put_time(localTime, "%H:%M:%S");
}
return ss.str();
}
// 显示什亭之箱启动界面
void showStartupScreen() {
std::system("clear || cls");
std::cout << PINK_START << "╔════════════════════════════════════════╗\n";
std::cout << "║ 什亭之箱 - 星野特别版 ║\n";
std::cout << "║ Shittin Box AI Assistant v1.0 ║\n";
std::cout << "╚════════════════════════════════════════╝\n\n";
std::cout << BLUE_START << "正在启动系统..." << RESET_COLOR << std::endl;
// 模拟启动过程
for (int i = 0; i < 3; ++i) {
std::cout << PINK_START << ".";
std::cout.flush();
std::this_thread::sleep_for(std::chrono::milliseconds(300));
}
std::cout << RESET_COLOR << "\n\n";
}
public:
ShittinBoxAI() : userName("老师") {}
void run() {
showStartupScreen();
std::cout << PINK_START << getGreeting() << RESET_COLOR << "\n\n";
std::cout << "我是什亭之箱AI助手,可以为您提供以下服务:\n";
std::cout << CYAN_START << "1. 查看当前时间\n";
std::cout << "2. 详细时间信息\n";
std::cout << "3. 更改称呼\n";
std::cout << "4. 显示帮助\n";
std::cout << "5. 退出系统\n" << RESET_COLOR;
bool running = true;
while (running) {
std::cout << PINK_START << "\n[" << userName << "] " << RESET_COLOR;
std::cout << "请输入指令 (输入4查看帮助): ";
std::string command;
std::getline(std::cin, command);
if (command == "1") {
std::cout << CYAN_START << "当前时间: " << getCurrentTime()
<< RESET_COLOR << std::endl;
}
else if (command == "2") {
std::cout << CYAN_START << "详细时间: " << getCurrentTime(true)
<< RESET_COLOR << std::endl;
}
else if (command == "3") {
std::cout << "请输入您希望我如何称呼您: ";
std::getline(std::cin, userName);
std::cout << PINK_START << "好的," << userName << "!"
<< RESET_COLOR << std::endl;
}
else if (command == "4") {
displayHelp();
}
else if (command == "5" || command == "exit" || command == "quit") {
std::cout << PINK_START << "再见," << userName
<< "!什亭之箱期待与您再次相会~" << RESET_COLOR << std::endl;
running = false;
}
else {
std::cout << PINK_START << "抱歉," << userName
<< ",我不太明白这个指令呢~" << RESET_COLOR << std::endl;
}
}
}
void displayHelp() {
std::cout << CYAN_START << "\n════════════ 帮助菜单 ════════════\n";
std::cout << "1 - 查看当前时间(时:分:秒)\n";
std::cout << "2 - 查看详细时间信息(含毫秒)\n";
std::cout << "3 - 更改AI对您的称呼\n";
std::cout << "4 - 显示此帮助菜单\n";
std::cout << "5/exit/quit - 退出程序\n";
std::cout << "═══════════════════════════════\n" << RESET_COLOR;
}
};
int main() {
ShittinBoxAI ai;
ai.run();
return 0;
}