Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Sharkey
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
1673 esurio
Sharkey
Commits
170e8436
Unverified
Commit
170e8436
authored
3 years ago
by
syuilo
Committed by
GitHub
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Update README.md
parent
42b611de
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
README.md
+11
-12
11 additions, 12 deletions
README.md
with
11 additions
and
12 deletions
README.md
+
11
−
12
View file @
170e8436
...
...
@@ -23,6 +23,17 @@ npm i misskey-js
```
# Usage
インポートは以下のようにまとめて行えます。
```
ts
import
*
as
Misskey
from
'
misskey-js
'
;
```
便宜上、以後のコード例は上記のように
`* as Misskey`
としてインポートしている前提のものになります。
まとめてインポートを行うとTree-Shakingできなくなるので、適宜変更をおすすめします。
## Authenticate
todo
...
...
@@ -30,8 +41,6 @@ todo
APIを利用する際は、利用するサーバーの情報とアクセストークンを与えて
`APIClient`
クラスのインスタンスを初期化し、そのインスタンスの
`request`
メソッドを呼び出してリクエストを行います。
```
ts
import
*
as
Misskey
from
'
misskey-js
'
;
const
cli
=
new
Misskey
.
api
.
APIClient
({
origin
:
'
https://misskey.test
'
,
credential
:
'
TOKEN
'
,
...
...
@@ -48,8 +57,6 @@ misskey.jsのストリーミングでは、二つのクラスが提供されま
ストリーミングを利用する際は、まず
`Stream`
クラスのインスタンスを初期化し、その後で
`Stream`
インスタンスのメソッドを利用して
`Channel`
クラスのインスタンスを取得する形になります。
```
ts
import
*
as
Misskey
from
'
misskey-js
'
;
const
stream
=
new
Misskey
.
Stream
(
'
https://misskey.test
'
,
{
token
:
'
TOKEN
'
});
const
mainChannel
=
stream
.
useChannel
(
'
main
'
);
mainChannel
.
on
(
'
notification
'
,
notification
=>
{
...
...
@@ -93,8 +100,6 @@ mainChannel.dispose();
`Channel`
クラスはEventEmitterを継承しており、メッセージがサーバーから受信されると受け取ったイベント名でペイロードをemitします。
```
ts
import
*
as
Misskey
from
'
misskey-js
'
;
const
stream
=
new
Misskey
.
Stream
(
'
https://misskey.test
'
,
{
token
:
'
TOKEN
'
});
const
mainChannel
=
stream
.
useChannel
(
'
main
'
);
mainChannel
.
on
(
'
notification
'
,
notification
=>
{
...
...
@@ -106,8 +111,6 @@ mainChannel.on('notification', notification => {
`Channel`
クラスの
`send`
メソッドを使用してメッセージをサーバーに送信することができます。
```
ts
import
*
as
Misskey
from
'
misskey-js
'
;
const
stream
=
new
Misskey
.
Stream
(
'
https://misskey.test
'
,
{
token
:
'
TOKEN
'
});
const
messagingChannel
=
stream
.
useChannel
(
'
messaging
'
,
{
otherparty
:
'
xxxxxxxxxx
'
,
...
...
@@ -122,8 +125,6 @@ messagingChannel.send('read', {
`Stream`
クラスの
`_connected_`
イベントが利用可能です。
```
ts
import
*
as
Misskey
from
'
misskey-js
'
;
const
stream
=
new
Misskey
.
Stream
(
'
https://misskey.test
'
,
{
token
:
'
TOKEN
'
});
stream
.
on
(
'
_connected_
'
,
()
=>
{
console
.
log
(
'
connected
'
);
...
...
@@ -134,8 +135,6 @@ stream.on('_connected_', () => {
`Stream`
クラスの
`_disconnected_`
イベントが利用可能です。
```
ts
import
*
as
Misskey
from
'
misskey-js
'
;
const
stream
=
new
Misskey
.
Stream
(
'
https://misskey.test
'
,
{
token
:
'
TOKEN
'
});
stream
.
on
(
'
_disconnected_
'
,
()
=>
{
console
.
log
(
'
disconnected
'
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment