diff --git a/bot.py b/bot.py index c3bb0e3..76bebd1 100644 --- a/bot.py +++ b/bot.py @@ -1,6 +1,6 @@ import nonebot from nonebot.adapters.qq import Adapter as QQAdapter -from src.qq_plugins.data_init import data_init # 导入QQ插件 +from src.my_sqlite.data_init import data_init nonebot.init() driver = nonebot.get_driver() diff --git a/src/img_resource/MaoYuNa/001.png b/src/image/MaoYuNa/001.png similarity index 100% rename from src/img_resource/MaoYuNa/001.png rename to src/image/MaoYuNa/001.png diff --git a/src/img_resource/MaoYuNa/002.png b/src/image/MaoYuNa/002.png similarity index 100% rename from src/img_resource/MaoYuNa/002.png rename to src/image/MaoYuNa/002.png diff --git a/src/img_resource/MaoYuNa/003.png b/src/image/MaoYuNa/003.png similarity index 100% rename from src/img_resource/MaoYuNa/003.png rename to src/image/MaoYuNa/003.png diff --git a/src/img_resource/MaoYuNa/005.png b/src/image/MaoYuNa/005.png similarity index 100% rename from src/img_resource/MaoYuNa/005.png rename to src/image/MaoYuNa/005.png diff --git a/src/img_resource/MaoYuNa/006.png b/src/image/MaoYuNa/006.png similarity index 100% rename from src/img_resource/MaoYuNa/006.png rename to src/image/MaoYuNa/006.png diff --git a/src/img_resource/MaoYuNa/007.png b/src/image/MaoYuNa/007.png similarity index 100% rename from src/img_resource/MaoYuNa/007.png rename to src/image/MaoYuNa/007.png diff --git a/src/img_resource/MaoYuNa/008.png b/src/image/MaoYuNa/008.png similarity index 100% rename from src/img_resource/MaoYuNa/008.png rename to src/image/MaoYuNa/008.png diff --git a/src/img_resource/MaoYuNa/009.png b/src/image/MaoYuNa/009.png similarity index 100% rename from src/img_resource/MaoYuNa/009.png rename to src/image/MaoYuNa/009.png diff --git a/src/img_resource/MaoYuNa/010.png b/src/image/MaoYuNa/010.png similarity index 100% rename from src/img_resource/MaoYuNa/010.png rename to src/image/MaoYuNa/010.png diff --git a/src/img_resource/MaoYuNa/011.png b/src/image/MaoYuNa/011.png similarity index 100% rename from src/img_resource/MaoYuNa/011.png rename to src/image/MaoYuNa/011.png diff --git a/src/img_resource/MaoYuNa/012.png b/src/image/MaoYuNa/012.png similarity index 100% rename from src/img_resource/MaoYuNa/012.png rename to src/image/MaoYuNa/012.png diff --git a/src/img_resource/MaoYuNa/013.png b/src/image/MaoYuNa/013.png similarity index 100% rename from src/img_resource/MaoYuNa/013.png rename to src/image/MaoYuNa/013.png diff --git a/src/img_resource/MaoYuNa/014.png b/src/image/MaoYuNa/014.png similarity index 100% rename from src/img_resource/MaoYuNa/014.png rename to src/image/MaoYuNa/014.png diff --git a/src/img_resource/MaoYuNa/015.png b/src/image/MaoYuNa/015.png similarity index 100% rename from src/img_resource/MaoYuNa/015.png rename to src/image/MaoYuNa/015.png diff --git a/src/img_resource/MaoYuNa/016.png b/src/image/MaoYuNa/016.png similarity index 100% rename from src/img_resource/MaoYuNa/016.png rename to src/image/MaoYuNa/016.png diff --git a/src/img_resource/MaoYuNa/017.png b/src/image/MaoYuNa/017.png similarity index 100% rename from src/img_resource/MaoYuNa/017.png rename to src/image/MaoYuNa/017.png diff --git a/src/img_resource/MaoYuNa/018.png b/src/image/MaoYuNa/018.png similarity index 100% rename from src/img_resource/MaoYuNa/018.png rename to src/image/MaoYuNa/018.png diff --git a/src/img_resource/MaoYuNa/019.png b/src/image/MaoYuNa/019.png similarity index 100% rename from src/img_resource/MaoYuNa/019.png rename to src/image/MaoYuNa/019.png diff --git a/src/img_resource/MaoYuNa/020.png b/src/image/MaoYuNa/020.png similarity index 100% rename from src/img_resource/MaoYuNa/020.png rename to src/image/MaoYuNa/020.png diff --git a/src/img_resource/MaoYuNa/021.png b/src/image/MaoYuNa/021.png similarity index 100% rename from src/img_resource/MaoYuNa/021.png rename to src/image/MaoYuNa/021.png diff --git a/src/img_resource/MaoYuNa/022.png b/src/image/MaoYuNa/022.png similarity index 100% rename from src/img_resource/MaoYuNa/022.png rename to src/image/MaoYuNa/022.png diff --git a/src/img_resource/MaoYuNa/023.png b/src/image/MaoYuNa/023.png similarity index 100% rename from src/img_resource/MaoYuNa/023.png rename to src/image/MaoYuNa/023.png diff --git a/src/img_resource/MaoYuNa/024.png b/src/image/MaoYuNa/024.png similarity index 100% rename from src/img_resource/MaoYuNa/024.png rename to src/image/MaoYuNa/024.png diff --git a/src/img_resource/MaoYuNa/025.png b/src/image/MaoYuNa/025.png similarity index 100% rename from src/img_resource/MaoYuNa/025.png rename to src/image/MaoYuNa/025.png diff --git a/src/img_resource/MaoYuNa/026.png b/src/image/MaoYuNa/026.png similarity index 100% rename from src/img_resource/MaoYuNa/026.png rename to src/image/MaoYuNa/026.png diff --git a/src/img_resource/MaoYuNa/027.png b/src/image/MaoYuNa/027.png similarity index 100% rename from src/img_resource/MaoYuNa/027.png rename to src/image/MaoYuNa/027.png diff --git a/src/img_resource/MaoYuNa/028.png b/src/image/MaoYuNa/028.png similarity index 100% rename from src/img_resource/MaoYuNa/028.png rename to src/image/MaoYuNa/028.png diff --git a/src/img_resource/MaoYuNa/029.png b/src/image/MaoYuNa/029.png similarity index 100% rename from src/img_resource/MaoYuNa/029.png rename to src/image/MaoYuNa/029.png diff --git a/src/img_resource/MaoYuNa/030.png b/src/image/MaoYuNa/030.png similarity index 100% rename from src/img_resource/MaoYuNa/030.png rename to src/image/MaoYuNa/030.png diff --git a/src/common_plugins/config/common.yaml b/src/image/config/image.yaml similarity index 77% rename from src/common_plugins/config/common.yaml rename to src/image/config/image.yaml index 04e5a5b..c6b31e0 100644 --- a/src/common_plugins/config/common.yaml +++ b/src/image/config/image.yaml @@ -1,5 +1,7 @@ image: - image_local_path: "src/img_resource/MaoYuNa" + app_id: "" + image_local_qq_image_path: "src/image/qq_image" + image_local_path: "src/image/MaoYuNa" #SMMS图床相关配置 smms_token: "" # sm.ms图床的token smms_image_upload_history: "https://sm.ms/api/v2/upload_history" # sm.ms图床获取上传图片历史API地址 diff --git a/src/common_plugins/img/get_image.py b/src/image/get_image.py similarity index 63% rename from src/common_plugins/img/get_image.py rename to src/image/get_image.py index 2a8c692..c36bb73 100644 --- a/src/common_plugins/img/get_image.py +++ b/src/image/get_image.py @@ -4,13 +4,15 @@ import random import requests -with open(os.getcwd() +'/src/common_plugins/config/common.yaml', 'r', encoding='utf-8') as f: +with open(os.getcwd() +'/src/image/config/image.yaml', 'r', encoding='utf-8') as f: image = yaml.load(f.read(), Loader=yaml.FullLoader).get('image') image_local_path = image.get('image_local_path') + image_local_qq_image_path = image.get('image_local_qq_image_path') smms_token = image.get('smms_token') smms_image_upload_history = image.get('smms_image_upload_history') ju_he_token = image.get('ju_he_token') ju_he_image_list = image.get('ju_he_image_list') + app_id = image.get('app_id') """本地图片""" def get_image_names(): @@ -24,6 +26,24 @@ def get_image_names(): local_image_path = os.getcwd() + '/' + image_local_path + '/' + random.choice(image_names) # 随机选取一张图片的路径 return local_image_path +"""获取QQ头像""" +def download_qq_image(member_open_id): + save_path = os.getcwd() + '/' + image_local_qq_image_path + '/' + member_open_id + '.jpg' + size = 640 #尺寸 40、100、140、640 + url = f"https://q.qlogo.cn/qqapp/{app_id}/{member_open_id}/{size}" + response = requests.get(url) # 发送 GET 请求获取图片资源 + if response.status_code == 200: # 判断请求是否成功 + with open(save_path, 'wb') as file: # 以二进制写入模式打开文件 + file.write(response.content) # 将响应内容写入文件 + return save_path + +"""删除QQ头像""" +def qq_image_delete(): + for root, dirs, files in os.walk(image_local_qq_image_path): + for file in files: + file_path = os.path.join(root, file) + os.remove(file_path) + """ sm.ms 图床""" def get_smms_image_url(): # 定义请求的参数 diff --git a/src/img_resource/tarot/TarotImages/Ace of Coins.jpg b/src/image/tarot/TarotImages/Ace of Coins.jpg similarity index 100% rename from src/img_resource/tarot/TarotImages/Ace of Coins.jpg rename to src/image/tarot/TarotImages/Ace of Coins.jpg diff --git a/src/img_resource/tarot/TarotImages/Ace of Cups.jpg b/src/image/tarot/TarotImages/Ace of Cups.jpg similarity index 100% rename from src/img_resource/tarot/TarotImages/Ace of Cups.jpg rename to src/image/tarot/TarotImages/Ace of Cups.jpg diff --git a/src/img_resource/tarot/TarotImages/Ace of Swords.jpg b/src/image/tarot/TarotImages/Ace of Swords.jpg similarity index 100% rename from src/img_resource/tarot/TarotImages/Ace of Swords.jpg rename to src/image/tarot/TarotImages/Ace of Swords.jpg diff --git a/src/img_resource/tarot/TarotImages/Ace of Wands.jpg b/src/image/tarot/TarotImages/Ace of Wands.jpg similarity index 100% rename from src/img_resource/tarot/TarotImages/Ace of Wands.jpg rename to src/image/tarot/TarotImages/Ace of Wands.jpg diff --git a/src/img_resource/tarot/TarotImages/Death.jpg b/src/image/tarot/TarotImages/Death.jpg similarity index 100% rename from src/img_resource/tarot/TarotImages/Death.jpg rename to src/image/tarot/TarotImages/Death.jpg diff --git a/src/img_resource/tarot/TarotImages/Five of Cups.png b/src/image/tarot/TarotImages/Five of Cups.png similarity index 100% rename from src/img_resource/tarot/TarotImages/Five of Cups.png rename to src/image/tarot/TarotImages/Five of Cups.png diff --git a/src/img_resource/tarot/TarotImages/Five of Wands.png b/src/image/tarot/TarotImages/Five of Wands.png similarity index 100% rename from src/img_resource/tarot/TarotImages/Five of Wands.png rename to src/image/tarot/TarotImages/Five of Wands.png diff --git a/src/img_resource/tarot/TarotImages/Four of Swords.png b/src/image/tarot/TarotImages/Four of Swords.png similarity index 100% rename from src/img_resource/tarot/TarotImages/Four of Swords.png rename to src/image/tarot/TarotImages/Four of Swords.png diff --git a/src/img_resource/tarot/TarotImages/Judgement.jpg b/src/image/tarot/TarotImages/Judgement.jpg similarity index 100% rename from src/img_resource/tarot/TarotImages/Judgement.jpg rename to src/image/tarot/TarotImages/Judgement.jpg diff --git a/src/img_resource/tarot/TarotImages/Justice.jpg b/src/image/tarot/TarotImages/Justice.jpg similarity index 100% rename from src/img_resource/tarot/TarotImages/Justice.jpg rename to src/image/tarot/TarotImages/Justice.jpg diff --git a/src/img_resource/tarot/TarotImages/King of Cups.png b/src/image/tarot/TarotImages/King of Cups.png similarity index 100% rename from src/img_resource/tarot/TarotImages/King of Cups.png rename to src/image/tarot/TarotImages/King of Cups.png diff --git a/src/img_resource/tarot/TarotImages/King of Pentacles.png b/src/image/tarot/TarotImages/King of Pentacles.png similarity index 100% rename from src/img_resource/tarot/TarotImages/King of Pentacles.png rename to src/image/tarot/TarotImages/King of Pentacles.png diff --git a/src/img_resource/tarot/TarotImages/King of Swords.png b/src/image/tarot/TarotImages/King of Swords.png similarity index 100% rename from src/img_resource/tarot/TarotImages/King of Swords.png rename to src/image/tarot/TarotImages/King of Swords.png diff --git a/src/img_resource/tarot/TarotImages/King of Wands.png b/src/image/tarot/TarotImages/King of Wands.png similarity index 100% rename from src/img_resource/tarot/TarotImages/King of Wands.png rename to src/image/tarot/TarotImages/King of Wands.png diff --git a/src/img_resource/tarot/TarotImages/Knight of Cups.png b/src/image/tarot/TarotImages/Knight of Cups.png similarity index 100% rename from src/img_resource/tarot/TarotImages/Knight of Cups.png rename to src/image/tarot/TarotImages/Knight of Cups.png diff --git a/src/img_resource/tarot/TarotImages/Knight of Pentacles.png b/src/image/tarot/TarotImages/Knight of Pentacles.png similarity index 100% rename from src/img_resource/tarot/TarotImages/Knight of Pentacles.png rename to src/image/tarot/TarotImages/Knight of Pentacles.png diff --git a/src/img_resource/tarot/TarotImages/Knight of Swords.png b/src/image/tarot/TarotImages/Knight of Swords.png similarity index 100% rename from src/img_resource/tarot/TarotImages/Knight of Swords.png rename to src/image/tarot/TarotImages/Knight of Swords.png diff --git a/src/img_resource/tarot/TarotImages/Knight of Wands.png b/src/image/tarot/TarotImages/Knight of Wands.png similarity index 100% rename from src/img_resource/tarot/TarotImages/Knight of Wands.png rename to src/image/tarot/TarotImages/Knight of Wands.png diff --git a/src/img_resource/tarot/TarotImages/Nine of Cups.png b/src/image/tarot/TarotImages/Nine of Cups.png similarity index 100% rename from src/img_resource/tarot/TarotImages/Nine of Cups.png rename to src/image/tarot/TarotImages/Nine of Cups.png diff --git a/src/img_resource/tarot/TarotImages/Page of Cups.png b/src/image/tarot/TarotImages/Page of Cups.png similarity index 100% rename from src/img_resource/tarot/TarotImages/Page of Cups.png rename to src/image/tarot/TarotImages/Page of Cups.png diff --git a/src/img_resource/tarot/TarotImages/Page of Pentacles.png b/src/image/tarot/TarotImages/Page of Pentacles.png similarity index 100% rename from src/img_resource/tarot/TarotImages/Page of Pentacles.png rename to src/image/tarot/TarotImages/Page of Pentacles.png diff --git a/src/img_resource/tarot/TarotImages/Page of Swords.png b/src/image/tarot/TarotImages/Page of Swords.png similarity index 100% rename from src/img_resource/tarot/TarotImages/Page of Swords.png rename to src/image/tarot/TarotImages/Page of Swords.png diff --git a/src/img_resource/tarot/TarotImages/Page of Wands.png b/src/image/tarot/TarotImages/Page of Wands.png similarity index 100% rename from src/img_resource/tarot/TarotImages/Page of Wands.png rename to src/image/tarot/TarotImages/Page of Wands.png diff --git a/src/img_resource/tarot/TarotImages/Queen of Cups.png b/src/image/tarot/TarotImages/Queen of Cups.png similarity index 100% rename from src/img_resource/tarot/TarotImages/Queen of Cups.png rename to src/image/tarot/TarotImages/Queen of Cups.png diff --git a/src/img_resource/tarot/TarotImages/Queen of Pentacles.png b/src/image/tarot/TarotImages/Queen of Pentacles.png similarity index 100% rename from src/img_resource/tarot/TarotImages/Queen of Pentacles.png rename to src/image/tarot/TarotImages/Queen of Pentacles.png diff --git a/src/img_resource/tarot/TarotImages/Queen of Swords.png b/src/image/tarot/TarotImages/Queen of Swords.png similarity index 100% rename from src/img_resource/tarot/TarotImages/Queen of Swords.png rename to src/image/tarot/TarotImages/Queen of Swords.png diff --git a/src/img_resource/tarot/TarotImages/Queen of Wands.png b/src/image/tarot/TarotImages/Queen of Wands.png similarity index 100% rename from src/img_resource/tarot/TarotImages/Queen of Wands.png rename to src/image/tarot/TarotImages/Queen of Wands.png diff --git a/src/img_resource/tarot/TarotImages/Six of Wands.png b/src/image/tarot/TarotImages/Six of Wands.png similarity index 100% rename from src/img_resource/tarot/TarotImages/Six of Wands.png rename to src/image/tarot/TarotImages/Six of Wands.png diff --git a/src/img_resource/tarot/TarotImages/Strength.jpg b/src/image/tarot/TarotImages/Strength.jpg similarity index 100% rename from src/img_resource/tarot/TarotImages/Strength.jpg rename to src/image/tarot/TarotImages/Strength.jpg diff --git a/src/img_resource/tarot/TarotImages/Temperance.jpg b/src/image/tarot/TarotImages/Temperance.jpg similarity index 100% rename from src/img_resource/tarot/TarotImages/Temperance.jpg rename to src/image/tarot/TarotImages/Temperance.jpg diff --git a/src/img_resource/tarot/TarotImages/Ten of Cups.png b/src/image/tarot/TarotImages/Ten of Cups.png similarity index 100% rename from src/img_resource/tarot/TarotImages/Ten of Cups.png rename to src/image/tarot/TarotImages/Ten of Cups.png diff --git a/src/img_resource/tarot/TarotImages/The Chariot.jpg b/src/image/tarot/TarotImages/The Chariot.jpg similarity index 100% rename from src/img_resource/tarot/TarotImages/The Chariot.jpg rename to src/image/tarot/TarotImages/The Chariot.jpg diff --git a/src/img_resource/tarot/TarotImages/The Devil.jpg b/src/image/tarot/TarotImages/The Devil.jpg similarity index 100% rename from src/img_resource/tarot/TarotImages/The Devil.jpg rename to src/image/tarot/TarotImages/The Devil.jpg diff --git a/src/img_resource/tarot/TarotImages/The Emperor.jpg b/src/image/tarot/TarotImages/The Emperor.jpg similarity index 100% rename from src/img_resource/tarot/TarotImages/The Emperor.jpg rename to src/image/tarot/TarotImages/The Emperor.jpg diff --git a/src/img_resource/tarot/TarotImages/The Empress.jpg b/src/image/tarot/TarotImages/The Empress.jpg similarity index 100% rename from src/img_resource/tarot/TarotImages/The Empress.jpg rename to src/image/tarot/TarotImages/The Empress.jpg diff --git a/src/img_resource/tarot/TarotImages/The Fool.jpg b/src/image/tarot/TarotImages/The Fool.jpg similarity index 100% rename from src/img_resource/tarot/TarotImages/The Fool.jpg rename to src/image/tarot/TarotImages/The Fool.jpg diff --git a/src/img_resource/tarot/TarotImages/The Hanged Man.jpg b/src/image/tarot/TarotImages/The Hanged Man.jpg similarity index 100% rename from src/img_resource/tarot/TarotImages/The Hanged Man.jpg rename to src/image/tarot/TarotImages/The Hanged Man.jpg diff --git a/src/img_resource/tarot/TarotImages/The Hermit.jpg b/src/image/tarot/TarotImages/The Hermit.jpg similarity index 100% rename from src/img_resource/tarot/TarotImages/The Hermit.jpg rename to src/image/tarot/TarotImages/The Hermit.jpg diff --git a/src/img_resource/tarot/TarotImages/The Hierophant.jpg b/src/image/tarot/TarotImages/The Hierophant.jpg similarity index 100% rename from src/img_resource/tarot/TarotImages/The Hierophant.jpg rename to src/image/tarot/TarotImages/The Hierophant.jpg diff --git a/src/img_resource/tarot/TarotImages/The High Priestess.jpg b/src/image/tarot/TarotImages/The High Priestess.jpg similarity index 100% rename from src/img_resource/tarot/TarotImages/The High Priestess.jpg rename to src/image/tarot/TarotImages/The High Priestess.jpg diff --git a/src/img_resource/tarot/TarotImages/The Lovers.jpg b/src/image/tarot/TarotImages/The Lovers.jpg similarity index 100% rename from src/img_resource/tarot/TarotImages/The Lovers.jpg rename to src/image/tarot/TarotImages/The Lovers.jpg diff --git a/src/img_resource/tarot/TarotImages/The Magician.jpg b/src/image/tarot/TarotImages/The Magician.jpg similarity index 100% rename from src/img_resource/tarot/TarotImages/The Magician.jpg rename to src/image/tarot/TarotImages/The Magician.jpg diff --git a/src/img_resource/tarot/TarotImages/The Moon.jpg b/src/image/tarot/TarotImages/The Moon.jpg similarity index 100% rename from src/img_resource/tarot/TarotImages/The Moon.jpg rename to src/image/tarot/TarotImages/The Moon.jpg diff --git a/src/img_resource/tarot/TarotImages/The Star.jpg b/src/image/tarot/TarotImages/The Star.jpg similarity index 100% rename from src/img_resource/tarot/TarotImages/The Star.jpg rename to src/image/tarot/TarotImages/The Star.jpg diff --git a/src/img_resource/tarot/TarotImages/The Sun.jpg b/src/image/tarot/TarotImages/The Sun.jpg similarity index 100% rename from src/img_resource/tarot/TarotImages/The Sun.jpg rename to src/image/tarot/TarotImages/The Sun.jpg diff --git a/src/img_resource/tarot/TarotImages/The Tower.jpg b/src/image/tarot/TarotImages/The Tower.jpg similarity index 100% rename from src/img_resource/tarot/TarotImages/The Tower.jpg rename to src/image/tarot/TarotImages/The Tower.jpg diff --git a/src/img_resource/tarot/TarotImages/The Wheel of Fortune.jpg b/src/image/tarot/TarotImages/The Wheel of Fortune.jpg similarity index 100% rename from src/img_resource/tarot/TarotImages/The Wheel of Fortune.jpg rename to src/image/tarot/TarotImages/The Wheel of Fortune.jpg diff --git a/src/img_resource/tarot/TarotImages/The World.jpg b/src/image/tarot/TarotImages/The World.jpg similarity index 100% rename from src/img_resource/tarot/TarotImages/The World.jpg rename to src/image/tarot/TarotImages/The World.jpg diff --git a/src/img_resource/tarot/TarotImages/Three of Swords.png b/src/image/tarot/TarotImages/Three of Swords.png similarity index 100% rename from src/img_resource/tarot/TarotImages/Three of Swords.png rename to src/image/tarot/TarotImages/Three of Swords.png diff --git a/src/img_resource/tarot/sideTarotImages/Temperance.jpg b/src/image/tarot/sideTarotImages/Temperance.jpg similarity index 100% rename from src/img_resource/tarot/sideTarotImages/Temperance.jpg rename to src/image/tarot/sideTarotImages/Temperance.jpg diff --git a/src/img_resource/tarot/sideTarotImages/The Chariot.jpg b/src/image/tarot/sideTarotImages/The Chariot.jpg similarity index 100% rename from src/img_resource/tarot/sideTarotImages/The Chariot.jpg rename to src/image/tarot/sideTarotImages/The Chariot.jpg diff --git a/src/img_resource/tarot/sideTarotImages/The Devil.jpg b/src/image/tarot/sideTarotImages/The Devil.jpg similarity index 100% rename from src/img_resource/tarot/sideTarotImages/The Devil.jpg rename to src/image/tarot/sideTarotImages/The Devil.jpg diff --git a/src/img_resource/tarot/sideTarotImages/The Emperor.jpg b/src/image/tarot/sideTarotImages/The Emperor.jpg similarity index 100% rename from src/img_resource/tarot/sideTarotImages/The Emperor.jpg rename to src/image/tarot/sideTarotImages/The Emperor.jpg diff --git a/src/img_resource/tarot/sideTarotImages/The Fool.jpg b/src/image/tarot/sideTarotImages/The Fool.jpg similarity index 100% rename from src/img_resource/tarot/sideTarotImages/The Fool.jpg rename to src/image/tarot/sideTarotImages/The Fool.jpg diff --git a/src/img_resource/tarot/sideTarotImages/The Lovers.jpg b/src/image/tarot/sideTarotImages/The Lovers.jpg similarity index 100% rename from src/img_resource/tarot/sideTarotImages/The Lovers.jpg rename to src/image/tarot/sideTarotImages/The Lovers.jpg diff --git a/src/img_resource/tarot/sideTarotImages/The Magician.jpg b/src/image/tarot/sideTarotImages/The Magician.jpg similarity index 100% rename from src/img_resource/tarot/sideTarotImages/The Magician.jpg rename to src/image/tarot/sideTarotImages/The Magician.jpg diff --git a/src/img_resource/tarot/sideTarotImages/The Sun.jpg b/src/image/tarot/sideTarotImages/The Sun.jpg similarity index 100% rename from src/img_resource/tarot/sideTarotImages/The Sun.jpg rename to src/image/tarot/sideTarotImages/The Sun.jpg diff --git a/src/common_plugins/cloud_music/agent.py b/src/music/cloud_music/agent.py similarity index 96% rename from src/common_plugins/cloud_music/agent.py rename to src/music/cloud_music/agent.py index 3316f29..57ee5d4 100644 --- a/src/common_plugins/cloud_music/agent.py +++ b/src/music/cloud_music/agent.py @@ -24,7 +24,7 @@ def djs(js): break return jst def getjs(): - return djs('src/common_plugins/cloud_music/jsdm.js') + return djs('src/music/cloud_music/jsdm.js') # 获取ptqrtoken def ptqrtoken(qrsign): diff --git a/src/common_plugins/cloud_music/cloud_music.py b/src/music/cloud_music/cloud_music.py similarity index 98% rename from src/common_plugins/cloud_music/cloud_music.py rename to src/music/cloud_music/cloud_music.py index b0cd441..da22aec 100644 --- a/src/common_plugins/cloud_music/cloud_music.py +++ b/src/music/cloud_music/cloud_music.py @@ -2,14 +2,12 @@ import base64 import codecs import json -import pickle from random import Random from Crypto.Cipher import AES import qrcode -import src.common_plugins.cloud_music.agent as agent +import src.music.cloud_music.agent as agent from threading import Thread -import time import requests from io import BytesIO from PIL import Image diff --git a/src/common_plugins/cloud_music/jsdm.js b/src/music/cloud_music/jsdm.js similarity index 100% rename from src/common_plugins/cloud_music/jsdm.js rename to src/music/cloud_music/jsdm.js diff --git a/src/qq_plugins/data_init/data_init.py b/src/my_sqlite/data_init/data_init.py similarity index 100% rename from src/qq_plugins/data_init/data_init.py rename to src/my_sqlite/data_init/data_init.py diff --git a/src/qq_plugins/data_init/fortune_init_data.py b/src/my_sqlite/data_init/fortune_init_data.py similarity index 100% rename from src/qq_plugins/data_init/fortune_init_data.py rename to src/my_sqlite/data_init/fortune_init_data.py diff --git a/src/qq_plugins/data_init/touch_init_data.py b/src/my_sqlite/data_init/touch_init_data.py similarity index 100% rename from src/qq_plugins/data_init/touch_init_data.py rename to src/my_sqlite/data_init/touch_init_data.py diff --git a/src/qq_plugins/fortune_by_sqlite.py b/src/my_sqlite/fortune_by_sqlite.py similarity index 67% rename from src/qq_plugins/fortune_by_sqlite.py rename to src/my_sqlite/fortune_by_sqlite.py index 37f9c74..f6d7387 100644 --- a/src/qq_plugins/fortune_by_sqlite.py +++ b/src/my_sqlite/fortune_by_sqlite.py @@ -1,45 +1,5 @@ -# 引入sqlalchemy依赖 -from pathlib import Path from sqlalchemy import Column, Integer, String, Date, create_engine, text from sqlalchemy.orm import declarative_base, sessionmaker -from nonebot.rule import to_me -from nonebot.plugin import on_command -from nonebot.adapters.qq import Message, MessageEvent, MessageSegment -from src.common_plugins.img.get_image import get_image_names, get_smms_image_url - -fortune_by_sqlite = on_command("今日运势", rule=to_me(), priority=10, block=True) -@fortune_by_sqlite.handle() -async def get_today_fortune(message: MessageEvent): - - local_image_path = get_image_names() - member_openid = message.get_user_id() - # 查询今日是否已经获取过今日运势,如果获取过则直接从日志取 - result = is_get_fortune_log(member_openid) - if result is None: - # 获取 运势说明 - result = get_fortune() - # 把抽取的今日运势插入日志 - q = QrFortuneLog() - q.fortune_summary = result.fortune_summary - q.lucky_star = result.lucky_star - q.sign_text = result.sign_text - q.un_sign_text = result.un_sign_text - q.user_id = member_openid - insert_fortune_log(q) - - content = ("\n" + "您的今日运势为:" + "\n" + - result.fortune_summary + "\n" + - result.lucky_star + "\n" + - "签文:" + result.sign_text + "\n" + - "————————————————————" + "\n" + - "解签:" + result.un_sign_text) - - msg = Message([ - MessageSegment.file_image(Path(local_image_path)), - # MessageSegment.image(url), - MessageSegment.text(content), - ]) - await fortune_by_sqlite.finish(msg) def is_get_fortune_log(member_openid): diff --git a/src/my_sqlite/touch_by_sqlite.py b/src/my_sqlite/touch_by_sqlite.py new file mode 100644 index 0000000..090fded --- /dev/null +++ b/src/my_sqlite/touch_by_sqlite.py @@ -0,0 +1,83 @@ +from sqlalchemy import Column, Integer, String, Date, create_engine, text +from sqlalchemy.orm import declarative_base, sessionmaker + + +def touch_count(member_openid): + session = SqliteSqlalchemy().session + # + result = session.execute(selectTouchCount, + {'member_openid': member_openid}).scalar() + session.close() + return result + + +def touch(status): + session = SqliteSqlalchemy().session + result = session.execute(selectTouchContent,{'status': status}).fetchone() + session.close() + return result + + +def insert_touch_log(QrTouchLog): + session = SqliteSqlalchemy().session + session.execute(insertTouchLog, + {'touch_status': QrTouchLog.touch_status, + 'reply_touch_content': QrTouchLog.reply_touch_content, + 'member_openid': QrTouchLog.user_id}) + session.commit() + session.close() + return "" + +# 申明基类对象 +Base = declarative_base() + +class QrTouch: + __tablename__ = 'qr_touch' + id = Column(Integer, primary_key=True) + touch_status = Column(Integer) + reply_touch_content = Column(String(255)) + + def __repr__(self): + return ( + "QrTouch(id:{},touch_status:{},reply_touch_content:{})" .format( + self.id, + self.touch_status, + self.reply_touch_content + )) + +class QrTouchLog: + __tablename__ = 'qr_touch_log' + id = Column(Integer, primary_key=True) + touch_status = Column(Integer) + reply_touch_content = Column(String(255)) + user_id = Column(String(255)) + extract_time = Column(Date) + + def __repr__(self): + return ( + "QrFortune(id:{},touch_status:{},reply_touch_content:{},user_id:{})" .format( + self.id, + self.touch_status, + self.reply_touch_content, + self.user_id)) + + +class SqliteSqlalchemy(object): + def __init__(self): + # 创建Sqlite连接引擎 + engine = create_engine('sqlite:///./chat_bot.db', echo=True) + # 创建Sqlite的session连接对象 + self.session = sessionmaker(bind=engine)() + + +# 查询初始化表是否存在 +selectInit = text( + "SELECT name FROM sqlite_master WHERE type='table' AND name='qr_touch';") +# 查询回复内容 +selectTouchContent = text("select * from qr_touch where touch_status = :status order by random() limit 1") +# 查询触摸次数 +selectTouchCount = text( + "select count(*) from qr_touch_log where user_id = :member_openid and extract_time = date('now')") +# 插入日志表 +insertTouchLog = text( + "insert into qr_touch_log (touch_status, reply_touch_content,user_id,extract_time) values (:touch_status, :reply_touch_content, :member_openid,date('now'))") diff --git a/src/onebot_plugins/tarot.py b/src/onebot_plugins/tarot.py index a0408d8..db71c92 100644 --- a/src/onebot_plugins/tarot.py +++ b/src/onebot_plugins/tarot.py @@ -35,22 +35,22 @@ def tarotChoice(lockTarot): if ints == 0: tarots = random.choice(tarot) txt = tarots[0] + '\n' + '正位' + '\n' + tarots[1] - img = f'src/img_resource/tarotT/TarotImages' + tarots[3] + img = f'src/image/tarotT/TarotImages' + tarots[3] img_folder = 'AbstractImages' if lockTarot else 'TarotImages' - img = f'src/img_resource/tarot/{img_folder}/{tarots[3]}' + img = f'src/image/tarot/{img_folder}/{tarots[3]}' return txt, img if ints == 1: tarots = random.choice(tarot) txt = tarots[0] + '\n' + '逆位' + '\n' + tarots[2] img_folder = 'AbstractImages' if lockTarot else 'TarotImages' - img1 = f'src/img_resource/tarot/side{img_folder}/' + tarots[3] - if not os.path.exists(f'src/img_resource/tarot/side{img_folder}'): - os.mkdir(f'src/img_resource/tarot/side{img_folder}') + img1 = f'src/image/tarot/side{img_folder}/' + tarots[3] + if not os.path.exists(f'src/image/tarot/side{img_folder}'): + os.mkdir(f'src/image/tarot/side{img_folder}') if os.path.exists(img1): return txt, img1 else: # 打开图像 - img = Image.open(f'src/img_resource/tarot/{img_folder}/{tarots[3]}') + img = Image.open(f'src/image/tarot/{img_folder}/{tarots[3]}') if img.mode == 'RGBA': img = img.convert('RGB') @@ -58,7 +58,7 @@ def tarotChoice(lockTarot): rotated_img = img.rotate(180) # 保存旋转后的图像 - rotated_img.save(f'src/img_resource/tarot/side{img_folder}/' + tarots[3]) + rotated_img.save(f'src/image/tarot/side{img_folder}/' + tarots[3]) return txt, img1 tarot = [['愚者 (The Fool)', diff --git a/src/qq_plugins/check.py b/src/qq_plugins/check.py index a6f2d49..2dbb29e 100644 --- a/src/qq_plugins/check.py +++ b/src/qq_plugins/check.py @@ -1,10 +1,10 @@ from nonebot.rule import Rule, to_me -from nonebot.adapters.qq import Message, MessageEvent, MessageSegment from nonebot import on_message +from nonebot.adapters.qq import Message from nonebot.adapters import Bot, Event -menu = ['/今日运势','/天气','/美图','/点歌','/摸摸','/今日老婆'] +menu = ['/今日运势','/天气','/图','/点歌','/摸摸头','/群老婆','/今日老婆'] async def check_value_in_menu(event: Event) -> bool: value = event.get_plaintext().strip().split(" ") if value[0] in menu: @@ -18,6 +18,3 @@ check = on_message(rule=to_me() & rule ,block=True) @check.handle() async def check(bot: Bot, event: Event): await bot.send(message=Message("是什么呢?猫猫没有识别到,喵~"+'\n'+"(๑>ڡ<)☆ 请注意命令后要加空格哦~"),event=event) - - - diff --git a/src/qq_plugins/cloudMusic.py b/src/qq_plugins/cloudMusic.py index 3ea1f89..43347a6 100644 --- a/src/qq_plugins/cloudMusic.py +++ b/src/qq_plugins/cloudMusic.py @@ -1,12 +1,10 @@ -import os import pickle +import time from pathlib import Path - -import requests from nonebot import on_command from nonebot.rule import to_me from nonebot.adapters.qq import MessageSegment,MessageEvent -from src.common_plugins.cloud_music.cloud_music import * +from src.music.cloud_music.cloud_music import * music = on_command("点歌", rule=to_me(), priority=10, block=True) @music.handle() diff --git a/src/qq_plugins/fortune.py b/src/qq_plugins/fortune.py new file mode 100644 index 0000000..be03cf1 --- /dev/null +++ b/src/qq_plugins/fortune.py @@ -0,0 +1,42 @@ +# 引入sqlalchemy依赖 +from pathlib import Path +from nonebot.rule import to_me +from nonebot.plugin import on_command +from nonebot.adapters.qq import Message, MessageEvent, MessageSegment + +from src.image.get_image import get_image_names +from src.my_sqlite.fortune_by_sqlite import is_get_fortune_log, get_fortune, QrFortuneLog, insert_fortune_log + +fortune_by_sqlite = on_command("今日运势", rule=to_me(), priority=10, block=True) +@fortune_by_sqlite.handle() +async def get_today_fortune(message: MessageEvent): + + local_image_path = get_image_names() + member_openid = message.get_user_id() + # 查询今日是否已经获取过今日运势,如果获取过则直接从日志取 + result = is_get_fortune_log(member_openid) + if result is None: + # 获取 运势说明 + result = get_fortune() + # 把抽取的今日运势插入日志 + q = QrFortuneLog() + q.fortune_summary = result.fortune_summary + q.lucky_star = result.lucky_star + q.sign_text = result.sign_text + q.un_sign_text = result.un_sign_text + q.user_id = member_openid + insert_fortune_log(q) + + content = ("\n" + "您的今日运势为:" + "\n" + + result.fortune_summary + "\n" + + result.lucky_star + "\n" + + "签文:" + result.sign_text + "\n" + + "————————————————————" + "\n" + + "解签:" + result.un_sign_text) + + msg = Message([ + MessageSegment.file_image(Path(local_image_path)), + # MessageSegment.image(url), + MessageSegment.text(content), + ]) + await fortune_by_sqlite.finish(msg) diff --git a/src/qq_plugins/image.py b/src/qq_plugins/image.py index 75f3ff6..f7f407f 100644 --- a/src/qq_plugins/image.py +++ b/src/qq_plugins/image.py @@ -1,10 +1,10 @@ -from nonebot.rule import to_me from pathlib import Path +from nonebot.rule import to_me from nonebot.plugin import on_command from nonebot.adapters.qq import MessageSegment -from src.common_plugins.img.get_image import get_image_names +from src.image.get_image import get_image_names -image = on_command("图", rule=to_me(), aliases={"图图", "美图"}, priority=10, block=True) +image = on_command("图", rule=to_me(), priority=10, block=True) @image.handle() async def handle_function(): diff --git a/src/qq_plugins/a-testMain.py b/src/qq_plugins/test/a-testMain.py similarity index 100% rename from src/qq_plugins/a-testMain.py rename to src/qq_plugins/test/a-testMain.py diff --git a/src/qq_plugins/today_wife.py b/src/qq_plugins/today_wife.py new file mode 100644 index 0000000..068ab43 --- /dev/null +++ b/src/qq_plugins/today_wife.py @@ -0,0 +1,36 @@ +from pathlib import Path +from nonebot.adapters.qq import Message, MessageEvent +from nonebot.adapters.qq import MessageSegment +from nonebot.plugin import on_command +from nonebot.rule import to_me +from src.image.get_image import download_qq_image,qq_image_delete + +today_group_wife = on_command("群老婆", rule=to_me(), priority=10, block=True) +@today_group_wife.handle() +async def handle_function(message: MessageEvent): + member_openid = message.get_user_id() + + local_image_path = download_qq_image(member_openid) + msg = Message([ + MessageSegment.file_image(Path(local_image_path)), + MessageSegment.text("@" + member_openid), + ]) + + qq_image_delete() + await today_group_wife.finish(msg) + + +today_wife = on_command("今日老婆", rule=to_me(), priority=10, block=True) +@today_wife.handle() +async def handle_function(message: MessageEvent): + member_openid = message.get_user_id() + + local_image_path = download_qq_image(member_openid) + msg = Message([ + MessageSegment.file_image(Path(local_image_path)), + ]) + + qq_image_delete() + await today_wife.finish(msg) + + diff --git a/src/qq_plugins/touch.py b/src/qq_plugins/touch.py index 746d699..322473e 100644 --- a/src/qq_plugins/touch.py +++ b/src/qq_plugins/touch.py @@ -1,12 +1,10 @@ -import os -import subprocess -from sqlalchemy import Column, Integer, String, Date, create_engine, text -from sqlalchemy.orm import declarative_base, sessionmaker from nonebot.rule import to_me from nonebot.plugin import on_command -from nonebot.adapters.qq import Message, MessageEvent, MessageSegment +from nonebot.adapters.qq import MessageEvent -to = on_command("摸摸",rule=to_me(),aliases={"摸","摸摸摸"},priority=10,block=True) +from src.my_sqlite.touch_by_sqlite import touch_count, QrTouchLog, insert_touch_log, touch + +to = on_command("摸摸头",rule=to_me(),priority=10,block=True) @to.handle() async def handle_touch(event: MessageEvent): @@ -36,83 +34,3 @@ async def handle_touch(event: MessageEvent): await to.finish(result.reply_touch_content) - -def touch_count(member_openid): - session = SqliteSqlalchemy().session - # - result = session.execute(selectTouchCount, - {'member_openid': member_openid}).scalar() - session.close() - return result - - -def touch(status): - session = SqliteSqlalchemy().session - result = session.execute(selectTouchContent,{'status': status}).fetchone() - session.close() - return result - - -def insert_touch_log(QrTouchLog): - session = SqliteSqlalchemy().session - session.execute(insertTouchLog, - {'touch_status': QrTouchLog.touch_status, - 'reply_touch_content': QrTouchLog.reply_touch_content, - 'member_openid': QrTouchLog.user_id}) - session.commit() - session.close() - return "" - -# 申明基类对象 -Base = declarative_base() - -class QrTouch: - __tablename__ = 'qr_touch' - id = Column(Integer, primary_key=True) - touch_status = Column(Integer) - reply_touch_content = Column(String(255)) - - def __repr__(self): - return ( - "QrTouch(id:{},touch_status:{},reply_touch_content:{})" .format( - self.id, - self.touch_status, - self.reply_touch_content - )) - -class QrTouchLog: - __tablename__ = 'qr_touch_log' - id = Column(Integer, primary_key=True) - touch_status = Column(Integer) - reply_touch_content = Column(String(255)) - user_id = Column(String(255)) - extract_time = Column(Date) - - def __repr__(self): - return ( - "QrFortune(id:{},touch_status:{},reply_touch_content:{},user_id:{})" .format( - self.id, - self.touch_status, - self.reply_touch_content, - self.user_id)) - - -class SqliteSqlalchemy(object): - def __init__(self): - # 创建Sqlite连接引擎 - engine = create_engine('sqlite:///./chat_bot.db', echo=True) - # 创建Sqlite的session连接对象 - self.session = sessionmaker(bind=engine)() - - -# 查询初始化表是否存在 -selectInit = text( - "SELECT name FROM sqlite_master WHERE type='table' AND name='qr_touch';") -# 查询回复内容 -selectTouchContent = text("select * from qr_touch where touch_status = :status order by random() limit 1") -# 查询触摸次数 -selectTouchCount = text( - "select count(*) from qr_touch_log where user_id = :member_openid and extract_time = date('now')") -# 插入日志表 -insertTouchLog = text( - "insert into qr_touch_log (touch_status, reply_touch_content,user_id,extract_time) values (:touch_status, :reply_touch_content, :member_openid,date('now'))")