mattn / bsky

A cli application for bluesky social
270 stars 25 forks source link

Unable to specify language with post command #15

Open ekfacile opened 7 months ago

ekfacile commented 7 months ago

Blueskyの公式Webアプリでは投稿時に使用言語を1つ以上指定出来ます。 しかしbskyの post コマンドには言語を指定する引数がありません。 使用言語を指定する引数を追加出来ませんか。

When posting from the official web app, you can specify one or more languages to use for posting. However, bsky's post command does not have an argument to specify the language. Is it possible to add an argument to specify the language to use?

mattn commented 7 months ago

Thank your suggestion. I can add new flag -lang to bsky post command, but how can I check the results?

ekfacile commented 7 months ago

Blueskyでの指定アカウントの投稿を全部テキストファイルに出力するやつ https://gist.github.com/gpsnmeajp/c549330dfdbc0a11643b0f0a52f5aa53

All post data (JSON) output by this script includes language information.

mattn commented 7 months ago

日本語で失礼します。 Bluesky で日本語と中国語のフラグを設定したポストをしたのですが、これが中国語のフラグを設定している事を確認するには、Bluesky の何かの設定をすればよいのでしょうか?

https://bsky.app/profile/did:plc:ituhatvv5pyz4rwsj4hfrslh/post/3kgax7bggy22b

ekfacile commented 7 months ago

私の方でも実際に投稿してBluesky側の設定やカスタムフィードを作って検出を試みましたが出来ませんでした。 確認する術がない以上、現時点では複数言語指定は諦めるしかなさそうです。 中途半端な実装を好まないのであれば、このIssueはCloseして下さい。

mattn commented 7 months ago

Bluesky の中の人に聞いてみますね。

mattn commented 7 months ago

翻訳のリンクを作る際に「言語Aから言語B」にという部分のAに使われるらしいですが、なぜ複数指定可能なのか分かってないです。

ekfacile commented 7 months ago

投稿に使用された言語を知る方法が見つかりました。 外部サービスのTOKIMEKIで以下の設定を有効にして下さい。言語情報が表示されます。 設定(歯車アイコン)全般開発者向け情報を表示する をON

また2つ前の投稿に書いた全投稿を書き出すスクリプトも、 com.atproto.sync.getRepo を呼び出す際に使うURLをそのアカウントが割り当てられたPDSのURLに置き換えれば正常に動作して言語情報を取得出来ます。PDS URLはTOKIMEKIのプロフィール画面で確認出来ます(要上記設定)。

(例) shimejiサーバーの場合
https://bsky.social/xprc/com.atproto.sync.getRepo?did= ~
↓
https://shimeji.us-east.host.bsky.network/xrpc/com.atproto.sync.getRepo?did= ~

なぜ複数指定可能なのか分かってないです。

語学学習で2つ以上の言語で投稿したい時位しか思いつきません。 あるいはコミュニケーションの都合上、母語だけでは正確な意思疎通が出来ない場合にも使われるかも知れません。

ekfacile commented 7 months ago

言語情報ですが、(手順を踏んで) app.bsky.feed.getAuthorFeed を叩けば返ってくるJSONにきちんと言語情報が含まれています。

// C#で書いた雑なプログラム
using System;
using System.IO;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Net.Http.Json;
using System.Text.Json;
using System.Threading.Tasks;

internal class AuthParam
{
    public string Identifier { get; set; }
    public string Password { get; set; }
}

internal class AuthResponse
{
    public string AccessJwt { get; set; }
}

class CLASS1
{
    private static readonly JsonSerializerOptions option = new()
    {
        PropertyNamingPolicy = JsonNamingPolicy.CamelCase
    };
    static async Task Main()
    {
        var auth = new AuthParam
        {
            Identifier = "handle.bsky.social",
            Password = "xxxx-xxxx-xxxx-xxxx"
        };
        var client = new HttpClient();
        var data = JsonSerializer.Serialize(auth, option);
        var content = new StringContent(data, System.Text.Encoding.UTF8, "application/json");
        var response = await client.PostAsync("https://bsky.social/xrpc/com.atproto.server.createSession", content);
        var authdata = await response.Content.ReadFromJsonAsync<AuthResponse>(option);
        client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", authdata.AccessJwt);
        var getprofile = await client.GetAsync("https://bsky.social/xrpc/app.bsky.actor.getProfile?actor=handle.bsky.social");
        var profile = await getprofile.Content.ReadAsStringAsync();
        Console.WriteLine(profile);
        var getfeed = await client.GetAsync("https://bsky.social/xrpc/app.bsky.feed.getAuthorFeed?actor=handle.bsky.social");
        var feed = await getfeed.Content.ReadAsStringAsync();
        Console.WriteLine(feed);
    }
}