diff --git a/archive/method.md b/archive/method.md index 3016553..8d79b2f 100644 --- a/archive/method.md +++ b/archive/method.md @@ -205,6 +205,7 @@ for value in mid: `sqrd += [0, 0]`はメッセージの終了を意味します つまり、 + ```py param = [12,1,[ [8,1,0], @@ -212,4 +213,5 @@ param = [12,1,[ [14,3,[11,[mid]]] ]] ``` + と変換できます diff --git a/docs/.vitepress/config.mts b/docs/.vitepress/config.mts index 1f49893..e610c3b 100644 --- a/docs/.vitepress/config.mts +++ b/docs/.vitepress/config.mts @@ -1,72 +1,87 @@ -import { defineConfig } from 'vitepress' +import { defineConfig } from "vitepress"; // https://vitepress.dev/reference/site-config export default defineConfig({ - title: "LINEJS Documentation", - titleTemplate: ":title | LINEJS", - description: "Documentation of LINEJS | LINEJS is a JavaScript library for LINE SelfBot.", - sitemap: { - hostname: 'https://linejs.evex.land', - }, - themeConfig: { - // https://vitepress.dev/reference/default-theme-config - siteTitle: 'LINEJS Docs', - search: { - provider: 'local' - }, + title: "LINEJS Documentation", + titleTemplate: ":title | LINEJS", + description: + "Documentation of LINEJS | LINEJS is a JavaScript library for LINE SelfBot.", + sitemap: { + hostname: "https://linejs.evex.land", + }, + themeConfig: { + // https://vitepress.dev/reference/default-theme-config + siteTitle: "LINEJS Docs", + search: { + provider: "local", + }, - nav: [ - { text: 'Home', link: '/' }, - { text: 'Docs', link: '/docs/start' }, - { text: 'Examples', link: 'https://github.com/evex-dev/linejs' } - ], + nav: [ + { text: "Home", link: "/" }, + { text: "Docs", link: "/docs/start" }, + { text: "Examples", link: "https://github.com/evex-dev/linejs" }, + ], - sidebar: [ - { - text: 'Docs', - items: [ - { text: 'Start', link: '/docs/start' }, - { text: 'Start 2', link: '/docs/start-2' }, - { text: 'Message Event', link: '/docs/message-event' }, - ] - }, - { - text: 'Guides', - items: [ - { text: 'Authors', link: '/docs/authors' }, - { text: 'Question', link: '/docs/question' } - ] - } - ], + sidebar: [ + { + text: "Docs", + items: [ + { text: "Start", link: "/docs/start" }, + { text: "Start 2", link: "/docs/start-2" }, + { text: "Message Event", link: "/docs/message-event" }, + ], + }, + { + text: "Guides", + items: [ + { text: "Authors", link: "/docs/authors" }, + { text: "Question", link: "/docs/question" }, + ], + }, + ], - editLink: { - pattern: 'https://github.com/evex-dev/linejs/edit/main/docs/:path', - text: 'Edit this page on GitHub', - }, + editLink: { + pattern: "https://github.com/evex-dev/linejs/edit/main/docs/:path", + text: "Edit this page on GitHub", + }, - footer: { - message: 'Released under the MIT License.', - copyright: - 'Copyright © '+ new Date().getFullYear() + '-present Evex Developers.', - }, + footer: { + message: "Released under the MIT License.", + copyright: "Copyright © " + new Date().getFullYear() + + "-present Evex Developers.", + }, - socialLinks: [ - { icon: 'github', link: 'https://github.com/evex-dev/linejs' }, - { icon: 'discord', link: 'https://evex.land' } - ] - }, - head: [ - ['link', { rel: 'icon shortcut', href: '/favicon.png' }], - ['link', { rel: 'apple-touch-icon', href: '/favicon.png' }], - ['meta', { name: 'og:title', content: 'LINEJS Documentation' }], - ['meta', { name: 'og:image', content: 'https://linejs.evex.land/favicon.png' }], - ['meta', { name: 'og:description', content: 'LINEJS Documentation | LINEJS is a JavaScript library for LINE SelfBot.' }], - ['meta', { name: 'og:url', content: 'https://linejs.evex.land' }], - ['meta', { name: 'twitter:title', content: 'LINEJS Documentation' }], - ['meta', { name: 'twitter:description', content: 'LINEJS Documentation | LINEJS is a JavaScript library for LINE SelfBot.' }], - ['meta', { name: 'twitter:card', content: 'summary_large_image' }], - ['meta', { name: 'twitter:site', content: '@amex2189' }], - ['meta', { name: 'twitter:creator', content: '@amex2189' }], - ['meta', { name: 'twitter:image', content: 'https://linejs.evex.land/favicon.png' }], - ], -}) + socialLinks: [ + { icon: "github", link: "https://github.com/evex-dev/linejs" }, + { icon: "discord", link: "https://evex.land" }, + ], + }, + head: [ + ["link", { rel: "icon shortcut", href: "/favicon.png" }], + ["link", { rel: "apple-touch-icon", href: "/favicon.png" }], + ["meta", { name: "og:title", content: "LINEJS Documentation" }], + ["meta", { + name: "og:image", + content: "https://linejs.evex.land/favicon.png", + }], + ["meta", { + name: "og:description", + content: + "LINEJS Documentation | LINEJS is a JavaScript library for LINE SelfBot.", + }], + ["meta", { name: "og:url", content: "https://linejs.evex.land" }], + ["meta", { name: "twitter:title", content: "LINEJS Documentation" }], + ["meta", { + name: "twitter:description", + content: + "LINEJS Documentation | LINEJS is a JavaScript library for LINE SelfBot.", + }], + ["meta", { name: "twitter:card", content: "summary_large_image" }], + ["meta", { name: "twitter:site", content: "@amex2189" }], + ["meta", { name: "twitter:creator", content: "@amex2189" }], + ["meta", { + name: "twitter:image", + content: "https://linejs.evex.land/favicon.png", + }], + ], +}); diff --git a/docs/.vitepress/theme/index.ts b/docs/.vitepress/theme/index.ts index e037e91..ec4f87f 100644 --- a/docs/.vitepress/theme/index.ts +++ b/docs/.vitepress/theme/index.ts @@ -1,17 +1,16 @@ // https://vitepress.dev/guide/custom-theme -import { h } from 'vue' -import type { Theme } from 'vitepress' -import DefaultTheme from 'vitepress/theme' -import './style.css' +import { h } from "vue"; +import type { Theme } from "vitepress"; +import DefaultTheme from "vitepress/theme"; +import "./style.css"; export default { - extends: DefaultTheme, - Layout: () => { - return h(DefaultTheme.Layout, null, { - // https://vitepress.dev/guide/extending-default-theme#layout-slots - }) - }, - enhanceApp({ app, router, siteData }) { - - } -} satisfies Theme + extends: DefaultTheme, + Layout: () => { + return h(DefaultTheme.Layout, null, { + // https://vitepress.dev/guide/extending-default-theme#layout-slots + }); + }, + enhanceApp({ app, router, siteData }) { + }, +} satisfies Theme; diff --git a/docs/deno.json b/docs/deno.json index f19f613..7525125 100644 --- a/docs/deno.json +++ b/docs/deno.json @@ -1,8 +1,8 @@ { - "tasks": { - "vp": "deno run -A npm:vitepress" - }, - "unstable": [ - "byonm" - ] -} \ No newline at end of file + "tasks": { + "vp": "deno run -A npm:vitepress" + }, + "unstable": [ + "byonm" + ] +} diff --git a/docs/docs/authors.md b/docs/docs/authors.md index c02f309..ba473bc 100644 --- a/docs/docs/authors.md +++ b/docs/docs/authors.md @@ -1,10 +1,13 @@ # Authors + Maintainers of **LINEJS** ## Maintainers + - Owner & Developer [Piloking](https://github.com/piloking) - Developer [EdamAme-x](https://github.com/EdamAme-x) ## Sub-maintainers + - Developer [MocA-Love](https://github.com/MocA-Love) - Developer [Hafusun](https://github.com/hafusun) diff --git a/docs/docs/message-event.md b/docs/docs/message-event.md index be3e57b..da5cbf3 100644 --- a/docs/docs/message-event.md +++ b/docs/docs/message-event.md @@ -1,2 +1,3 @@ # Receive Message Event -Coming soon... \ No newline at end of file + +Coming soon... diff --git a/docs/docs/question.md b/docs/docs/question.md index 0a74237..7d378c5 100644 --- a/docs/docs/question.md +++ b/docs/docs/question.md @@ -1,4 +1,5 @@ # Question + This is our server. Feel free to ask questions! [https://discord.gg/evex](https://discord.gg/evex) diff --git a/docs/docs/start-2.md b/docs/docs/start-2.md index d702f6a..1c01a7f 100644 --- a/docs/docs/start-2.md +++ b/docs/docs/start-2.md @@ -18,7 +18,7 @@ client.on("pincall", (pincode) => { client.on("ready", async (user) => { console.log(`Logged in as ${user.displayName} (${user.mid})`); - console.log(await client.getProfile()); + console.log(await client.getProfile()); }); await client.login({ @@ -39,24 +39,25 @@ The output will be as follows. } ``` -I will tell you one thing here. -When you log in, you can use a better choice. +I will tell you one thing here.\ +When you log in, you can use a better choice. -Logging in repeatedly with *email* may be regarded as fraudulent login -and your account may be temporarily restricted (though only for a few days), and above all, It is very cumbersome. +Logging in repeatedly with _email_ may be regarded as fraudulent login\ +and your account may be temporarily restricted (though only for a few days), and +above all, It is very cumbersome. -It is therefore a good idea to use an **AuthToken**. +It is therefore a good idea to use an **AuthToken**. -A temporary token is used for email login. -Therefore, after a few days, it will expire and the client will stop running. +A temporary token is used for email login.\ +Therefore, after a few days, it will expire and the client will stop running.\ So, if you want to run the client permanently, you must use v1. -It would be a good idea to use v2 during development. +It would be a good idea to use v2 during development.\ Repeating the email login multiple times is highly discouraged. Now, let's look at how to get token. -Simply write the following. +Simply write the following.\ It's easy. ```ts @@ -71,8 +72,7 @@ The output will be as follows. AuthToken **********.******** ``` -This is the v2 token. -It can be used as follows +This is the v2 token. It can be used as follows ```ts await client.login({ @@ -80,42 +80,41 @@ await client.login({ }); ``` -However, this login method has pitfalls. -LINE uses *e2ee* for encryption, but the key to decrypt it can only be obtained with an email login. +However, this login method has pitfalls. LINE uses _e2ee_ for encryption, but +the key to decrypt it can only be obtained with an email login. -Therefore, if you login only with an authToken, you will not be able to retrieve group talk events. +Therefore, if you login only with an authToken, you will not be able to retrieve +group talk events.\ (Square (open chat) is possible.) -So how can we do this?   -It's easy, too. +So how can we do this?   It's easy, too. -We just need to make the internal storage permanent and log in with email first only once. +We just need to make the internal storage permanent and log in with email first +only once. -LINEJS has internal storage for storing and caching. -By default, it is `MemoryStorage`, and it all disappears after one execution. +LINEJS has internal storage for storing and caching.\ +By default, it is `MemoryStorage`, and it all disappears after one execution. -This can be `FileStorage`. -As follows. +This can be `FileStorage`. As follows. ```ts import { FileStorage } from "@evex/linejs/storage"; const client = new Client({ - storage: new FileStorage("./storage.json"), // path to storage file (This is secret file) -}) + storage: new FileStorage("./storage.json"), // path to storage file (This is secret file) +}); ``` -You only need to log in once first with your email and then use your authToken. +You only need to log in once first with your email and then use your authToken. -This concludes our first trip. -But there is still a journey left to be made. +This concludes our first trip.\ +But there is still a journey left to be made.\ Enjoy. -:::info -If you want to create your own storage such as connecting to the cloud api, -import `BaseStorage` and extend it to create your own storage. (Please ask for details.) -::: +:::info If you want to create your own storage such as connecting to the cloud +api,\ +import `BaseStorage` and extend it to create your own storage. (Please ask for +details.) ::: -:::info -If you want to use v1, please ask for details at [discord.gg/evex](https://discord.gg/evex). -::: \ No newline at end of file +:::info If you want to use v1, please ask for details at +[discord.gg/evex](https://discord.gg/evex). ::: diff --git a/docs/docs/start.md b/docs/docs/start.md index a73c592..9dc2661 100644 --- a/docs/docs/start.md +++ b/docs/docs/start.md @@ -1,4 +1,5 @@ # Getting Started + LINEJS is always by your side Thank you for choosing this library! @@ -11,9 +12,10 @@ bunx --bun jsr add @evex/linejs deno add @evex/linejs ``` -After execution, you should have the library available. +After execution, you should have the library available. + +Next, let's create a script that just retrieves your profile! -Next, let's create a script that just retrieves your profile! ```ts import { Client } from "@evex/linejs"; @@ -33,12 +35,10 @@ await client.login({ }); // (If you're using Node.js, please wrap async IIFE) ``` -First, log in using your *email*. We will explain each code later. +First, log in using your _email_. We will explain each code later.\ (LINEJS supports login by **AuthToken**, **QR** and **Pincode**.) -:::warning -Please enable email login in your settings. -::: +:::warning Please enable email login in your settings. ::: The method of execution depends on the runtime. @@ -57,10 +57,11 @@ Then, you will see the following output. pincode: 114514 ``` -You will then receive a login request on the LINE app for the account you wish to log in to, and enter the pin code displayed. +You will then receive a login request on the LINE app for the account you wish +to log in to, and enter the pin code displayed. -By the way, `114514` is Japanese slang. -If you don't like it or think it's messy, you can change it by doing the following. +By the way, `114514` is Japanese slang. If you don't like it or think it's +messy, you can change it by doing the following. ```ts await client.login({ @@ -75,16 +76,16 @@ The output will then be as follows. Logged in as EdamAmex (u********************************) ``` -Now, you have obtained a `displayName` and `mid`! -On successful login, `ready` is called and the user object is passed. +Now, you have obtained a `displayName` and `mid`!\ +On successful login, `ready` is called and the user object is passed. -There you will find your complete profile. -Of course, there is another way to get it from the method. +There you will find your complete profile. Of course, there is another way to +get it from the method. Let's try that next! --- -This library is still in its infancy! -If you find any bugs or missing parts, please let us know on our server! -(Roles will be given to those who suggest bugs and features!) \ No newline at end of file +This library is still in its infancy!\ +If you find any bugs or missing parts, please let us know on our +server! (Roles will be given to those who suggest bugs and features!) diff --git a/docs/index.md b/docs/index.md index 1c98ec0..d14c401 100644 --- a/docs/index.md +++ b/docs/index.md @@ -25,4 +25,3 @@ features: icon: 🔒 details: Defaults to safety locked. (RateLimit and others) --- - diff --git a/docs/package.json b/docs/package.json index b482155..02414a5 100644 --- a/docs/package.json +++ b/docs/package.json @@ -1,13 +1,13 @@ { - "name": "linejs-docs", - "version": "0.0.0", - "scripts": { - "dev": "vitepress dev docs", - "build": "vitepress build docs", - "serve": "vitepress serve docs" - }, - "devDependencies": { - "vitepress": "^1.3.4", - "vue": "^3.5.3" - } -} \ No newline at end of file + "name": "linejs-docs", + "version": "0.0.0", + "scripts": { + "dev": "vitepress dev docs", + "build": "vitepress build docs", + "serve": "vitepress serve docs" + }, + "devDependencies": { + "vitepress": "^1.3.4", + "vue": "^3.5.3" + } +} diff --git a/packages/client/clients/base-client.ts b/packages/client/clients/base-client.ts index 7038bdd..4fe2b98 100644 --- a/packages/client/clients/base-client.ts +++ b/packages/client/clients/base-client.ts @@ -1306,7 +1306,7 @@ export class BaseClient extends TypedEventEmitter { if (__force) { this.storage.clear(); - + await this.request( [], "logoutZ", diff --git a/packages/client/clients/internal/square-client.ts b/packages/client/clients/internal/square-client.ts index cfd49b2..6105867 100644 --- a/packages/client/clients/internal/square-client.ts +++ b/packages/client/clients/internal/square-client.ts @@ -312,9 +312,8 @@ export class SquareClient extends LiffClient { message.push([11, 21, relatedMessageId], [8, 22, 3], [8, 24, 2]); } - const { promise, resolve } = Promise.withResolvers< - LINETypes.SendMessageResponse - >(); + const { promise, resolve } = + Promise.withResolvers(); const request = async () => { resolve( @@ -677,7 +676,10 @@ export class SquareClient extends LiffClient { }): Promise { const { squareChatMid, revision } = { revision: 0, ...options }; return await this.request( - [[11, 2, squareChatMid], [10, 3, revision]], + [ + [11, 2, squareChatMid], + [10, 3, revision], + ], "deleteSquareChat", this.SquareService_PROTOCOL_TYPE, true, diff --git a/packages/client/clients/internal/talk-client.ts b/packages/client/clients/internal/talk-client.ts index c6f6ea0..6bb28de 100644 --- a/packages/client/clients/internal/talk-client.ts +++ b/packages/client/clients/internal/talk-client.ts @@ -5,6 +5,7 @@ import type * as LINETypes from "../../libs/thrift/line_types.ts"; import type { LooseType } from "../../entities/common.ts"; import { ChannelClient } from "./channel-client.ts"; import type { Buffer } from "node:buffer"; +import { InternalError } from "../../entities/errors.ts"; export class TalkClient extends ChannelClient { protected TalkService_API_PATH = "/S4"; @@ -156,11 +157,9 @@ export class TalkClient extends ChannelClient { /** * @description Unsend message. */ - public async unsendMessage( - options: { - messageId: string; - }, - ): Promise { + public async unsendMessage(options: { + messageId: string; + }): Promise { const { messageId } = { ...options, }; @@ -185,12 +184,10 @@ export class TalkClient extends ChannelClient { /** * @description React to the message. */ - public async reactToMessage( - options: { - messageId: string; - reactionType: number; - }, - ): Promise { + public async reactToMessage(options: { + messageId: string; + reactionType: number; + }): Promise { const { messageId, reactionType } = { ...options, }; @@ -203,9 +200,7 @@ export class TalkClient extends ChannelClient { [ [8, 1, 0], [10, 2, messageId], - [12, 3, [ - [8, 1, reactionType], - ]], + [12, 3, [[8, 1, reactionType]]], ], ], ], @@ -393,12 +388,10 @@ export class TalkClient extends ChannelClient { /** * @description Kick out members of the chat. */ - public async deleteOtherFromChat( - options: { - to: string; - mid: string; - }, - ): Promise { + public async deleteOtherFromChat(options: { + to: string; + mid: string; + }): Promise { const { to, mid } = { ...options, }; @@ -424,11 +417,9 @@ export class TalkClient extends ChannelClient { /** * @description Leave the chat. */ - public async deleteSelfFromChat( - options: { - to: string; - }, - ): Promise { + public async deleteSelfFromChat(options: { + to: string; + }): Promise { const { to } = { ...options, }; @@ -453,11 +444,9 @@ export class TalkClient extends ChannelClient { /** * @description Accept the chat invitation and join. */ - public async acceptChatInvitation( - options: { - to: string; - }, - ): Promise { + public async acceptChatInvitation(options: { + to: string; + }): Promise { const { to } = { ...options, }; @@ -482,11 +471,9 @@ export class TalkClient extends ChannelClient { /** * @description Issue a ticket to join the chat. */ - public async reissueChatTicket( - options: { - groupMid: string; - }, - ): Promise { + public async reissueChatTicket(options: { + groupMid: string; + }): Promise { const { groupMid } = { ...options, }; @@ -511,24 +498,14 @@ export class TalkClient extends ChannelClient { /** * @description Find the chat from the ticket. */ - public async findChatByTicket( - options: { - ticketId: string; - }, - ): Promise { + public async findChatByTicket(options: { + ticketId: string; + }): Promise { const { ticketId } = { ...options, }; return await this.direct_request( - [ - [ - 12, - 1, - [ - [11, 1, ticketId], - ], - ], - ], + [[12, 1, [[11, 1, ticketId]]]], "findChatByTicket", this.TalkService_PROTOCOL_TYPE, "FindChatByTicketResponse", @@ -539,12 +516,10 @@ export class TalkClient extends ChannelClient { /** * @description Join the chat using the ticket. */ - public async acceptChatInvitationByTicket( - options: { - to: string; - ticket: string; - }, - ): Promise { + public async acceptChatInvitationByTicket(options: { + to: string; + ticket: string; + }): Promise { const { to, ticket } = { ...options, }; @@ -570,17 +545,19 @@ export class TalkClient extends ChannelClient { /** * @description Update the information for the specified chat. */ - public async updateChat( - options: { - chatMid: string; - chatSet: LINETypes.Chat; - updatedAttribute: number; - }, - ): Promise { + public async updateChat(options: { + chatMid: string; + chatSet: LINETypes.Chat; + updatedAttribute: number; + }): Promise { const { chatMid, chatSet, updatedAttribute } = { ...options, }; + if (chatSet) { + throw new InternalError("Not Impl", "Please wait update"); + } + return await this.direct_request( [ [ @@ -592,32 +569,32 @@ export class TalkClient extends ChannelClient { 12, 2, [ - [8, 1, chatSet[1]], + [8, 1, "__NO__"], [11, 2, chatMid], - chatSet[4] !== undefined ? [2, 4, chatSet[4]] : null, - chatSet[6] !== undefined ? [11, 6, chatSet[6]] : null, - chatSet[8] !== undefined + "__NO__" !== undefined ? [2, 4, "__NO__"] : null, + "__NO__" !== undefined ? [11, 6, "__NO__"] : null, + "__NO__" !== undefined ? [ - 12, - 8, - [ + 12, + 8, [ - 12, - 1, [ - chatSet[8][2] !== undefined - ? [2, 2, chatSet[8][2]] - : null, - chatSet[8][6] !== undefined - ? [2, 6, chatSet[8][6]] - : null, - chatSet[8][7] !== undefined - ? [2, 7, chatSet[8][7]] - : null, + 12, + 1, + [ + "__NO__"[2] !== undefined + ? [2, 2, "__NO__"[2]] + : null, + "__NO__"[6] !== undefined + ? [2, 6, "__NO__"[6]] + : null, + "__NO__"[7] !== undefined + ? [2, 7, "__NO__"[7]] + : null, + ], ], ], - ], - ] + ] : null, ], ],