コメント追加したり
This commit is contained in:
parent
1c45e759c3
commit
b9575d2c5b
22 changed files with 945 additions and 809 deletions
|
@ -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 トークンが有効ならtrue、無効ならfalse
|
||||
*/
|
||||
export const apiAvailable = async (host: string, i: string): Promise<boolean> => {
|
||||
try {
|
||||
const res = await api(host, 'i', {}, i);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue