hato-bot

愛嬌のあるbotです。

https://github.com/dev-hato/hato-bot

Science Score: 44.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (5.4%) to scientific vocabulary

Keywords

hato slack-bot
Last synced: 10 months ago · JSON representation ·

Repository

愛嬌のあるbotです。

Basic Info
  • Host: GitHub
  • Owner: dev-hato
  • License: mit
  • Language: Python
  • Default Branch: develop
  • Homepage:
  • Size: 17.9 MB
Statistics
  • Stars: 14
  • Watchers: 6
  • Forks: 3
  • Open Issues: 35
  • Releases: 25
Topics
hato slack-bot
Created over 6 years ago · Last pushed 10 months ago
Metadata Files
Readme Changelog License Citation

README.md

鳩bot - 愛嬌のあるBot

badge

鳩botでは主に次のことができます。

  • 雨雲情報 ... amesh [text] で指定した地名・住所[text]の雨雲情報を画像で表示します。
  • 最新の地震情報 ... eq で最新の地震情報を3件表示します。
  • パワーワードの登録、表示 ... text で登録したパワーワードを表示します。
  • 突然の死吹き出しで整形 ... >< [text] で文字列[text]を「突然の死」吹き出しで整形します。

hato

鳩botを動かす

鳩botは自分のPC上で動かすことができます。

必要なもの

鳩botを使うには以下が必要です。

fly.io上で動かす

  1. 事前にSlack API TokenとYahoo API Tokenを取得します。
  2. Launch a demo app · Fly Docsに記載されている手順で fly コマンドをインストールします。
  3. Launch a demo app · Fly Docsに記載されている手順でfly.ioへの登録・ログインを行います。
  4. Dashboard · Fly内の Billing からクレジットカードを登録します (無料枠で使用する場合も必須)。
  5. yq コマンドのGitHubに記載されている手順で yq コマンドをインストールします。
  6. このリポジトリをcloneします。

安定版を使う場合は -b master を指定します。最新の開発版を使う場合は指定不要です。

sh git clone -b master https://github.com/dev-hato/hato-bot.git cd hato-bot

  1. .env ファイルを作成しSlack API Token、PostgreSQLの認証情報、Yahoo API Tokenなどを記述します。

.env.example をコピーして使うとよいでしょう。

MODEに discord を指定すると、DiscordのBotとして動作します。

MODEに misskey を指定すると、自分のいるサーバーからのメンションに限って反応するMisskeyのBotとして動作します。

  1. fly.toml ファイルを作成します。

fly.template.toml をコピーし、TODOコメントに従って編集すると良いでしょう。

  1. 次のコマンドを実行してfly.ioへのデプロイを行います。 sh ./flyio_deploy.sh

自分のPC上で動かす

自分のPCで動かすこともできます。

  1. 事前にSlack API TokenとYahoo API Tokenを取得します。
  2. hadolintをインストールします。

  3. このリポジトリをcloneします。

安定版を使う場合は -b master を指定します。最新の開発版を使う場合は指定不要です。

sh git clone -b master https://github.com/dev-hato/hato-bot.git cd hato-bot

または Release から最新の安定版をダウンロードして解凍します。

  1. 必要に応じてパッケージをインストールします。

sh uv python install uv sync npm install

  1. .env ファイルを作成しSlack API Token、PostgreSQLの認証情報、Yahoo API Tokenなどを記述します。

.env.example をコピーして使うとよいでしょう

MODEに discord を指定すると、DiscordのBotとして動作します。

MODEに misskey を指定すると、自分のいるサーバーからのメンションに限って反応するMisskeyのBotとして動作します。

  1. Docker composeで鳩botとPostgreSQLを起動します。

sh export TAG_NAME=$(git symbolic-ref --short HEAD | sed -e "s:/:-:g") docker compose up -d --wait

開発時は代わりに次のコマンドを実行します。

sh export TAG_NAME=$(git symbolic-ref --short HEAD | sed -e "s:/:-:g") docker compose -f docker-compose.yml -f dev.base.docker-compose.yml -f dev.docker-compose.yml build docker compose -f docker-compose.yml -f dev.base.docker-compose.yml -f dev.docker-compose.yml watch

  1. コードの変更はDocker composeの再起動で適用できます。

sh export TAG_NAME=$(git symbolic-ref --short HEAD | sed -e "s:/:-:g") docker compose restart

開発時は自動的にDockerイメージの再ビルドが行われ反映されます。

lintをかける方法

sh npm run lint

コマンドの実行方法

  • 鳩botに対しコマンドを実行したいときは post_command.py を使うと便利です。

sh uv run post_command.py --channel {投稿先のチャンネルのchannel id} \ --user {自分のuser_id} \ "{hato-botのコマンド}"

  • またはngrokを使うこともできます。

sh ./ngrok http 3000

コミットする前に行うこと

開発に必要なパッケージと pre-commit のインストールを行います。

sh uv python install uv sync --dev uv tool run pre-commit install

補足

  • コードを整形する場合は uv tool run autopep8 --in-place --recursive . を実行します。

鳩botコマンド一覧

  • 鳩botで使用可能なコマンドは次の通りです。

text amesh ... 東京のamesh(雨雲情報)を表示する。 amesh [text] ... 指定した地名・住所・郵便番号[text]のamesh(雨雲情報)を表示する。 amesh [緯度 (float)] [経度 (float)] ... 指定した座標([緯度 (float)], [経度 (float)])のamesh(雨雲情報)を表示する。 amedas ... 東京のamedas(気象情報)を表示する。 amedas [text] ... 指定した地名・住所・郵便番号[text]のamedas(気象情報)を表示する。 amedas [緯度 (float)] [経度 (float)] ... 指定した座標([緯度 (float)], [経度 (float)])のamedas(気象情報)を表示する。 電力 ... 東京電力管内の電力使用率を表示する。 標高 ... 東京の標高を表示する。 標高 [text] ... 指定した地名・住所・郵便番号[text]の標高を表示する。 標高 [緯度 (float)] [経度 (float)] ... 指定した座標([緯度 (float)], [経度 (float)])の標高を表示する。 eq ... 最新の地震情報を3件表示する。 textlint [text] ... 文字列[text]を校正する。 text list ... パワーワード一覧を表示する。 text random ... パワーワードをひとつ、ランダムで表示する。 text show [int] ... 指定した番号[int]のパワーワードを表示する。 text add [text] ... パワーワードに[text]を登録する。 text delete [int] ... 指定した番号[int]のパワーワードを削除する。 >< [text] ... 文字列[text]を吹き出しで表示する。 にゃーん ... 「よしよし」と返す。 おみくじ ... おみくじを引いて返す。 version ... バージョン情報を表示する。 chat [text] ... ChatGPTで文章生成する。 画像生成 [text] ... openAIのImage generationで画像生成する。[text]は英語での入力推奨。 ping ... 「ping」したら「PONG」と返す。

バージョンアップによる変更点

  • バージョンアップによる変更点についてはCHANGELOG を参照してください。

バグ報告や機能の要望について

  • バグ報告や機能追加の要望がある場合は IssuesNew Issue から報告をお願いします。

  • プルリクエストも大歓迎です。

クレジット

Botで利用しているサービスのクレジットを記載します。

Owner

  • Name: dev-hato
  • Login: dev-hato
  • Kind: organization

Citation (CITATION.cff)

authors:
  - given-names: "dev-hato"
cff-version: "1.1.0"
date-released: 2021-06-17
license: MIT
message: "愛嬌のあるSlack用bot"
repository-code: "https://github.com/dev-hato/hato-bot"
title: "hato-bot"
version: "2.1.1"

Issues and Pull Requests

Last synced: 10 months ago

All Time
  • Total issues: 30
  • Total pull requests: 1,931
  • Average time to close issues: 10 months
  • Average time to close pull requests: 1 day
  • Total issue authors: 6
  • Total pull request authors: 9
  • Average comments per issue: 0.8
  • Average comments per pull request: 0.11
  • Merged pull requests: 1,224
  • Bot issues: 13
  • Bot pull requests: 1,761
Past Year
  • Issues: 11
  • Pull requests: 1,256
  • Average time to close issues: about 10 hours
  • Average time to close pull requests: about 20 hours
  • Issue authors: 4
  • Pull request authors: 8
  • Average comments per issue: 0.09
  • Average comments per pull request: 0.11
  • Merged pull requests: 723
  • Bot issues: 10
  • Bot pull requests: 1,178
Top Authors
Issue Authors
  • nakkaa (15)
  • renovate[bot] (8)
  • github-actions[bot] (3)
  • dependabot[bot] (2)
  • massongit (1)
  • fono09 (1)
Pull Request Authors
  • renovate[bot] (898)
  • dev-hato-app[bot] (361)
  • github-actions[bot] (316)
  • dependabot[bot] (186)
  • massongit (153)
  • nakkaa (7)
  • Goryudyuma (6)
  • fono09 (3)
  • Konyx (1)
Top Labels
Issue Labels
dependencies (2) python (2) bug (1) documentation (1)
Pull Request Labels
dependencies (186) review please (66) github_actions (63) python (63) docker (51) javascript (9)