Skip to content

Commit

Permalink
Merge pull request #12 from MinatoAquaCrews/dev
Browse files Browse the repository at this point in the history
v0.2.6a1
  • Loading branch information
KafCoppelia authored Oct 8, 2022
2 parents 841e13f + 57e90f3 commit ba33fd3
Show file tree
Hide file tree
Showing 6 changed files with 478 additions and 463 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<!-- prettier-ignore-start -->
<!-- markdownlint-disable-next-line MD036 -->
_🍗 天天疯狂 🍗_
_🍗 疯狂星期四 🍗_
<!-- prettier-ignore-end -->

</div>
Expand All @@ -16,10 +16,10 @@ _🍗 天天疯狂 🍗_
</a>

<a href="https://github.com/nonebot/nonebot2">
<img src="https://img.shields.io/badge/nonebot2-2.0.0beta.2+-green">
<img src="https://img.shields.io/badge/nonebot2-2.0.0rc1+-green">
</a>

<a href="https://github.com/MinatoAquaCrews/nonebot_plugin_crazy_thursday/releases/tag/v0.2.5">
<a href="https://github.com/MinatoAquaCrews/nonebot_plugin_crazy_thursday/releases/tag/v0.2.6a1">
<img src="https://img.shields.io/github/v/release/MinatoAquaCrews/nonebot_plugin_crazy_thursday?color=orange">
</a>

Expand All @@ -31,11 +31,11 @@ _🍗 天天疯狂 🍗_

## 版本

v0.2.5
v0.2.6a1

⚠ 适配nonebot2-2.0.0beta.2+
⚠ 适配nonebot2-2.0.0rc1+

[更新日志](https://github.com/MinatoAquaCrews/nonebot_plugin_crazy_thursday/releases/tag/v0.2.5)
[更新日志](https://github.com/MinatoAquaCrews/nonebot_plugin_crazy_thursday/releases/tag/v0.2.6a1)

## 安装

Expand Down
36 changes: 16 additions & 20 deletions nonebot_plugin_crazy_thursday/__init__.py
Original file line number Diff line number Diff line change
@@ -1,50 +1,46 @@
import random
from typing import List
from pathlib import Path
from nonebot import on_regex
from nonebot.typing import T_State
from nonebot.matcher import Matcher
from nonebot.params import Depends, State, RegexMatched
from nonebot.params import Depends, RegexMatched
from .config import crazy_config
try:
import ujson as json
except ModuleNotFoundError:
import json

__crazy_thursday_version__ = "v0.2.5"
__crazy_thursday_version__ = "v0.2.6a1"
__crazy_thursday_notes__ = f"""
KFC疯狂星期四 {__crazy_thursday_version__}
[疯狂星期X] 随机输出KFC疯狂星期四文案
[狂乱X曜日] 随机输出KFC疯狂星期四文案""".strip()

crazy = on_regex(pattern=r"^疯狂星期\S$", priority=15)
crazy_cn = on_regex(pattern=r"^疯狂星期\S$", priority=15)
crazy_jp = on_regex(pattern=r"^狂乱\S曜日$", priority=15)

def get_weekday_cn(arg: str = RegexMatched(), state: T_State = State()):
weekday = arg[-1].replace("天", "日")
return {**state, "weekday": weekday}
async def get_weekday_cn(arg: str = RegexMatched()) -> str:
return arg[-1].replace("天", "日")

def get_weekday_jp(arg: str = RegexMatched(), state: T_State = State()):
weekday = arg[2]
return {**state, "weekday": weekday}
async def get_weekday_jp(arg: str = RegexMatched()) -> str:
return arg[2]

@crazy.handle()
async def _(matcher: Matcher, state: T_State = Depends(get_weekday_cn)):
weekday = state["weekday"]
@crazy_cn.handle()
async def _(matcher: Matcher, weekday: str = Depends(get_weekday_cn)):
await matcher.finish(rndKfc(weekday))

@crazy_jp.handle()
async def _(matcher: Matcher, state: T_State = Depends(get_weekday_jp)):
weekday = state["weekday"]
async def _(matcher: Matcher, weekday: str = Depends(get_weekday_jp)):
await matcher.finish(rndKfc(weekday))

def rndKfc(day: str):
def rndKfc(day: str) -> str:
# jp en cn
tb = ["月", "Monday", "一", "火", "Tuesday", "二", "水", "Wednesday", "三", "木", "Thursday", "四", "金", "Friday", "五", "土", "Saturday", "六", "日", "Sunday", "日"]
tb: List[str] = ["月", "Monday", "一", "火", "Tuesday", "二", "水", "Wednesday", "三", "木", "Thursday", "四", "金", "Friday", "五", "土", "Saturday", "六", "日", "Sunday", "日"]
if day not in tb:
return "给个准确时间,OK?"

# Get the weekday group index
idx = int(tb.index(day)/3)*3
idx: int = int(tb.index(day)/3)*3

# json数据存放路径
path: Path = crazy_config.crazy_path / "post.json"
Expand All @@ -53,5 +49,5 @@ def rndKfc(day: str):
with open(path, "r", encoding="utf-8") as f:
kfc = json.load(f).get("post")

# 随机选取数组中的一个对象,替换关键字
return random.choice(kfc).replace("木曜日", tb[idx] + "曜日").replace("Thursday", tb[idx+1]).replace("thursday", tb[idx+1]).replace("星期四", "星期" + tb[idx+2]).replace("周四", "周" + tb[idx+2]).replace("礼拜四", "礼拜" + tb[idx+2])
# 随机选取数组中的一个对象,并替换日期
return random.choice(kfc).replace("木曜日", tb[idx] + "曜日").replace("Thursday", tb[idx+1]).replace("thursday", tb[idx+1]).replace("星期四", "星期" + tb[idx+2]).replace("周四", "周" + tb[idx+2]).replace("礼拜四", "礼拜" + tb[idx+2])
14 changes: 6 additions & 8 deletions nonebot_plugin_crazy_thursday/config.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from nonebot import get_driver, logger
from nonebot import get_driver
from nonebot.log import logger
from pydantic import BaseModel, Extra
from pathlib import Path
from typing import Union
from pathlib import Path
from typing import Union, Dict, List
import httpx
try:
import ujson as json
Expand Down Expand Up @@ -41,10 +42,7 @@ async def post_check() -> None:
If failed and post dosen't exists, raise exception
Otherwise just abort downloading
'''
if not crazy_config.crazy_path.exists():
crazy_config.crazy_path.mkdir(parents=True, exist_ok=True)

json_path = crazy_config.crazy_path / "post.json"
json_path: Path = crazy_config.crazy_path / "post.json"

url = "https://raw.fastgit.org/MinatoAquaCrews/nonebot_plugin_crazy_thursday/beta/nonebot_plugin_crazy_thursday/post.json"
response = await download_url(url)
Expand All @@ -53,7 +51,7 @@ async def post_check() -> None:
logger.warning("Crazy Thursday resource missing! Please check!")
raise ResourceError
else:
docs = response.json()
docs: Dict[str, Union[float, List[str]]] = response.json()
version = docs.get("version")

with json_path.open("w", encoding="utf-8") as f:
Expand Down
3 changes: 2 additions & 1 deletion nonebot_plugin_crazy_thursday/post.json
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@
"找对象五年了,多了87个外卖地址,31个收货地址,别的什么也没留下。时常被人完弄感情,但还是憧憬爱情,想起这些事趴桌子上大哭,正当我打开窗户想跳楼的时候,不小心打开了群,觉得也许还能再相信一次爱情,今天是疯狂星期四,群里帅哥、美女v50,我给你们讲讲我的故事",
"我和男朋友出去玩的时候发生了关系。然后以前都是特别克制的,因为我觉得婚前性行为很不好并且向来很排斥,然后我觉得我很喜欢他。他还打了书面保证,保证结婚前是处女。但是上次的时候就是发生了,当时一点不害怕的原因就是我刚开始还没开始的时候就没感觉到一点疼痛,过程中也完全没有出血。我是农村的,我当时想可能我的处女膜在以前的剧烈运动什么的时候早就不存在了吧。所以也就顺着他了。因为是异地恋,我在离开他之前都没有任何害怕,但是回到学校后就越来越害怕,感觉自己不完整了,纯洁了,一种极度自卑的心理。特别怕他不要我了,他20岁,在此之前我们的关系很好,我的害怕产生后每天晚上我都打很久电话给他,一星期了我感觉他有点撑不下去。但是我觉得他不是那种会不负责任的人,但是我依然害怕。现在两人约定不再提这件事但是我心里感受到一种自卑,同时感觉对他没那么信任,但我不想把这段感情作没了。不想自卑,因为还要好好的读书,但是心态实在不好,所以你能v我50吗",
"周四请个人吃肯德基\n要求:\n1.做人有逼格\n2.对人有礼貌\n3.Computer Science/Software Engineering/Computer Engineering或相关专业研究生学历或QS前200学院本科学历及更高\n4.熟悉以下语言其中之一\nPython, C,C++,C#,Go\n5.五年以上Java Spring框架开发经历并有一定研究及成果,具有独立前后端开发能力\n6.有Database工作背景,熟悉SQL和数据库设计,具备mysql数据库设计和性能优化经验;熟悉主流非关系性数据库、缓存技术,如:Redis、MongoDB、Memcached等\n7.HTML5,CSS,JavaScript前端知识基础扎实,熟练掌握react,vue,Node.js框架\n8.持有Cisco CCNA以及上认证\n9.三年以上领导团队开发经验\n10.熟悉Unix/Linux系统操作\n11.服务器硬件维护知识\n12.有AWS/Azure操作经验\n13.具有良好的沟通能力和团队合作能力,具备良好的主动性和责任感\n面试成功后找我V50吃肯德基",
"个人副业,支持一下\n1、比赛带打,获奖300r,国二400r,国一500r\n2、Python脚本 20元/100行 \n3、verilog程序 10元/200行\n4、FPGA soc类小设计开发 100/个,复杂面议\n5、加速器可重构算子设计,简单的30/个,复杂面议\n6、音频处理算法,py设计15元,v设计100元,消除人声等处理面议\n7、dsa编译器设计,支持分类普通算子,80r,支持普遍使用的detection 算子150r,另加op面议\n8、KFC代吃 45/次,只接周四\n目前只接8 ,其他的还在学"
"个人副业,支持一下\n1、比赛带打,获奖300r,国二400r,国一500r\n2、Python脚本 20元/100行 \n3、verilog程序 10元/200行\n4、FPGA soc类小设计开发 100/个,复杂面议\n5、加速器可重构算子设计,简单的30/个,复杂面议\n6、音频处理算法,py设计15元,v设计100元,消除人声等处理面议\n7、dsa编译器设计,支持分类普通算子,80r,支持普遍使用的detection 算子150r,另加op面议\n8、KFC代吃 45/次,只接周四\n目前只接8 ,其他的还在学",
"那年,有一个男人抱着我\n在出租屋里,在大雪天\n他手上的茧子和他下面的棍子一样硬\n像榔头一样,能把人几下敲晕\n他抱着我,就像抱着整个世界\n我们要过一辈子,他说\n等到了春天,我要去大城市了\n你还会回来吗,他问\n我说,可能会,也可能不会\n我在大城市陪别人喝酒喝到十一点\n这里没有秋天,也没有春天\n只有一片片没有颜色的水泥大厦\n没有过期的菠萝罐头,也没有他\n那次接完客人我就穿着单衣回去\n浑身冷的好像是在那个冬天\n那个冬天和这个冬天就像是相片的底片\n有了重叠\n我又想起来滚烫的大榔头\n我又想起来他\n我又想起来世界被大榔头敲碎\n我想起来他说要和我一直在一起\n我还记得雪化开之后什么都没了\nb和眼睛\n就全湿了\n我只想在这个即将来临的冬天找到一个可以懂我的人V我50,让我在疯狂星期四能感受到一丝丝的温暖"
]
}
Loading

0 comments on commit ba33fd3

Please sign in to comment.