@kotori-bot/core
Version:
Kotori Core
549 lines (548 loc) • 14.5 kB
JavaScript
/**
* @Package @kotori-bot/core
* @Version 1.7.2
* @Author Arimura Sena <me@hotaru.icu>
* @Copyright 2024-2025 Hotaru. All rights reserved.
* @License GPL-3.0
* @Link https://github.com/kotorijs/kotori
* @Date 2026/2/14 15:50:13
*/
;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var api_exports = {};
__export(api_exports, {
Api: () => Api,
default: () => api_default
});
module.exports = __toCommonJS(api_exports);
var import_tools = require("@kotori-bot/tools");
class Api {
/**
* Get supported actions for current api implementation.
*
* @returns Supported actions
*/
getSupportedActions() {
return Object.getOwnPropertyNames(Api.prototype).filter(
(key) => typeof key === "string" && !["getSupportedActions", "adapter", "constructor"].includes(key) && this[key] instanceof Function && this[key] !== Api.prototype[key]
);
}
/**
* Current api's bot instance.
*
* @readonly
*/
// biome-ignore lint: *
adapter;
/**
* Api class constructor.
*
* @param adapter - Current api's bot instance
*/
// biome-ignore lint: *
constructor(adapter) {
this.adapter = adapter;
}
/**
* Send a private message.
*
* @param message - Message content to send
* @param userId - Target user id
* @param meta - Extra meta data, optional
* @returns Message id and send time
*
* @async
*/
async sendPrivateMsg(message, userId, meta = {}) {
(0, import_tools.none)(this, message, userId, meta);
return { messageId: "", time: 0 };
}
/**
* Send a group message.
*
* @param message - Message content to send
* @param groupId - Target group id
* @param meta - Extra meta data, optional
* @returns Message id and send time
*
* @async
*/
async sendGroupMsg(message, groupId, meta = {}) {
(0, import_tools.none)(this, message, groupId, meta, meta);
return { messageId: "", time: 0 };
}
/**
* Send a channel message.
*
* @param message - Message content to send
* @param guildId - Target guild id
* @param channelId - Target channel id
* @param meta - Extra meta data, optional
* @returns Message id and send time
*
* @async
*/
async sendChannelMsg(message, guildId, channelId, meta = {}) {
(0, import_tools.none)(this, message, guildId, channelId, meta);
return { messageId: "", time: 0 };
}
/**
* Delete a message.
*
* Required target message that is sent by self or bot had manger permission.
*
* @param messageId - Target message id
* @param meta - Extra meta data, optional
*
* @async
*/
deleteMsg(messageId, meta = {}) {
(0, import_tools.none)(this, messageId, meta);
}
/**
* Get information about the bot itself.
*
* @returns Self info
*
* @async
*/
async getSelfInfo(meta = {}) {
(0, import_tools.none)(this, meta);
return { userId: "", username: "", userDisplayname: "" };
}
/**
* Get user information.
*
* @param userId - Target user id, can be the friend or the stronger
* @param meta - Extra meta data, optional
* @returns User info
*
* @async
*/
async getUserInfo(userId, meta = {}) {
(0, import_tools.none)(this, userId, meta);
return { userId: "", username: "", userDisplayname: "", userRemark: "" };
}
/**
* Get friend list.
*
* @param meta - Extra meta data, optional
* @returns Friend list information
*
* @async
*/
async getFriendList(meta = {}) {
(0, import_tools.none)(this, meta);
return [];
}
/**
* Get group information.
*
* @param groupId - Target group id
* @param meta - Extra meta data, optional
* @returns Group info
*
* @async
*/
async getGroupInfo(groupId, meta = {}) {
(0, import_tools.none)(this, groupId, meta);
return { groupId: "", groupName: "" };
}
/**
* Get group list.
*
* @param meta - Extra meta data, optional
* @returns Group list information
*
* @async
*/
async getGroupList(meta = {}) {
(0, import_tools.none)(this, meta);
return [];
}
/**
* Get group member information.
*
* @param groupId - Target group id
* @param userId - Target user id
* @param meta - Extra meta data, optional
* @returns Group member info
*
* @async
*/
async getGroupMemberInfo(groupId, userId, meta = {}) {
(0, import_tools.none)(this, groupId, userId, meta);
return { userId: "", username: "", userDisplayname: "" };
}
/**
* Get group member list.
*
* @param groupId - Target group id
* @param meta - Extra meta data, optional
* @returns Group member list information
*
* @async
*/
async getGroupMemberList(groupId, meta = {}) {
(0, import_tools.none)(this, groupId, meta);
return [];
}
/**
* Set group information.
*
* @param groupId - Target group id
* @param groupName - Group name
* @param meta - Extra meta data, optional
*/
setGroupName(groupId, groupName, meta = {}) {
(0, import_tools.none)(this, groupId, groupName, meta);
}
/**
* Leave a group, if bot is owner so it will be destroy the group.
*
* @param groupId - Target group id
* @param meta - Extra meta data, optional
*/
leaveGroup(groupId, meta = {}) {
(0, import_tools.none)(this, groupId, meta);
}
/**
* Get guild information.
*
* @param guildId - Target guild id
* @param meta - Extra meta data, optional
* @returns Guild info
*
* @async
*/
async getGuildInfo(guildId, meta = {}) {
(0, import_tools.none)(this, guildId, meta);
return { guildId: "", guildName: "" };
}
/**
* Get guild list.
*
* @param meta - Extra meta data, optional
* @returns Guild list information
*
* @async
*/
async getGuildList(meta = {}) {
(0, import_tools.none)(this, meta);
return [];
}
/**
* Set guild information.
*
* @param guildId - Target guild id
* @param guildName - Guild name
* @param meta - Extra meta data, optional
*/
setGuildName(guildId, guildName, meta = {}) {
(0, import_tools.none)(this, guildId, guildName, meta);
}
/**
* Get guild member information.
*
* @param guildId - Target guild id
* @param channelId - Target channel id
* @param userId - Target user id
* @param meta - Extra meta data, optional
* @returns Guild member info
*
* @async
*/
async getGuildMemberInfo(guildId, userId, meta = {}) {
(0, import_tools.none)(this, guildId, userId, meta);
return { userId: "", username: "", userDisplayname: "", userRemark: "" };
}
/**
* Get guild member list.
*
* @param guildId - Target guild id
* @param channelId - Target channel id
* @param meta - Extra meta data, optional
* @returns Guild member list information
*
* @async
*/
async getGuildMemberList(guildId, meta = {}) {
(0, import_tools.none)(this, guildId, meta);
return [];
}
/**
* Leave a guild.
*
* @param guildId - Target guild id
* @param meta - Extra meta data, optional
*/
leaveGuild(guildId, meta = {}) {
(0, import_tools.none)(this, guildId, meta);
}
/**
* Get channel information.
*
* @param guildId - Target guild id
* @param channelId - Target channel id
* @param meta - Extra meta data, optional
* @returns Channel info
*
* @async
*/
async getChannelInfo(guildId, channelId, meta = {}) {
(0, import_tools.none)(this, guildId, channelId, meta);
return { channelId: "", channelName: "" };
}
/**
* Get channel list.
*
* @param guildId - Target guild id
* @param joinedOnly - Whether to get joined channels only, default is false
* @param meta - Extra meta data, optional
* @returns Channel list information
*
* @async
*/
async getChannelList(guildId, joinedOnly = false, meta = {}) {
(0, import_tools.none)(this, guildId, joinedOnly, meta);
return [];
}
/**
* Set channel information.
*
* @param guildId - Target guild id
* @param channelId - Target channel id
* @param channelName - Channel name
* @param meta - Extra meta data, optional
*/
setChannelName(guildId, channelId, channelName, meta = {}) {
(0, import_tools.none)(this, guildId, channelId, channelName, meta);
}
/**
* Get channel member information.
*
* @param guildId - Target guild id
* @param channelId - Target channel id
* @param userId - Target user id
* @param meta - Extra meta data, optional
* @returns Channel member info
*
* @async
*/
async getChannelMemberInfo(guildId, channelId, userId, meta = {}) {
(0, import_tools.none)(this, guildId, channelId, userId, meta);
return { userId: "", username: "", userDisplayname: "", userRemark: "" };
}
/**
* Get channel member list.
*
* @param guildId - Target guild id
* @param channelId - Target channel id
* @param meta - Extra meta data, optional
* @returns Channel member list information
*
* @async
*/
async getChannelMemberList(guildId, channelId, meta = {}) {
(0, import_tools.none)(this, guildId, channelId, meta);
return [];
}
/**
* Leave a channel.
*
* @param guildId - Target guild id
* @param channelId - Target channel id
* @param meta - Extra meta data, optional
*/
leaveChannel(guildId, channelId, meta = {}) {
(0, import_tools.none)(this, guildId, channelId, meta);
}
/**
* Upload file from url.
*
* @param name - File name
* @param url - File url
* @param headers - File download url headers, optional
* @param meta - Extra meta data, optional
* @returns File id
*
* @async
*/
async uploadFileUrl(name, url, headers = {}, meta = {}) {
(0, import_tools.none)(this, name, url, headers, meta);
return { filedId: "" };
}
/**
* Upload file from path.
*
* @param name - File name
* @param path - File path
* @param meta - Extra meta data, optional
* @returns File id
*
* @async
*/
async uploadFilePath(name, path, meta = {}) {
(0, import_tools.none)(this, name, path, meta);
return { filedId: "" };
}
/**
* Upload file from data.
*
* @param name - File name
* @param data - File data
* @param meta - Extra meta data, optional
* @returns File id
*
* @async
*/
async uploadFileData(name, data, meta = {}) {
(0, import_tools.none)(this, name, data, meta);
return { filedId: "" };
}
/**
* Get file url.
*
* @param filedId - File id
* @param meta - Extra meta data, optional
* @returns File url data
*
* @async
*/
async getFileUrl(filedId, meta = {}) {
(0, import_tools.none)(this, filedId, meta);
return { name: "", sha256: "", url: "", headers: {} };
}
/**
* Get file path.
*
* @param filedId - File id
* @param meta - Extra meta data, optional
* @returns File path data
*
* @async
*/
async getFilePath(filedId, meta = {}) {
(0, import_tools.none)(this, filedId, meta);
return { name: "", sha256: "", path: "" };
}
/**
* Get file data.
*
* @param filedId - File id
* @param meta - Extra meta data, optional
* @returns File data
*
* @async
*/
async getFileData(filedId, meta = {}) {
(0, import_tools.none)(this, filedId, meta);
return { name: "", sha256: "", data: Buffer.from("") };
}
/**
* Set group avatar.
*
* @param groupId - Target group id
* @param image - Image data
* @param meta - Extra meta data, optional
*
* @experimental
*/
setGroupAvatar(groupId, image, meta = {}) {
(0, import_tools.none)(this, groupId, image, meta);
}
/**
* Set group admin.
*
* @param groupId - Target group id
* @param userId - Target user id
* @param enable - Whether to set admin
* @param meta - Extra meta data, optional
*
* @experimental
*/
setGroupAdmin(groupId, userId, enable, meta = {}) {
(0, import_tools.none)(this, groupId, userId, enable, meta);
}
/**
* Set group card.
*
* @param groupId - Target group id
* @param userId - Target user id
* @param card - Card content
* @param meta - Extra meta data, optional
*
* @experimental
*/
setGroupCard(groupId, userId, card, meta = {}) {
(0, import_tools.none)(this, groupId, userId, card, meta);
}
/**
* Set group members ban or unban.
*
* @param groupId - Target group id
* @param userId - Target user id
* @param time - Ban time, 0 means unban
* @param meta - Extra meta data, optional
*
* @experimental
*/
setGroupBan(groupId, userId, time, meta = {}) {
(0, import_tools.none)(this, groupId, userId, time, meta);
}
/**
* Set group new notice.
*
* @param groupId - Target group id
* @param content - Notice content
* @param image - Notice image, optional
* @param meta - Extra meta data, optional
*
* @experimental
*/
sendGroupNotice(groupId, content, image, meta = {}) {
(0, import_tools.none)(this, groupId, content, image, meta);
}
/**
* Set group whole ban
*
* @param groupId - Target group id
* @param enable - Whether to ban
*/
setGroupWholeBan(groupId, enable = true) {
this.adapter.send("set_group_whole_ban", { group_id: Number(groupId), enable });
}
/**
* Set group members kicked.
*
* @param groupId - Target group id
* @param userId - Target user id
* @param meta - Extra meta data, optional
*
* @experimental
*/
setGroupKick(groupId, userId, meta = {}) {
(0, import_tools.none)(this, groupId, userId, meta);
}
}
var api_default = Api;
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
Api
});