Skip to content
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

nodeをアップデートしてあげたよ! #3713 #3715

Closed
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
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@
"textlint-rule-terminology": "4.0.1"
},
"engines": {
"npm": "^10.2.3 || ^8.19.2"
"npm": "^10.2.4 || ^8.19.2"
}
}
50 changes: 2 additions & 48 deletions plugins/hato.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@
from library.hukidasi import generator
from library.jma_amedas import get_jma_amedas
from library.jma_amesh import jma_amesh
from library.omikuji import OmikujiResult, OmikujiResults
from library.omikuji import draw as omikuji_draw
from library.textlint import get_textlint_result
from library.vocabularydb import (
add_vocabulary,
Expand All @@ -36,6 +34,7 @@
show_random_vocabulary,
show_vocabulary,
)
from plugins.hato_mikuji import HatoMikuji

logger = getLogger(__name__)

Expand Down Expand Up @@ -429,58 +428,13 @@ def yoshiyoshi():
return "よしよし"


# 以下おみくじの設定
# Refer: dev-hato/hato-bot#876
class OmikujiEnum(Enum):
"""
おみくじの結果一覧
"""

DAI_KICHI = auto()
CHU_KICHI = auto()
SHO_KICHI = auto()
KICHI = auto()
SUE_KICHI = auto()
AGE_KICHI = auto()
KYO = auto()
DAI_KYO = auto()


omikuji_results = OmikujiResults(
{
OmikujiEnum.DAI_KICHI: OmikujiResult(
12, ":tada: 大吉 何でもうまくいく!!気がする!!"
),
OmikujiEnum.KICHI: OmikujiResult(100, ":smirk: 吉 まあうまくいくかも!?"),
OmikujiEnum.CHU_KICHI: OmikujiResult(
100, ":smile: 中吉 そこそこうまくいくかも!?"
),
OmikujiEnum.SHO_KICHI: OmikujiResult(
100, ":smiley: 小吉 なんとなくうまくいくかも!?"
),
OmikujiEnum.SUE_KICHI: OmikujiResult(
37, ":expressionless: 末吉 まあ多分うまくいくかもね……!?"
),
OmikujiEnum.AGE_KICHI: OmikujiResult(
2, ":poultry_leg: 揚げ吉 鳩を揚げると良いことあるよ!!"
),
OmikujiEnum.KYO: OmikujiResult(
12, ":cry: 凶 ちょっと慎重にいったほうがいいかも……"
),
OmikujiEnum.DAI_KYO: OmikujiResult(
2, ":crying_cat_face: 大凶 そういう時もあります……猫になって耐えましょう"
),
}
)


@action("おみくじ")
def omikuji():
"""
おみくじ結果を返す
"""

return omikuji_draw(omikuji_results)[1].message
return HatoMikuji.draw()


@action("chat")
Expand Down
57 changes: 57 additions & 0 deletions plugins/hato_mikuji.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
"""
hato-bot用のおみくじラッパー
"""

from enum import Enum, auto

from library.omikuji import OmikujiResult, OmikujiResults, draw

# 以下おみくじの設定


class OmikujiEnum(Enum):
"""
おみくじの結果一覧
"""

DAI_KICHI = auto()
CHU_KICHI = auto()
SHO_KICHI = auto()
KICHI = auto()
SUE_KICHI = auto()
AGE_KICHI = auto()
KYO = auto()
DAI_KYO = auto()


class HatoMikuji:
OMIKUJI_CONFIG = OmikujiResults(
{
OmikujiEnum.DAI_KICHI: OmikujiResult(
12, ":tada: 大吉 何でもうまくいく!!気がする!!"
),
OmikujiEnum.KICHI: OmikujiResult(100, ":smirk: 吉 まあうまくいくかも!?"),
OmikujiEnum.CHU_KICHI: OmikujiResult(
100, ":smile: 中吉 そこそこうまくいくかも!?"
),
OmikujiEnum.SHO_KICHI: OmikujiResult(
100, ":smiley: 小吉 なんとなくうまくいくかも!?"
),
OmikujiEnum.SUE_KICHI: OmikujiResult(
37, ":expressionless: 末吉 まあ多分うまくいくかもね……!?"
),
OmikujiEnum.AGE_KICHI: OmikujiResult(
2, ":poultry_leg: 揚げ吉 鳩を揚げると良いことあるよ!!"
),
OmikujiEnum.KYO: OmikujiResult(
12, ":cry: 凶 ちょっと慎重にいったほうがいいかも……"
),
OmikujiEnum.DAI_KYO: OmikujiResult(
2, ":crying_cat_face: 大凶 そういう時もあります……猫になって耐えましょう"
),
}
)

@classmethod
def draw(cls):
return draw(cls.OMIKUJI_CONFIG)[1].message
4 changes: 2 additions & 2 deletions tests/plugins/test_hato.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
amesh,
earth_quake,
omikuji,
omikuji_results,
split_command,
yoshiyoshi,
)
from plugins.hato_mikuji import HatoMikuji
from tests.library.test_geo import set_yahoo_mock
from tests.plugins import TestClient

Expand Down Expand Up @@ -399,7 +399,7 @@ def test_omikuji(self):
omikuji(client1)
self.assertIn(
client1.get_post_message(),
map(lambda e: e.message, omikuji_results.values()),
map(lambda e: e.message, HatoMikuji.OMIKUJI_CONFIG.values()),
)


Expand Down