0
0
Fork 0

コメント追加したり

This commit is contained in:
xeltica 2021-09-04 18:24:11 +09:00
parent 1c45e759c3
commit b9575d2c5b
22 changed files with 945 additions and 809 deletions

View file

@ -4,9 +4,11 @@ import _const from '../const';
export const ua = `Mozilla/5.0 misshaialertBot/${_const.version} +https://github.com/Xeltica/misshaialert Node/${process.version}`;
axios.defaults.headers['User-Agent'] = ua;
axios.defaults.validateStatus = (stat) => stat < 500;
/**
* Misskey APIを呼び出す
*/
export const api = <T = Record<string, unknown>>(host: string, endpoint: string, arg: Record<string, unknown>, i?: string): Promise<T> => {
const a = { ...arg };
if (i) {
@ -15,6 +17,12 @@ export const api = <T = Record<string, unknown>>(host: string, endpoint: string,
return axios.post<T>(`https://${host}/api/${endpoint}`, a).then(res => res.data);
};
/**
*
* @param host
* @param i
* @returns truefalse
*/
export const apiAvailable = async (host: string, i: string): Promise<boolean> => {
try {
const res = await api(host, 'i', {}, i);