GithubHelp home page GithubHelp logo

bluesky-story's Introduction

Bluesky 自動投稿bot

これは何ですか

昔Twitterで動かしていた物語投稿botを、Blueskyに移行しました。Pythonで実装されています。

サーバのスケジューラ等で登録し、一定間隔で実行します。

依存パッケージ

atprotoを使っています。バージョンは0.0.41です。

pip install atproto

ファイルについて

main.py

エントリ・ポイントです。

bluesky.py

bluesky投稿用のモジュールです。

/storyフォルダ

物語のファイルが格納されています。直下にstory1.jsonからstory6.jsonが入っています。

/story/story{n}.json

投稿する物語のファイルです。以下の形である必要があります。

[
  {
		"id": number,   // index
		"msg": string,  // 投稿する文字列
		"img": string   // 投稿する画像ファイルのパス
  },
]

/cred.json

認証用ファイルです。プロジェクト直下に配置が必要です。以下の形である必要があります。

{
	"identifier":         string, // アカウント名
	"pwd":                string, // パスワード
	"app-password-name"?: string, // [任意]パスワードの遂になるname
}

パスワードはBlueskyアカウントの「設定」→「アプリパスワード」で生成できます。生成するとパスワードに名前をつけることができます。app-password-nameにはその名前を設定していますが、現状未使用のためなくても問題ありません。

リンク:https://bsky.app/settings/app-passwords

/current.json

現在の物語の位置を格納しています。以下の形である必要があります。

{
	"file_id": number  // 物語ファイルの番号
	"story_id": number // 物語の位置。storyN.jsonのid
}

cron備忘

内容表示

crontab -l

編集

crontab -e

登録内容

0 2,6,10,14,18,22 * * * /usr/bin/python3 /home/crypto/bluesky-story/main.py > /home/crypto/bluesky-story.log 2>&1

cronからの起動は、ログインスクリプト等も流れていないので、各種コマンドのパスも通っていない状態。フルパスで記載します。

Pythonスクリプト内のパス指定も、"./cred.json"のような相対パスや、Path()のようにcwdを取得しても、想定通りに動きます。cwdはLinuxのルートのフォルダになります。

Path(__file__)のように実行するファイルを起点にパスを取得すれば大丈夫です。

bluesky-story's People

Contributors

zenryokukun avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.