Skip to content

Add: グローバルチャットを実装 #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: "Lint"
on: [push]
jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: "Checkout repository"
uses: actions/checkout@v3
- name: "Setup Python"
uses: actions/setup-python@v3
with:
python-version: "3.9"
- name: "Install poetry"
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
- name: "Load cached venv"
id: load-cached-venv
uses: actions/cache@v3
with:
path: .venv
key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}
- name: Install dependencies
run: poetry install
if: steps.load-cached-venv.outputs.cache-hit != 'true'
- name: "Lint"
run: poetry run poe lint
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ COPY . .

# -- Run the app
ENV environment=production
CMD ["python", "main.py"]
CMD ["python", "main.py"]
17 changes: 17 additions & 0 deletions create_index.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import pymongo
from dotenv import load_dotenv
from os import getenv

load_dotenv()

db_client = pymongo.MongoClient(getenv("MONGO_URI"))
db = db_client[getenv("environment", "development")]
db.gc_room.create_index(
"channels",
unique=True,
)
db.gc_room.create_index(
"name",
unique=True,
)
print("Done.")
Binary file added emojis/check.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added emojis/clock.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion locale/en.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
chat_input:
ping:
_:
name: "ping"
description: "Pong! Returns the latency of SevenBot."
args:
embed:
Expand Down
91 changes: 89 additions & 2 deletions locale/ja.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,96 @@ $schema: "./_scheme.yml"
chat_input:
ping:
_:
name: "ping"
description: "Pong! SevenBotの通信速度を返します。"
args:
embed:
title: ":ping_pong: Pong!"
description: "通信速度は`{latency}ms`です。"
description: "通信速度は`{latency}ms`です。"
global:
_:
description: "グローバルチャット。"
activate:
_:
description: "グローバルチャットを有効にします。"
create_confirm:
title: ":x: 不明なグローバルチャット"
description: |
チャット`{name}`が見付かりませんでした。
作成しますか?
create_success:
title: ":white_check_mark: 完了"
description: |
グローバルチャット{name}(`{id}`)を作成しました。
`/global activate {id}`で有効にします。
join_confirm:
title: ":question: 参加確認"
description: |
グローバルチャット`{name}`(`{id}`)に参加しますか?
>>> {description}
join_password:
title: "パスワードの確認"
fields:
password:
name: "パスワード"
placeholder: "パスワードを入力してください。"
password_failed:
title: ":x: パスワードが違います"
description: "パスワードが違います。"
join_success:
title: ":white_check_mark: 完了"
description: |
グローバルチャット`{name}`(`{id}`)に参加しました。
join_announce:
title: ":inbox_tray: 参加"
description: |
{name}がグローバルチャットに参加しました。
現在{count}チャンネルが参加しています。
already_in:
title: ":x: 参加済み"
description: |
このチャンネルは既にグローバルチャット{name}(`{id}`)に参加しています。
`/global deactivate`で退出できます。
create:
title: "グローバルチャットの作成"
fields:
id:
name: "チャットID"
placeholder: "接続に使用するチャットID。"
name:
name: "チャット名"
placeholder: "チャット名。デフォルトではチャットIDが使用されます。"
description:
name: "説明"
placeholder: "チャットの説明。接続時に表示されます。"
password:
name: "パスワード"
placeholder: "チャットのパスワード。省略すると誰でも入れるようになります。"
deactivate:
deactivate_confirm:
title: ":warning: 退出しますか?"
description: |
グローバルチャット{name}(`{id}`)から退出しますか?
deactivated:
title: ":white_check_mark: 完了"
description: |
グローバルチャット{name}(`{id}`)から退出しました。
deactivated_deleted:
title: ":white_check_mark: 完了"
description: |
グローバルチャット{name}(`{id}`)から退出しました。
参加しているチャンネルが無くなったため、グローバルチャットは削除されました。
not_in:
title: ":x: 未参加"
description: |
このチャンネルはグローバルチャットに参加していません。
`/global activate <ID>`で参加できます。
leave_announce:
title: ":outbox_tray: 退出"
description: |
{name}がグローバルチャットから退出しました。
現在{count}チャンネルが参加しています。
common:
confirm: "はい"
cancel: "いいえ"
timeouted: "タイムアウトしました。もう一度最初からやり直してください。"
canceled: "キャンセルしました。"
15 changes: 5 additions & 10 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,16 @@


def setup_logging():
discord_logger = logging.getLogger("discord")
sevenbot_logger = logging.getLogger("SevenBot")
discord_logger.setLevel(logging.DEBUG)
sevenbot_logger.setLevel(logging.DEBUG)
file_handler = logging.FileHandler(filename="sevenbot.log", encoding="utf-8", mode="w")
file_handler.setLevel(logging.INFO)
file_handler.setLevel(logging.DEBUG)
file_handler.setFormatter(logging.Formatter("%(asctime)s:%(levelname)s:%(name)s: %(message)s"))
discord_logger.addHandler(file_handler)
sevenbot_logger.addHandler(file_handler)

console_handler = logging.StreamHandler()
console_handler.setLevel(logging.INFO)
console_handler.setFormatter(ColoredFormatter(True))
discord_logger.addHandler(console_handler)
sevenbot_logger.addHandler(console_handler)

logging.root.setLevel(logging.DEBUG)
logging.root.addHandler(file_handler)
logging.root.addHandler(console_handler)


def main():
Expand Down
Loading