Skip to content

Commit 636d316

Browse files
authored
Merge branch 'develop' into add_image_generate
2 parents dc3df7a + 76419f9 commit 636d316

18 files changed

Lines changed: 403 additions & 249 deletions

File tree

.env.example

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
DATABASE_URL=postgres://postgres:password@postgres:5432/
22
DISCORD_API_TOKEN=
3+
MISSKEY_API_TOKEN=
4+
MISSKEY_DOMAIN=
35
MODE=
46
OPENAI_API_KEY=
57
SLACK_API_TOKEN=

.github/workflows/deploy-hato-bot.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ jobs:
100100
- name: Start docker
101101
env:
102102
DOCKER_CONTENT_TRUST: 1
103-
run: bash "${GITHUB_WORKSPACE}/scripts/deploy_hato_bot/deploy_docker_image/test.sh"
103+
run: docker compose up -d --wait
104104

105105
# .python-version をDockerイメージと同期させる
106106
update-version-python-version:

.github/workflows/pr-test-hato-bot.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
with:
2626
python-version: ${{ env.PYTHON_VERSION }}
2727
cache: pipenv
28-
- name: Install pipenv
28+
- name: Test
2929
run: bash "${GITHUB_WORKSPACE}/scripts/pr_test_hato_bot/pr_test/test.sh"
3030

3131
concurrency:

.python-lint

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,4 +467,4 @@ valid-metaclass-classmethod-first-arg=mcs
467467

468468
# Exceptions that will emit a warning when being caught. Defaults to
469469
# "Exception"
470-
overgeneral-exceptions=Exception
470+
overgeneral-exceptions=builtins.Exception

Dockerfile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ RUN apt-get update && \
3838
apt-get remove -y git gcc libc6-dev && \
3939
apt-get autoremove -y && \
4040
apt-get clean && \
41-
rm -rf /var/lib/apt/lists ~/.cache /tmp && \
41+
rm -rf /var/lib/apt/lists ~/.cache /tmp /root/.npm /usr/src/app/node_modules/re2/.github/actions/*/Dockerfile && \
4242
find / -type f -perm /u+s -ignore_readdir_race -exec chmod u-s {} \; && \
4343
find / -type f -perm /g+s -ignore_readdir_race -exec chmod g-s {} \; && \
4444
useradd -l -m -s /bin/bash -N -u "1000" "nonroot" && \
@@ -54,5 +54,4 @@ COPY --from=commit-hash slackbot_settings.py slackbot_settings.py
5454

5555
ENV GIT_PYTHON_REFRESH=quiet
5656
ENV NODE_OPTIONS="--max-old-space-size=512"
57-
HEALTHCHECK --interval=5s --retries=20 CMD ["curl", "-s", "-S", "-o", "/dev/null", "http://localhost:3000/status"]
5857
CMD ["python", "entrypoint.py"]

Pipfile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ python_version = "3.11"
99
[dev-packages]
1010
autopep8 = "==2.0.2"
1111
requests-mock = "==1.10.0"
12-
pylint = "==2.16.3"
12+
pylint = "==2.16.4"
1313
sqlfluff = "==1.4.5"
14-
mypy = "==1.0.1"
14+
mypy = "==1.1.1"
1515
flake8 = "==6.0.0"
1616
black = "*"
1717
isort = "*"
@@ -33,3 +33,5 @@ pandas = "==1.5.3"
3333
matplotlib = "==3.7.1"
3434
openai = "==0.27.0"
3535
discord = "==2.2.2"
36+
"misskey.py" = "==4.1.0"
37+
websockets = "==10.4"

Pipfile.lock

Lines changed: 280 additions & 224 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,12 @@
5858

5959
DISCORD_API_TOKENには `Read Messages/View Channels` と、 `Send Messages` の権限が必要です。
6060

61+
MODEに `misskey` を指定すると、自分のサーバーからのメンションに限って反応するMisskeyのBotとして動作します。
62+
63+
MISSKEY_URLにBotのいるMisskeyサーバーのドメインを指定します。
64+
65+
MISSKEY_API_TOKENにMisskeyのBotのアクセストークンを指定します。
66+
6167
6. docker composeで鳩botとPostgreSQLを起動します。
6268

6369
```sh

README.template.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,12 @@
5858

5959
DISCORD_API_TOKENには `Read Messages/View Channels` と、 `Send Messages` の権限が必要です。
6060

61+
MODEに `misskey` を指定すると、自分のサーバーからのメンションに限って反応するMisskeyのBotとして動作します。
62+
63+
MISSKEY_URLにBotのいるMisskeyサーバーのドメインを指定します。
64+
65+
MISSKEY_API_TOKENにMisskeyのBotのアクセストークンを指定します。
66+
6167
6. docker composeで鳩botとPostgreSQLを起動します。
6268

6369
```sh

library/clientclass.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,3 +142,40 @@ def get_send_user_name(self):
142142
def get_type():
143143
"""discord"""
144144
return "discord"
145+
146+
147+
class MisskeyClient(BaseClient):
148+
"""
149+
Misskeyを操作するClient
150+
"""
151+
152+
def __init__(self, misskey_client, message):
153+
self.client = misskey_client
154+
self.message = message
155+
156+
def post(self, text):
157+
"""Discordにポストする"""
158+
self._post(text=text)
159+
160+
def upload(self, file, filename=None):
161+
"""ファイルを投稿する"""
162+
with open(file, "rb") as f:
163+
drive_file = self.client.drive_files_create(file=f)
164+
self._post(file_ids=[drive_file["id"]])
165+
166+
def _post(self, text=None, file_ids=None):
167+
self.client.notes_create(
168+
text=text, reply_id=self.message["id"], file_ids=file_ids
169+
)
170+
171+
def get_send_user(self):
172+
"""botを呼び出したユーザーを返す"""
173+
return self.message["user"]["username"]
174+
175+
def get_send_user_name(self):
176+
return self.message["user"]["name"]
177+
178+
@staticmethod
179+
def get_type():
180+
"""misskey"""
181+
return "misskey"

0 commit comments

Comments
 (0)