Commit f41e86b7 authored by nanahira's avatar nanahira

missing

parent acc735d3
Pipeline #21033 passed with stages
in 2 minutes
import axios from 'axios';
import config from '../config';
interface HanatanReturnMessageData {
session: string;
conversationId: string;
messageId: string;
text: string;
}
interface HanatanReturnMessage {
statusCode: number;
message: string;
success: boolean;
data: HanatanReturnMessageData;
}
export const checkUsernameByHanatan = async (username: string) => {
if (!config.Hanatan.enable) {
return false;
}
try {
const result = await axios.post<HanatanReturnMessage>(
`${config.Hanatan.url}/api/chat`,
{
text: `${config.Hanatan.prompt}\n${username}`,
},
{
headers: {
Authorization: `Bearer ${config.Hanatan.token || 'default'}`,
},
timeout: 10000,
},
);
return result.data.data.text.includes('YES') && !result.data.data.text.includes('NO');
} catch (e) {
console.error(`Hanatan error: ${e}`);
return false;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment