Skip to content

Commit

Permalink
Merge pull request #92 from HenryXiaoYang/dev
Browse files Browse the repository at this point in the history
v2.2.0
  • Loading branch information
HenryXiaoYang authored Dec 7, 2024
2 parents 8399fb7 + 639e386 commit c4e993a
Show file tree
Hide file tree
Showing 22 changed files with 428 additions and 66 deletions.
6 changes: 3 additions & 3 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# XYBot 微信机器人

<p align="center">
<img alt="XYBot微信机器人logo" width="240" src="https://github.com/HenryXiaoYang/HXY_Readme_Images/blob/main/XYBot/v0.0.7/logo/xybot_logo.png?raw=true">
<img alt="XYBot微信机器人logo" width="240" src="https://github.com/HenryXiaoYang/HXY_Readme_Images/blob/main/XYBot/logo/xybot_logo.png?raw=true">
</p>

XYBot是一个可运行于Linux和Windows的基于Hook的微信机器人。😊 具有高度可自定义性,支持自我编写插件。🚀
Expand All @@ -21,7 +21,7 @@ XYBot详细的部署教程可以在项目的Wiki中找到。📚 同时,XYBot

<p align="center">
<a href="https://opensource.org/licenses/"><img src="https://img.shields.io/badge/License-GPL%20v3-red.svg" alt="GPLv3 License"></a>
<a href="https://github.com/HenryXiaoYang/XYBot"><img src="https://img.shields.io/badge/Version-2.0.0-orange.svg" alt="Version"></a>
<a href="https://github.com/HenryXiaoYang/XYBot"><img src="https://img.shields.io/badge/Version-2.2.0-orange.svg" alt="Version"></a>
<a href="https://yangres.com"><img src="https://img.shields.io/badge/Blog-@HenryXiaoYang-yellow.svg" alt="Blog"></a>
</p>

Expand Down Expand Up @@ -151,7 +151,7 @@ python start.py

#### 用的什么微信版本?🤔️

3.9.10.27😄
3.9.11.25😄

#### 最长能运行多久?🤔️

Expand Down
Binary file modified docs/xybot_logo_32x32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions docs/zh-cn/XYBot功能介绍.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# 本文档已过期

# XYBot功能介绍

这一页介绍了所有官方XYBot微信机器人用户可使用的功能、命令。
Expand Down
2 changes: 2 additions & 0 deletions docs/zh-cn/XYBot插件编写.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# 本文档已过期

# XYBot插件编写

这一页讲述了如何编写一个XYBot插件
Expand Down
8 changes: 4 additions & 4 deletions docs/zh-cn/XYBot的设置.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

这一页写了如何设置XYBot。

本篇适用于`XYBot v2.0.0`
本篇适用于`XYBot v2.2.0`

## 配置主设置

这是`XYBot v2.0.0`的主设置:
这是`XYBot v2.2.0`的主设置:

```yaml
#Version v2.0.0
bot_version: "v2.0.0"
#Version v2.2.0
bot_version: "v2.2.0"

# XYBot主设置

Expand Down
2 changes: 1 addition & 1 deletion docs/zh-cn/_coverpage.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
![logo](https://github.com/HenryXiaoYang/HXY_Readme_Images/blob/main/XYBot/v0.0.7/logo/xybot_logo_small.png?raw=true)
![logo](https://github.com/HenryXiaoYang/HXY_Readme_Images/blob/main/XYBot/logo/xybot_logo_medium.png?raw=true)

# XYBot <small>v2.0.0</small>

Expand Down
4 changes: 2 additions & 2 deletions main_config.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#Version v2.0.0
bot_version: "v2.0.0"
#Version v2.2.0
bot_version: "v2.2.0"

# XYBot主设置

Expand Down
1 change: 1 addition & 0 deletions plugins/command/bot_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,4 @@ async def run(self, bot: client.Wcf, recv: XYBotWxMsg):
out_message = f"-----XYBot-----\n{self.status_message}\nBot version: {self.bot_version}\n{base64.b64decode(a).decode('utf-8')}"
logger.info(f'[发送信息]{out_message}| [发送到] {recv.roomid}')
bot.send_text(out_message, recv.roomid) # 发送
bot.send_pat_msg(recv.roomid, recv.sender) # 发送拍一拍消息
1 change: 1 addition & 0 deletions plugins/command/dalle3.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ async def run(self, bot: client.Wcf, recv: XYBotWxMsg):
if user_wxid not in self.admins and self.db.get_whitelist(user_wxid) == 0: # 如果用户不是管理员或者白名单,扣积分
self.db.add_points(user_wxid, -self.price)
await self.send_friend_or_group(bot, recv, f"-----XYBot-----\n🎉图片生成完毕,已扣除 {self.price} 点积分!🙏")
bot.send_pat_msg(recv.roomid, user_wxid) # 拍一拍

bot.send_image(image_path, recv.roomid)
logger.info(f'[发送图片]{image_path}| [发送到] {recv.roomid}')
Expand Down
1 change: 1 addition & 0 deletions plugins/command/lucky_draw.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ async def run(self, bot: client.Wcf, recv: XYBotWxMsg):
) # 组建信息

await self.send_friend_or_group(bot, recv, message) # 发送
bot.send_pat_msg(recv.roomid, target_wxid) # 发送拍一拍消息

else:
await self.send_friend_or_group(bot, recv, error) # 发送错误
Expand Down
1 change: 1 addition & 0 deletions plugins/command/points_trade.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ async def run(self, bot: client.Wcf, recv: XYBotWxMsg):
self.db.safe_trade_points(trader_wxid, target_wxid, points_num)
# 记录日志和发送成功信息
await self.log_and_send_success_message(bot, roomid, trader_wxid, target_wxid, points_num)
bot.send_pat_msg(roomid, target_wxid)
else:
await self.log_and_send_error_message(bot, roomid, trader_wxid, error_message) # 记录日志和发送错误信息
else:
Expand Down
1 change: 1 addition & 0 deletions plugins/command/random_picture.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ async def run(self, bot: client.Wcf, recv: XYBotWxMsg):

logger.info(f'[发送信息](随机图图图片) {cache_path}| [发送到] {recv.roomid}')
bot.send_image(os.path.abspath(cache_path), recv.roomid) # 发送图片
bot.send_pat_msg(recv.roomid, recv.sender) # 发送拍一拍消息

except Exception as error:
out_message = f"-----XYBot-----\n出现错误❌!{error}"
Expand Down
46 changes: 0 additions & 46 deletions plugins/command/random_picture_link.py

This file was deleted.

6 changes: 0 additions & 6 deletions plugins/command/random_picture_link.yml

This file was deleted.

3 changes: 2 additions & 1 deletion plugins/command/red_packet.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ async def grab_red_packet(self, bot: client.Wcf, recv: XYBotWxMsg):
error = "-----XYBot-----\n❌红包只能在群里抢!"
elif red_packet_grabber in self.red_packets[req_captcha]["grabbed"]:
error = "-----XYBot-----\n⚠️你已经抢过这个红包了!"
elif self.red_packets[req_captcha].sender == red_packet_grabber:
elif self.red_packets[req_captcha]["sender"] == red_packet_grabber:
error = "-----XYBot-----\n❌不能抢自己的红包!"

if not error:
Expand All @@ -156,6 +156,7 @@ async def grab_red_packet(self, bot: client.Wcf, recv: XYBotWxMsg):
# 组建信息
out_message = f"-----XYBot-----\n🧧恭喜 {red_packet_grabber_nick} 抢到了 {grabbed_points} 点积分!"
await self.send_friend_or_group(bot, recv, out_message)
bot.send_pat_msg(recv.roomid, red_packet_grabber) # 发送拍一拍消息

# 判断是否抢完
if not self.red_packets[req_captcha]["list"]:
Expand Down
3 changes: 3 additions & 0 deletions plugins/command/sign_in.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ async def run(self, bot: client.Wcf, recv: XYBotWxMsg):
logger.info(f"[发送@信息]{out_message}| [发送到] {recv.roomid}")
bot.send_text(out_message, recv.roomid, sign_wxid)

bot.send_pat_msg(recv.roomid, sign_wxid)
logger.info(f"[发送拍一拍] 拍了拍: {sign_wxid} | 发送到: {recv.roomid}")

def signstat_check(self, signstat): # 检查签到状态
signstat = "20000101" if signstat in ["0", "1"] else signstat
last_sign_date = datetime.strptime(signstat, "%Y%m%d").date()
Expand Down
34 changes: 34 additions & 0 deletions plugins/join_group/join_notification.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Copyright (c) 2024. Henry Yang
#
# This program is licensed under the GNU General Public License v3.0.
import os
import re

from loguru import logger
from wcferry import client

from utils.plugin_interface import PluginInterface
from wcferry_helper import XYBotWxMsg


class join_notification(PluginInterface):
def __init__(self):
self.logo_path = os.path.abspath("resources/XYBotLogo.png")

async def run(self, bot: client.Wcf, recv: XYBotWxMsg):
join_group_msg = recv.content

# 邀请进来的
if "邀请" in join_group_msg:
# 通过正则表达式提取邀请者的名字
invite_pattern = r'"([^"]+)"邀请"([^"]+)"加入了群聊'
match = re.search(invite_pattern, join_group_msg)

if match:
joiner = match.group(2)
await self.send_welcome(bot, recv.roomid, joiner)

async def send_welcome(self, bot: client.Wcf, roomid: str, joiner: str):
out_message = f"-------- XYBot ---------\n👏欢迎新成员 {joiner} 加入本群!⭐️\n⚙️输入 菜单 获取玩法哦😄"
logger.info(f'[发送信息]{out_message}| [发送到] {roomid}')
bot.send_text(out_message, roomid)
Loading

0 comments on commit c4e993a

Please sign in to comment.