参考
- https://zhuanlan.zhihu.com/p/603724047
- https://www.163.com/dy/article/HTD2ID4G05561K0X.html
- https://zhuanlan.zhihu.com/p/603724047
想法
- 接微信机器人
- 群友对话直接 at 机器人、以指令开头、触发逻辑。
- 接 chatgpt
- 根据问题与获取的卦辞或者表达的象征,通过有预设的 gpt 做解释后发回给群友。
代码部分
十二地支时间换算
import datetime
from lunardate import LunarDate
Zhi = ["子", "醜", "寅", "卯", "辰", "巳", "午", "未", "申", "酉", "戌", "亥"]
def get_factor_time(time:datetime.datetime=None):
if time is None:
time = datetime.datetime.now()
# 获取农历时间
lunar_time = LunarDate.fromSolarDate(time.year, time.month, time.day)
# 输出农历时间
lunar_month = lunar_time.month
lunar_day = lunar_time.day
lunar_hour = time.hour//2
print(f"农历时间:{lunar_month} 月 {lunar_day} 日 {lunar_hour}({Zhi[lunar_hour]}) 时")
完整代码
#!/usr/bin/env python
# encoding: utf-8
# @Time : 2023/07/04 01:05:33
# @author : zza
# @Email : z740713651@outlook.com
# @File : xiao_liu_ren.py
from collections import defaultdict
import datetime
from lunardate import LunarDate
Zhi = ["子", "醜", "寅", "卯", "辰", "巳", "午", "未", "申", "酉", "戌", "亥"]
xiao_liu_ren = [
"大安",
"留连",
"速喜",
"赤口",
"小吉",
"空亡",
]
def get_factor_time(time: datetime.datetime = None):
if time is None:
time = datetime.datetime.now()
print(f"阳历时间:{time.isoformat()}")
# 获取农历时间
lunar_time = LunarDate.fromSolarDate(time.year, time.month, time.day)
# 输出农历时间
lunar_month = lunar_time.month
lunar_day = lunar_time.day
lunar_hour = (time.hour + 1) // 2
print(f"农历时间:{lunar_month} 月 {lunar_day} 日 {Zhi[lunar_hour]}({lunar_hour}) 时")
factor_month = xiao_liu_ren[(lunar_month - 1) % 6]
factor_day = xiao_liu_ren[(lunar_month - 1 + lunar_day - 1) % 6]
factor_hour = xiao_liu_ren[(lunar_month - 1 + lunar_day - 1 + lunar_hour) % 6]
print(f"小六壬月日时:{factor_month} {factor_day} {factor_hour}")
return factor_month, factor_day, factor_hour
def lost_item(factor):
guaci = {
"大安": {
"留连": "大安加留连,失物西北去。",
"速喜": "大安加速喜,失物当日见。",
"赤口": "大安加赤口,失物不用找。",
"小吉": "大安加小吉,失物不出门。",
"空亡": "大安加空亡,失物无踪影。",
"大安": "大安加大安,失物在家里。",
},
"留连": {
"