Giter Site home page Giter Site logo

henryxiaoyang / xybot Goto Github PK

View Code? Open in Web Editor NEW
339.0 7.0 37.0 6.72 MB

XYBot是一个可运行于Linux和Windows的基于Hook的微信机器人🤖️!✅高度可自定义! ✅支持自我编写插件!非常多的功能:天气🌤️、获取新闻📰、ChatGPT聊天🗣️、Hypixel玩家查询🎮、随机图片📷、随机链接🔗、随机群成员👥、五子棋♟️、签到✅、查询积分📊、积分榜🏆、积分转送💰、积分抽奖🎁、积分红包🧧等

Home Page: https://henryxiaoyang.github.io/XYBot/

License: GNU General Public License v3.0

Python 99.27% Dockerfile 0.17% Shell 0.56%
bot docker pc wechat wechat-bot wei-xin weixin

xybot's People

Contributors

dependabot[bot] avatar henryxiaoyang avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

xybot's Issues

win端安装的出现此项错误:“由于目标计算机积极拒绝,无法连接。”,请问如何解决?

win10客户端
微信,Python安装的都是教程提供的版本

PS C:\Users\Administrator\Desktop\XYBot> python start.py
2024-07-28 23:25:31.941 | INFO | utils.database:init:37 - [数据库]检测数据库是否有正确的列
2024-07-28 23:25:31.956 | INFO | main:main:65 - 已设置日志
2024-07-28 23:25:31.966 | INFO | main:main:76 - 读取设置成功
2024-07-28 23:25:31.966 | INFO | main:main:81 - 机器人实例化成功
2024-07-28 23:25:31.966 | INFO | main:main:84 - 开始注入Hook
2024-07-28 23:25:32.687 | DEBUG | pywxdll.pywxdll:windows_start_wechat_inject_and_fix_ver:79 - 0,6536
2024-07-28 23:25:32.687 | INFO | main:main:102 - 已注入微信Hook
2024-07-28 23:25:32.687 | INFO | main:main:127 - 开始检测微信是否登陆
Traceback (most recent call last):
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\site-packages\urllib3\connection.py", line 196, in _new_conn
sock = connection.create_connection(
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\site-packages\urllib3\util\connection.py", line 85, in create_connection
raise err
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\site-packages\urllib3\util\connection.py", line 73, in create_connection
sock.connect(sa)
ConnectionRefusedError: [WinError 10061] 由于目标计算机积极拒绝,无法连接。

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\site-packages\urllib3\connectionpool.py", line 789, in urlopen
response = self._make_request(
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\site-packages\urllib3\connectionpool.py", line 495, in _make_request
conn.request(
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\site-packages\urllib3\connection.py", line 398, in request
self.endheaders()
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\http\client.py", line 1247, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\http\client.py", line 1007, in _send_output
self.send(msg)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\http\client.py", line 947, in send
self.connect()
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\site-packages\urllib3\connection.py", line 236, in connect
self.sock = self._new_conn()
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\site-packages\urllib3\connection.py", line 211, in _new_conn
raise NewConnectionError(
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x000002295C03BD30>: Failed to establish a new connection: [WinError 10061] 由于目标计算机积 极拒绝,无法连接。

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\site-packages\requests\adapters.py", line 667, in send
resp = conn.urlopen(
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\site-packages\urllib3\connectionpool.py", line 843, in urlopen
retries = retries.increment(
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\site-packages\urllib3\util\retry.py", line 519, in increment
raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type]
urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='127.0.0.1', port=19088): Max retries exceeded with url: /api/checkLogin (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x000002295C03BD30>: Failed to establish a new connection: [WinError 10061] 由于目标计算机积极拒绝,无法连接。'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "start.py", line 172, in
asyncio.run(main())
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\asyncio\runners.py", line 44, in run
return loop.run_until_complete(main)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\asyncio\base_events.py", line 616, in run_until_complete
return future.result()
File "start.py", line 128, in main
if not bot.is_logged_in():
File "C:\Users\Administrator\Desktop\XYBot\pywxdll\pywxdll.py", line 115, in is_logged_in
json_response = self.raw_is_logged_in()
File "C:\Users\Administrator\Desktop\XYBot\pywxdll\pywxdll.py", line 107, in raw_is_logged_in
response = requests.post(url, data=json_para)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\site-packages\requests\api.py", line 115, in post
return request("post", url, data=data, json=json, **kwargs)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\site-packages\requests\api.py", line 59, in request
return session.request(method=method, url=url, **kwargs)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\site-packages\requests\sessions.py", line 589, in request
resp = self.send(prep, **send_kwargs)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\site-packages\requests\sessions.py", line 703, in send
r = adapter.send(request, **kwargs)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\site-packages\requests\adapters.py", line 700, in send
raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPConnectionPool(host='127.0.0.1', port=19088): Max retries exceeded with url: /api/checkLogin (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x000002295C03BD30>: Failed to establish a new connection: [WinError 10061] 由于目标计算机积极拒绝,无法连接。'))

在已经登陆微信的情况下提示未登陆

image 感谢大佬! 在自己安装过程中和配置不一样的地方: 之前pip3 -r requirements.txt的时候报错,最终运行的pip3 install -r requirements.txt start.py之后有几个包提示import不成功,手动安装的 然后就导致了登陆不成功的效果,求解应该怎么排障,手动卸载重装下依赖的包?🙏

启动微信后打不开微信DLL注入器

windows安装,安装微信及设置版本修改后,启动微信就打不开DLL注入程序。
如果没有打开微信,DLL注入程序可以打开,试过几台机一样。

使用方法

只有输入/菜单 成功,其余它提示报错;;;群二维码已失效啊

plugins/news.yml被墙了

今天发现new插件里的https://news.ycombinator.com/被墙了,国内不能再访问了,导致插件报错,于是写了一个新的news插件:

# news.yml
keywords: [ "新闻" ]
plugin_name: "news"
news_api_key: "8ee2b469d70fdbbd99ea110ca2452602"   #申请地址:https://www.tianapi.com/console/
news_num: 50  # 新闻数量设置,最高50条
request_interval: 3600   # 请求间隔时间,单位为秒,默认1小时

# news.py
import http.client
import urllib
import json
import yaml
from loguru import logger
from utils.plugin_interface import PluginInterface
import pywxdll  
from datetime import datetime, timedelta

class news(PluginInterface):
    def __init__(self):
        # 读取插件配置
        config_path = 'plugins/news.yml'
        with open(config_path, 'r', encoding='utf-8') as f:
            config = yaml.safe_load(f.read())
        
        self.api_key = config['news_api_key']
        self.news_num = config.get('news_num', 10)  # 默认新闻数量为10
        self.request_interval = config.get('request_interval', 3600)  # 默认请求间隔为1小时
        
        # 读取主设置中的机器人IP和端口
        main_config_path = 'main_config.yml'
        with open(main_config_path, 'r', encoding='utf-8') as f:
            main_config = yaml.safe_load(f.read())

        self.ip = main_config['ip']
        self.port = main_config['port']
        self.bot = pywxdll.Pywxdll(self.ip, self.port)

        self.last_request_times = {}  # 用于记录每个群的上次请求时间
    
    async def run(self, recv):
        wxid = recv['wxid']
        current_time = datetime.now()
        
        last_request_time = self.last_request_times.get(wxid)
        if last_request_time and (current_time - last_request_time).total_seconds() < self.request_interval:
            wait_time = self.request_interval - (current_time - last_request_time).total_seconds()
            self.bot.send_txt_msg(wxid, f"️⚠️请等待 {int(wait_time // 60)} 分钟 {int(wait_time % 60)} 秒后再试。")
            return
        
        news_data = self.get_news()
        if news_data:
            messages = self.format_news(news_data)
            for message in messages:
                self.bot.send_txt_msg(wxid, message)
            self.last_request_times[wxid] = current_time
        else:
            self.bot.send_txt_msg(wxid, "⚠️无法获取新闻信息,请稍后再试。")
    
    def get_news(self):
        try:
            conn = http.client.HTTPSConnection('apis.tianapi.com')
            params = urllib.parse.urlencode({'key': self.api_key, 'num': self.news_num})
            headers = {'Content-type': 'application/x-www-form-urlencoded'}
            conn.request('POST', '/world/index', params, headers)
            response = conn.getresponse()
            result = response.read()
            data = result.decode('utf-8')
            dict_data = json.loads(data)
            
            logger.info(f"API返回的数据: {dict_data}")  # 添加日志记录返回的数据
            
            return dict_data
        except Exception as e:
            logger.error(f"⚠️获取新闻时发生错误: {e}")
            return None

    def format_news(self, news_data):
        try:
            news_list = news_data.get('result', {}).get('newslist', [])
            if not news_list:
                return ["⚠️未获取到任何新闻信息。"]

            today = datetime.now().date()
            yesterday = today - timedelta(days=1)
            filtered_news = [news for news in news_list if datetime.strptime(news.get('ctime', ''), '%Y-%m-%d %H:%M').date() in [today, yesterday]]

            formatted_news = []
            news_chunk = []
            for idx, news in enumerate(filtered_news, 1):
                title = news.get('title', '无标题')
                description = news.get('description', '无描述')
                url = news.get('url', '')
                ctime = news.get('ctime', '无时间信息')
                source = news.get('source', '无发行单位')
                news_chunk.append(f"{idx}. 📰标题: {title}\nℹ时间: {ctime}\n📺发行单位: {source}\n🔗链接: {url}\n\n")
                
                if idx % 10 == 0 or idx == len(filtered_news):
                    formatted_news.append("".join(news_chunk))
                    news_chunk = []

            return formatted_news
        except Exception as e:
            logger.error(f"⚠️格式化新闻时发生错误: {e}")
            return ["⚠️新闻数据格式化错误。"]

用了两周发现的一些bug

  1. 有时候微信弹更新窗的时候会卡死,微信会掉出去,需要kill微信或者重启pod, 不知道能不能屏蔽掉提醒更新的弹窗
  2. 查询积分没有针对群组隔离
  3. 数据库没用户的时候第一次签到有概率没反应

积分功能Bug

大Bug

签到时每个人有了两次机会,查询积分是会出来两个账号。(?)
具体bug内容如下
截屏2023-11-13 18 29 57
截屏2023-11-13 18 28 01

被封了

华为云 windows server 最新代码
image

查找一个时区出错,不能签到

'No time zone found with key Asia/Shanghai'

电脑自身时区设置没有问题,同时写了脚本发现依赖也没有问题,不知道怎么改
(时区检测脚本)
from dateutil import tz
from datetime import datetime

def test_timezone(timezone_str):
try:
timezone = tz.gettz(timezone_str)
datetime.now(timezone)
print(f"时区 {timezone_str} 设置成功。当前时间:{datetime.now(timezone)}")
except Exception as e:
print(f"设置时区出错:{e}")

if name == "main":
test_timezone("Asia/Shanghai")

运行下载的微信低版本提示修复 wechat_launcher_bypass_ver_check.exe 运行失败

如图所示:
此应用无法在你的电脑上运行
着要规到适用于你的电脑的版本,请咨询软件发布者

bcd935e0551405eb62f3e741d23d1a6

设备信息:
设备名称 N100
处理器 Intel(R) N100 800 MHz
机带 RAM 8.00 GB (7.75 GB 可用)
设备 ID 35FF02D0-XXXXX-XXXXX-XXXXX-XXXXXXXXXXXXXXX
产品 ID 00329-XXXXX-XXXXX-XXXXX
系统类型 64 位操作系统, 基于 x64 的处理器
笔和触控 没有可用于此显示器的笔或触控输入

版本 Windows 11 企业版
版本 23H2
安装日期 ‎2024/‎2/‎27
操作系统版本 22631.3593
体验 Windows Feature Experience Pack 1000.22700.1003.0

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.