3
0

v0.1.1 支持查询每日运势 (#2)

This commit is contained in:
Xtao_dada 2021-07-14 17:51:24 +08:00 committed by GitHub
parent 5eeea30fdc
commit 6c07eae843
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
37 changed files with 1069 additions and 10 deletions

720
assets/data/fortunate.json Normal file
View File

@ -0,0 +1,720 @@
{
"fortunate": [
{
"good-luck": 10,
"content": "曾经的努力和经验会成为他人眼中魅力的样子"
},
{
"good-luck": 24,
"content": "财运顺畅,临时收入也可期待"
},
{
"good-luck": 9,
"content": "越出远门越能提高幸运值的日子"
},
{
"good-luck": 9,
"content": "善解人意的一天,道出鼓励的话语吧"
},
{
"good-luck": 9,
"content": "寄全身于好奇心,世界将更加宽阔"
},
{
"good-luck": 8,
"content": "今天听到的甜蜜言语不信为○"
},
{
"good-luck": 8,
"content": "拥有独处的时间会使内心满足"
},
{
"good-luck": 8,
"content": "能够通过新的体验深造自己的一天"
},
{
"good-luck": 7,
"content": "与人接触可丰富内心,亲切待人是幸运之钥"
},
{
"good-luck": 7,
"content": "越是凭直觉大胆行动越能加速进展的日子"
},
{
"good-luck": 7,
"content": "可能会从亲近的亲戚那里得知条件不错的事!?"
},
{
"good-luck": 6,
"content": "匀出自由的时间,便能充实地度过"
},
{
"good-luck": 20,
"content": "万事顺利的一天 麻利工作即是吉"
},
{
"good-luck": 21,
"content": "变得更加坚强,女性朋友是幸运的关鍵"
},
{
"good-luck": 9,
"content": "看东西的眼光很准的一天 SALE也◎"
},
{
"good-luck": 9,
"content": "原本的魅力闪耀的一天 珍惜喜欢的事物"
},
{
"good-luck": 9,
"content": "去获取时效性高的情报吧!"
},
{
"good-luck": 8,
"content": "对手上的锅也能感觉到有意义"
},
{
"good-luck": 8,
"content": "求知欲比平时更高!"
},
{
"good-luck": -7,
"content": "做惯了的工作会发生低级错误!?"
},
{
"good-luck": 7,
"content": "和亲近之人心灵相通 传达感激之情吧"
},
{
"good-luck": 7,
"content": "同情心加深的一天 坦率道出温柔话语吧"
},
{
"good-luck": 7,
"content": "可以期待心跳的一天 慢慢进展便可"
},
{
"good-luck": -8,
"content": "自我主张要适可而止,步调保持一致"
},
{
"good-luck": 10,
"content": "有意义的工作,将会是成长的关键"
},
{
"good-luck": 21,
"content": "被异性喜爱的一天 相信自己的魅力"
},
{
"good-luck": 23,
"content": "即使想法被驳回也不要气馁!"
},
{
"good-luck": 21,
"content": "会有重要的邂逅,或许能发展为长期交往"
},
{
"good-luck": 9,
"content": "为了提高自己技能的自我投资"
},
{
"good-luck": 8,
"content": "或许能从亲人那里听到好消息"
},
{
"good-luck": 24,
"content": "钱包里留最低限度的钱就好"
},
{
"good-luck": 25,
"content": "好像会对学习有兴趣,马上学习吧"
},
{
"good-luck": 7,
"content": "喜爱的饮料可以帮自己高度集中注意力"
},
{
"good-luck": 7,
"content": "实用物品只用同种品牌会带来好运"
},
{
"good-luck": 7,
"content": "感觉能做到的话,请务必坚持下来!"
},
{
"good-luck": -7,
"content": "不去着急的话,就能一帆风顺的一天"
},
{
"good-luck": 10,
"content": "被幽默感眷顾的一天,尽情的发言吧!"
},
{
"good-luck": 26,
"content": "身为领导者,连身边人的幸运都能提高的一天"
},
{
"good-luck": 9,
"content": "早上日程表的确认能够带来好运"
},
{
"good-luck": 9,
"content": "被人期待的一天,整理总结的任务应该也能胜任"
},
{
"good-luck": 8,
"content": "下定决心向人撒娇就能进展顺利的一天"
},
{
"good-luck": 8,
"content": "拥有判断力,感觉可以买到满意的东西"
},
{
"good-luck": 8,
"content": "热衷于眼前的事物可以使心情放松"
},
{
"good-luck": 7,
"content": "不去着急的话就能一帆风顺的一天"
},
{
"good-luck": 7,
"content": "今天的工作一个人做进展会更顺利"
},
{
"good-luck": 7,
"content": "听点轻快的音乐就能进展顺利的一天"
},
{
"good-luck": -7,
"content": "凭借新的体验,得以加深自己的一天"
},
{
"good-luck": 23,
"content": "事业运顺畅!积极地向周围的人搭话吧"
},
{
"good-luck": 6,
"content": "在时尚上花钱"
},
{
"good-luck": 9,
"content": "即使准备工作很困难,也不要放过机会"
},
{
"good-luck": 9,
"content": "临时收入用来犒劳自己吧"
},
{
"good-luck": 9,
"content": "今天就尽可能收集情报吧!"
},
{
"good-luck": 8,
"content": "能接近理想的一天,积极行动吧!"
},
{
"good-luck": 8,
"content": "是该考虑如何妥善安排的时候!"
},
{
"good-luck": 24,
"content": "培养眼见也让财运UP吧"
},
{
"good-luck": 21,
"content": "爱情方面有进展的机会,表现得坦率一些"
},
{
"good-luck": 7,
"content": "可能会抽到不错的签!?"
},
{
"good-luck": 7,
"content": "重在保持自我的日子,兴趣优先"
},
{
"good-luck": -7,
"content": "有在意的东西的话,便去获取它"
},
{
"good-luck": 10,
"content": "新的开始,会熠熠生辉的幸运日☆"
},
{
"good-luck": 9,
"content": "运气和实力会成为对你的期待"
},
{
"good-luck": 9,
"content": "定好今后的目标,每天都要为之努力"
},
{
"good-luck": 27,
"content": "人运旺盛!扩展人脉吧"
},
{
"good-luck": 9,
"content": "知觉敏锐的一天,随好奇心而动"
},
{
"good-luck": 8,
"content": "能走近他人内心的一天,温柔将会闪耀"
},
{
"good-luck": 8,
"content": "目前请仅专注于提升实力"
},
{
"good-luck": 8,
"content": "对教养的关注也可能会提高"
},
{
"good-luck": 7,
"content": "高难度的工作也能高效推进"
},
{
"good-luck": 7,
"content": "膳食选择质量优于数量,心情也会随之变好!"
},
{
"good-luck": 6,
"content": "买东西要慎重,不要吝啬交际费用"
},
{
"good-luck": -7,
"content": "心情变化剧烈的一天 凭借深呼吸冷静下来"
},
{
"good-luck": 10,
"content": "在提升技能与教养上花钱的话◎"
},
{
"good-luck": 27,
"content": "能够拓展人际关系的一天,谨慎地与人交往吧"
},
{
"good-luck": 9,
"content": "跨越眼下的困境将会得到很好的成长"
},
{
"good-luck": 9,
"content": "努力的话可以获得与之相应的成果的一天"
},
{
"good-luck": 9,
"content": "努力完成工作,自然能够磨炼自己的能力"
},
{
"good-luck": 8,
"content": "今天带最低限度的钱出门吧"
},
{
"good-luck": 8,
"content": "积蓄至今的努力,将会成为你突破波澜万丈的运气!"
},
{
"good-luck": 6,
"content": "不要焦急不要慌张,用心细致地完成工作吧!"
},
{
"good-luck": 7,
"content": "培养与人之间的羁绊,多进行愉快的谈话吧"
},
{
"good-luck": 5,
"content": "用心做出冷静的判断则吉"
},
{
"good-luck": 7,
"content": "勒紧钱包的话将会找到更加重要的东西"
},
{
"good-luck": -7,
"content": "是被人关注的一天,要把和谐关系放在第一位"
},
{
"good-luck": 10,
"content": "万事顺利的一天!"
},
{
"good-luck": 9,
"content": "相信自己的能力坚持到最后吧!"
},
{
"good-luck": 9,
"content": "有可能会被采用意见并且得到称赞哦"
},
{
"good-luck": 9,
"content": "用团队合作来提升工作质量吧!"
},
{
"good-luck": 9,
"content": "机遇无处不在,试着扩大一下活动范围吧"
},
{
"good-luck": 6,
"content": "天上可不会掉馅饼喔"
},
{
"good-luck": 6,
"content": "钱包少放钱,刷卡也避免"
},
{
"good-luck": 8,
"content": "或许会产生想要提高知识与修养的念头"
},
{
"good-luck": 7,
"content": "不拘泥于小节心情才会变得舒畅"
},
{
"good-luck": 7,
"content": "是时候为了取得资格而开始学习了"
},
{
"good-luck": 21,
"content": "或许会有爱情方面的收获 能让人心意相通的一天"
},
{
"good-luck": 10,
"content": "不要忘记谦虚的初心"
},
{
"good-luck": 9,
"content": "多与他人接触充实内心 亲切待人是好运的关键"
},
{
"good-luck": 26,
"content": "出乎想象开心的一天,把笑容分享给周围吧"
},
{
"good-luck": 9,
"content": "或许可以在SNS上领悟到什么人生启发"
},
{
"good-luck": 9,
"content": "是受人所托的一天,最好果断的行动"
},
{
"good-luck": 8,
"content": "内心冷静的一天,不慌不忙的度过吧"
},
{
"good-luck": 24,
"content": "文钱不落虚空财运UP"
},
{
"good-luck": 23,
"content": "可能会有机会得到能增长自己见识的副业"
},
{
"good-luck": 7,
"content": "心跳加速万分期待的日子,对进展要从容不迫"
},
{
"good-luck": 5,
"content": "珍惜私人时间明天才会更有活力"
},
{
"good-luck": 26,
"content": "自己和别人被承认的一天,要深深地点头认可"
},
{
"good-luck": -7,
"content": "既然得到他人劝告就要虚心改正"
},
{
"good-luck": 10,
"content": "能和人分享喜悦,露出最真实的一面吧"
},
{
"good-luck": 10,
"content": "通过主动去挑战会有所长进"
},
{
"good-luck": 9,
"content": "努力就会有成果的一天!"
},
{
"good-luck": 9,
"content": "能与别人很好合作的一天,坦率很重要"
},
{
"good-luck": 9,
"content": "会引人注目的一天!顺其自然"
},
{
"good-luck": 6,
"content": "也许忍住购物欲会比较好"
},
{
"good-luck": 8,
"content": "忙碌但能获得充实感!"
},
{
"good-luck": -7,
"content": "即使值得做的事,也可能心有余力而不足"
},
{
"good-luck": 8,
"content": "努力工作会得到认可的一天"
},
{
"good-luck": 7,
"content": "主动去挑战艰难的工作吧!"
},
{
"good-luck": 24,
"content": "也许能简单入手珍品!"
},
{
"good-luck": 24,
"content": "注意不要冲动购物,之后可能会后悔"
},
{
"good-luck": -7,
"content": "试着说一说自己奇特的想法"
},
{
"good-luck": 10,
"content": "把想法付诸到实践里试试!"
},
{
"good-luck": 9,
"content": "愿望或许能实现,寻求身边的协助会有好运"
},
{
"good-luck": 24,
"content": "存款可能会大大增加"
},
{
"good-luck": 9,
"content": "经济上的投资可能会带来临时收益哦!"
},
{
"good-luck": 9,
"content": "今天是适合收集情报的一天"
},
{
"good-luck": 8,
"content": "注意要脚踏实地的行动"
},
{
"good-luck": 8,
"content": "更加注意修养方面,在此之上更上一层楼吧!"
},
{
"good-luck": -7,
"content": "频繁地犯一些小失误,要冷静下来哦"
},
{
"good-luck": 27,
"content": "别人对你的信赖度可能会上升"
},
{
"good-luck": 7,
"content": "想买彩票的话今天相当合适"
},
{
"good-luck": 7,
"content": "不要害怕新的环境去尝试融入它吧"
},
{
"good-luck": -7,
"content": "表达意见的时候要注意尽量委婉的去表达吧"
},
{
"good-luck": 10,
"content": "内心丰富多彩的一天,值得沉浸在自己喜欢的事物里"
},
{
"good-luck": 24,
"content": "财运非常棒的一天!能有效的利用自己的财产"
},
{
"good-luck": 21,
"content": "大展才能!女性友人是幸运的关键"
},
{
"good-luck": 27,
"content": "似乎与难得的伙伴有缘!"
},
{
"good-luck": 9,
"content": "慷慨的花钱,磨炼自我!"
},
{
"good-luck": 5,
"content": "今天听到的能赚钱的话语,最好不要上心"
},
{
"good-luck": 8,
"content": "你的想法似乎能得到高度评价"
},
{
"good-luck": 8,
"content": "立刻开始学习你感到需要的知识和修养"
},
{
"good-luck": 24,
"content": "财运很棒,是再一次开始存钱的机会"
},
{
"good-luck": 7,
"content": "可以尝试着开始学习以提高能力"
},
{
"good-luck": 7,
"content": "似乎可以遇到能长时间使用的东西,凭直觉去购买"
},
{
"good-luck": -7,
"content": "定下目标,挑战一下试试!"
},
{
"good-luck": 10,
"content": "无论独自一人还是与人相伴都可以充实度过的一天"
},
{
"good-luck": 9,
"content": "能够准确的行动的一天"
},
{
"good-luck": 9,
"content": "为了达成今后的目标要制定财务计划"
},
{
"good-luck": 9,
"content": "会萌生出未曾发现的能力哦!"
},
{
"good-luck": 9,
"content": "若是被相中为指挥者,就奋起一搏吧!"
},
{
"good-luck": 8,
"content": "慎重的选择发言会拥有喜悦的一天"
},
{
"good-luck": 8,
"content": "践行理想的一天,带着笑容向前进吧"
},
{
"good-luck": 8,
"content": "幸运将会造访你未来的憧憬,做出积极的发言吧"
},
{
"good-luck": 7,
"content": "努力的人将会在今天收获果实"
},
{
"good-luck": 7,
"content": "安稳的一天,要重视自己该有的时机"
},
{
"good-luck": 21,
"content": "或许会出现欣赏你魅力的人!?"
},
{
"good-luck": -7,
"content": "多注意好事的两面性哦"
},
{
"good-luck": 27,
"content": "人气运上升!绽放笑容吧"
},
{
"good-luck": 21,
"content": "受异性青睐的日子,相信自己的魅力"
},
{
"good-luck": 9,
"content": "花钱可能使幸运值上升!"
},
{
"good-luck": 9,
"content": "会与能人异士邂逅!放低姿态"
},
{
"good-luck": 9,
"content": "自由的行动中寄宿了幸运的日子"
},
{
"good-luck": 8,
"content": "感性变丰富的日子,接触一些美好食物吧"
},
{
"good-luck": 24,
"content": "只在钱包里准备最低限度的钱"
},
{
"good-luck": 8,
"content": "被摆脱帮忙就做力所能及的事,十分耀眼"
},
{
"good-luck": 7,
"content": "在这样那样的迷茫之中也能享受的日子"
},
{
"good-luck": 21,
"content": "能得到异性关注的日子,端正姿态"
},
{
"good-luck": 7,
"content": "精心计划交际费用,赠礼应当积极!"
},
{
"good-luck": -7,
"content": "在接近目标的分岔路上用心做出选择"
},
{
"good-luck": 10,
"content": "试试为了磨炼自己而花费时间◎"
},
{
"good-luck": 27,
"content": "靠连带意识和同伴意识创造良好的氛围"
},
{
"good-luck": 9,
"content": "眼见很准确的一天,做有益的购物吧"
},
{
"good-luck": 9,
"content": "自身魅力闪耀之日,珍视喜爱的东西"
},
{
"good-luck": 9,
"content": "靠让自己变忙提升能力!"
},
{
"good-luck": 8,
"content": "对手上的锅也会感觉到有意义"
},
{
"good-luck": 8,
"content": "行动力突出!时间和金钱都尽情使用吧"
},
{
"good-luck": -7,
"content": "熟练之事也会犯低级错误?"
},
{
"good-luck": 24,
"content": "财运滚滚,也分给身边的人一些"
},
{
"good-luck": 23,
"content": "设置好大家都能愉快工作的环境"
},
{
"good-luck": 7,
"content": "可以期待心跳的日子,放慢脚步"
},
{
"good-luck": 5,
"content": "虽伴有风险,成功的预感也颇高!"
}
]
}

84
assets/data/goodLuck.json Normal file
View File

@ -0,0 +1,84 @@
{
"types_of": [
{
"good-luck": 10,
"name": "大吉"
},
{
"good-luck": 9,
"name": "中吉"
},
{
"good-luck": 8,
"name": "小吉"
},
{
"good-luck": 7,
"name": "吉"
},
{
"good-luck": 6,
"name": "半吉"
},
{
"good-luck": 5,
"name": "末吉"
},
{
"good-luck": 4,
"name": "末小吉"
},
{
"good-luck": -6,
"name": "凶"
},
{
"good-luck": -7,
"name": "小凶"
},
{
"good-luck": -8,
"name": "半凶"
},
{
"good-luck": -9,
"name": "末凶"
},
{
"good-luck": -10,
"name": "大凶"
},
{
"good-luck": 20,
"name": "総合運"
},
{
"good-luck": 21,
"name": "恋愛運"
},
{
"good-luck": 22,
"name": "結婚運"
},
{
"good-luck": 23,
"name": "仕事運"
},
{
"good-luck": 24,
"name": "金運"
},
{
"good-luck": 25,
"name": "勉強運"
},
{
"good-luck": 26,
"name": "全体運"
},
{
"good-luck": 27,
"name": "関係運"
}
]
}

BIN
assets/fonts/Mamelon.otf Normal file

Binary file not shown.

BIN
assets/fonts/sakura.ttf Normal file

Binary file not shown.

BIN
assets/img/frame_1.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 208 KiB

BIN
assets/img/frame_10.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 223 KiB

BIN
assets/img/frame_11.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 230 KiB

BIN
assets/img/frame_12.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 202 KiB

BIN
assets/img/frame_13.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 221 KiB

BIN
assets/img/frame_14.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 204 KiB

BIN
assets/img/frame_15.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 216 KiB

BIN
assets/img/frame_16.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 209 KiB

BIN
assets/img/frame_17.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 221 KiB

BIN
assets/img/frame_18.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 230 KiB

BIN
assets/img/frame_19.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 222 KiB

BIN
assets/img/frame_2.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 216 KiB

BIN
assets/img/frame_20.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 221 KiB

BIN
assets/img/frame_21.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 213 KiB

BIN
assets/img/frame_22.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 231 KiB

BIN
assets/img/frame_23.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 215 KiB

BIN
assets/img/frame_24.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 233 KiB

BIN
assets/img/frame_25.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 197 KiB

BIN
assets/img/frame_26.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 220 KiB

BIN
assets/img/frame_27.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 221 KiB

BIN
assets/img/frame_3.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 222 KiB

BIN
assets/img/frame_4.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 216 KiB

BIN
assets/img/frame_5.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 211 KiB

BIN
assets/img/frame_6.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 232 KiB

BIN
assets/img/frame_7.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 212 KiB

BIN
assets/img/frame_8.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 228 KiB

BIN
assets/img/frame_9.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 210 KiB

View File

@ -102,7 +102,11 @@ def generate_almanac():
def get_almanac_image(): def get_almanac_image():
# 判断是否需要重新生成黄历,无 redis 不生成。 # 判断是否需要重新生成黄历,无 redis 不生成。
if redis_status(): if redis_status():
if not redis.get('almanac').decode() == time.strftime("%Y-%m-%d"): try:
date = redis.get('almanac').decode()
except AttributeError:
date = None
if not date == time.strftime("%Y-%m-%d"):
generate_almanac() generate_almanac()
return f'{working_dir}{sep}temp{sep}almanac.png' return f'{working_dir}{sep}temp{sep}almanac.png'
else: else:

175
defs/fortunate.py Normal file
View File

@ -0,0 +1,175 @@
import json, time, secrets
from defs.character import nic2name, get_json, auto_correct, montage_result
from os import getcwd, sep
from PIL import Image, ImageDraw, ImageFont
from json.decoder import JSONDecodeError
from defs.redis_load import redis_status, redis
def get_character(name: str):
# 角色常见昵称转换为官方角色名
nick_name = nic2name(name)
try:
if nick_name == '旅行者':
return "派蒙这里不支持旅行者哦。", None
get_json(nick_name)
return nick_name, 'ok'
except JSONDecodeError:
correct_result = auto_correct(nick_name)
if correct_result is None:
return f"派蒙这里没找到 <code>{name}</code> ,可能是派蒙的错,可能是你输入的名字不正确哦。", None
else:
if len(correct_result) > 1:
return f"派蒙这里没找到 <code>{name}</code> ,你是要搜索如下的角色吗?\n{montage_result(correct_result)}", None
elif len(correct_result) < 1:
return f"派蒙这里没找到 <code>{name}</code> ,可能是派蒙的错,可能是你输入的名字不正确哦。", None
else:
return f"派蒙这里没找到 <code>{name}</code> ,你是要搜索 <code>{correct_result[0]}</code> 吗", None
def get_img_path(name: str):
data = ['迪奥娜', '芭芭拉', '', '重云', '行秋', '凯亚', '雷泽', '温迪', '班尼特', '迪卢克', '砂糖', '北斗', '菲谢尔',
'诺艾尔', '香菱', '达达利亚', '丽莎', '安伯', '七七', '', '凝光', '莫娜', '刻晴', '可莉', '钟离', '辛焱',
'阿贝多']
if name == 'random':
secret_generator = secrets.SystemRandom()
index = secret_generator.randint(0, len(data) - 1)
return f'{getcwd()}{sep}assets{sep}img{sep}frame_{index + 1}.jpg'
return f'{getcwd()}{sep}assets{sep}img{sep}frame_{data.index(name) + 1}.jpg'
def copy_writing(uid):
p = f"{getcwd()}{sep}assets{sep}data{sep}fortunate.json"
with open(p, "r", encoding="utf-8") as f:
content = json.loads(f.read())
secret_generator = secrets.SystemRandom()
index = secret_generator.randint(0, len(content["fortunate"]) - 1)
text = json.dumps(content["fortunate"][index])
redis.set(f'f_{uid}_txt', text)
redis.set(f'f_{uid}', time.strftime("%Y-%m-%d"))
return content["fortunate"][index]
def getTitle(structure):
p = f"{getcwd()}{sep}assets{sep}data{sep}goodLuck.json"
with open(p, "r", encoding="utf-8") as f:
content = json.loads(f.read())
for i in content["types_of"]:
if i["good-luck"] == structure["good-luck"]:
return i["name"]
def drawing(img_path, text):
resources = f"{getcwd()}{sep}assets{sep}fonts{sep}"
fonts_path = {
"title": f"{resources}Mamelon.otf",
"text": f"{resources}sakura.ttf",
}
img = Image.open(img_path)
# Draw title
draw = ImageDraw.Draw(img)
title = getTitle(text)
text = text["content"]
font_size = 45
color = "#F5F5F5"
image_font_center = (140, 99)
tt_front = ImageFont.truetype(fonts_path["title"], font_size)
font_length = tt_front.getsize(title)
draw.text(
(
image_font_center[0] - font_length[0] / 2,
image_font_center[1] - font_length[1] / 2,
),
title,
fill=color,
font=tt_front,
)
# Text rendering
font_size = 25
color = "#323232"
image_font_center = [140, 297]
tt_front = ImageFont.truetype(fonts_path["text"], font_size)
result = decrement(text)
if not result[0]:
return
for i in range(0, result[0]):
font_height = len(result[i + 1]) * (font_size + 4)
text_vertical = vertical(result[i + 1])
x = int(
image_font_center[0]
+ (result[0] - 2) * font_size / 2
+ (result[0] - 1) * 4
- i * (font_size + 4)
)
y = int(image_font_center[1] - font_height / 2)
draw.text((x, y), text_vertical, fill=color, font=tt_front)
# Save
img.save(f'temp{sep}fortune.png')
return f'temp{sep}fortune.png'
def decrement(text):
length = len(text)
result = []
cardinality = 9
if length > 4 * cardinality:
return [False]
number_of_slices = 1
while length > cardinality:
number_of_slices += 1
length -= cardinality
result.append(number_of_slices)
# Optimize for two columns
space = " "
length = len(text)
if number_of_slices == 2:
if length % 2 == 0:
# even
fill_in = space * int(9 - length / 2)
return [
number_of_slices,
text[: int(length / 2)] + fill_in,
fill_in + text[int(length / 2):],
]
else:
# odd number
fill_in = space * int(9 - (length + 1) / 2)
return [
number_of_slices,
text[: int((length + 1) / 2)] + fill_in,
fill_in + space + text[int((length + 1) / 2):],
]
for i in range(0, number_of_slices):
if i == number_of_slices - 1 or number_of_slices == 1:
result.append(text[i * cardinality:])
else:
result.append(text[i * cardinality: (i + 1) * cardinality])
return result
def vertical(txt):
lists = []
for s in txt:
lists.append(s)
return "\n".join(lists)
def get_fortunate_image(uid, name):
# 判断是否需要重新生成,无 redis 不生成。
if redis_status():
try:
date = redis.get(f'f_{uid}').decode()
except AttributeError:
date = None
if not date == time.strftime("%Y-%m-%d"):
text = copy_writing(uid)
img = get_img_path(name)
drawing(img, text)
return f'{getcwd()}{sep}temp{sep}fortune.png'
else:
text = json.loads(redis.get(f'f_{uid}_txt').decode())
img = get_img_path(name)
drawing(img, text)
return f'{getcwd()}{sep}temp{sep}fortune.png'
else:
return ''

View File

@ -112,7 +112,8 @@ async def draw_pic(uid):
id_img = Image.open(f"{working_dir}{sep}assets{sep}images{sep}level.png").resize((250, 155), id_img = Image.open(f"{working_dir}{sep}assets{sep}images{sep}level.png").resize((250, 155),
Image.BILINEAR).convert("RGBA") Image.BILINEAR).convert("RGBA")
# 上右部背景 # 上右部背景
level_img = Image.open(f"{working_dir}{sep}assets{sep}images{sep}level2.png").resize((180, 180), "RGBA") level_img = Image.open(f"{working_dir}{sep}assets{sep}images{sep}level2.png").resize((180, 180),
Image.BILINEAR).convert("RGBA")
# 中部大背景 # 中部大背景
p1_img = Image.open(f"{working_dir}{sep}assets{sep}images{sep}p1.png").resize((600, 300), p1_img = Image.open(f"{working_dir}{sep}assets{sep}images{sep}p1.png").resize((600, 300),
Image.BILINEAR).convert("RGBA") Image.BILINEAR).convert("RGBA")
@ -148,7 +149,7 @@ async def draw_pic(uid):
img_canvas.paste(char5_img, (440, 540), char5_img) img_canvas.paste(char5_img, (440, 540), char5_img)
img_canvas.paste(char6_img, (540, 540), char6_img) img_canvas.paste(char6_img, (540, 540), char6_img)
text_draw.text((240, 80), "账号信息", 'lightcyan', ys_font(23)) text_draw.text((275, 15), "账号信息", 'lightcyan', ys_font(23))
text_draw.text((230, 80), f'UID {uid}', 'lightcyan', ys_font(25)) text_draw.text((230, 80), f'UID {uid}', 'lightcyan', ys_font(25))
if uid[0] == "1": if uid[0] == "1":
text_draw.text((230, 130), "服务器 天空岛", 'lightcyan', ys_font(25)) text_draw.text((230, 130), "服务器 天空岛", 'lightcyan', ys_font(25))

50
plugins/fortunate.py Normal file
View File

@ -0,0 +1,50 @@
from pyrogram import Client
from pyrogram.types import Message
from defs.fortunate import get_character, get_fortunate_image
from defs.redis_load import redis_status, redis
async def fortunate_msg(client: Client, message: Message):
# 生成运势
uid = message.from_user.id
name = message.text.replace('今日运势', '').replace('运势', '').strip()
if name == '':
if redis_status():
try:
name = redis.get(f'f_{uid}_name').decode()
except AttributeError:
name = 'random'
else:
name = 'random'
else:
name, temp = get_character(name)
if not temp:
await message.reply(name, quote=True)
return
path = get_fortunate_image(message.from_user.id, name)
if path == '':
await message.reply('派蒙与提瓦特大陆的连接遇到了一点问题:<code>数据库离线</code>', quote=True)
return
if 'fortune.png' in path:
# 开始上传
await message.reply_photo(photo=path, quote=True)
async def set_fortunate_img(client: Client, message: Message):
# 设置默认运势图
uid = message.from_user.id
name = message.text.replace('设置运势', '').strip()
if not redis_status():
await message.reply('派蒙与提瓦特大陆的连接遇到了一点问题:<code>数据库离线</code>', quote=True)
return
if name == '':
name = 'random'
else:
name, temp = get_character(name)
if not temp:
await message.reply(name, quote=True)
return
redis.set(f'f_{uid}_name', name)
if name == 'random':
name = '随机'
await message.reply(f'设置成功,默认运势角色已设置为:<code>{name}</code>')

View File

@ -6,6 +6,7 @@ from plugins.almanac import almanac_msg
from plugins.challenge import tf_msg, wq_msg, zb_msg from plugins.challenge import tf_msg, wq_msg, zb_msg
from plugins.character import character_msg, mz_msg from plugins.character import character_msg, mz_msg
from plugins.weapons import weapon_msg from plugins.weapons import weapon_msg
from plugins.fortunate import fortunate_msg, set_fortunate_img
from plugins.mys import mys_msg, promote_command from plugins.mys import mys_msg, promote_command
from defs.log import log from defs.log import log
@ -56,6 +57,15 @@ async def process_private_msg(client: Client, message: Message):
if '命座' in message.text: if '命座' in message.text:
await mz_msg(client, message) await mz_msg(client, message)
await log(client, message, '查询角色命座') await log(client, message, '查询角色命座')
# 设置运势
if '设置运势' in message.text:
await set_fortunate_img(client, message)
await log(client, message, '设置运势角色')
return
# 运势查询
if '运势' in message.text:
await fortunate_msg(client, message)
await log(client, message, '查询今日运势')
# 账号信息cookie 过期过快 不推荐启用) # 账号信息cookie 过期过快 不推荐启用)
# if '账号信息' in message.text or '用户信息' in message.text: # if '账号信息' in message.text or '用户信息' in message.text:
# await mys_msg(client, message) # await mys_msg(client, message)
@ -97,10 +107,19 @@ async def process_group_msg(client: Client, message: Message):
if text.startswith('命座'): if text.startswith('命座'):
await mz_msg(client, message) await mz_msg(client, message)
await log(client, message, '查询角色命座') await log(client, message, '查询角色命座')
# 运势查询
if text.startswith('运势') or text.startswith('今日运势'):
await fortunate_msg(client, message)
await log(client, message, '查询今日运势')
# 设置运势
if text.startswith('设置运势'):
await set_fortunate_img(client, message)
await log(client, message, '设置运势角色')
@Client.on_message(Filters.new_chat_members) @Client.on_message(Filters.new_chat_members)
async def send_self_intro(client: Client, message: Message): async def send_self_intro(client: Client, message: Message):
# 发送欢迎消息 # 发送欢迎消息
await message.reply('感谢邀请小派蒙到本群!\n请使用 /help 查看咱已经学会的功能。', quote=True) if message.new_chat_members[0].is_self:
await log(client, message, '邀请入群') await message.reply('感谢邀请小派蒙到本群!\n请使用 /help 查看咱已经学会的功能。', quote=True)
await log(client, message, '邀请入群')

View File

@ -39,13 +39,19 @@ async def leave_command(client: Client, message: Message):
async def help_command(client: Client, message: Message): async def help_command(client: Client, message: Message):
text = '<a href="https://git.io/JcbTD">PaimonBot</a> 0.1.0beta By Xtao-Labs\n\n' \ text = '<a href="https://git.io/JcbTD">PaimonBot</a> 0.1.1beta By Xtao-Labs\n\n' \
'🔅 以下是小派蒙我学会了的功能(部分):\n' \ '🔅 以下是小派蒙我学会了的功能(部分):\n' \
'1⃣ [武器/今日武器] 查看今日武器材料和武器\n' \ '1⃣ [武器/今日武器] 查看今日武器材料和武器\n' \
'2⃣ [天赋/今日天赋] 查看今日天赋材料和角色\n' \ '2⃣ [天赋/今日天赋] 查看今日天赋材料和角色\n' \
'3⃣ [周本] 查看周本材料和人物\n' \ '3⃣ [周本] 查看周本材料和人物\n' \
'4⃣ [武器查询 武器名] 查看武器资料\n 💠 <code>武器查询 沐浴龙血的剑</code>\n' \ '4⃣ [武器查询 武器名] 查看武器资料\n' \
'5⃣ [角色查询 名字] 查看人物简介\n 💠 <code>角色查询 重云</code>\n' \ ' 💠 <code>武器查询 沐浴龙血的剑</code>\n' \
'6⃣ [命座 名字] 查看人物命座\n 💠 <code>命座 重云一命</code>\n' \ '5⃣ [角色查询 名字] 查看人物简介\n' \
'7⃣ [原神黄历] 查看随机生成的原神黄历' ' 💠 <code>角色查询 重云</code>\n' \
'6⃣ [命座 名字] 查看人物命座\n' \
' 💠 <code>命座 重云一命</code>\n' \
'7⃣ [运势 (名字)] 查看今日运势\n' \
' 💠 <code>运势 (重云)</code>\n' \
' 💠 <code>设置运势 (重云)</code>\n' \
'8⃣ [原神黄历] 查看随机生成的原神黄历'
await message.reply(text, quote=True, disable_web_page_preview=True) await message.reply(text, quote=True, disable_web_page_preview=True)