{"id":13467711,"url":"https://github.com/why2lyj/ItChat-UOS","last_synced_at":"2025-03-26T03:30:57.584Z","repository":{"id":45511953,"uuid":"379106798","full_name":"why2lyj/ItChat-UOS","owner":"why2lyj","description":"复活Itchat,你只需要 pip install itchat-uos","archived":false,"fork":true,"pushed_at":"2023-02-10T01:51:28.000Z","size":1022,"stargazers_count":748,"open_issues_count":21,"forks_count":151,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-03-03T03:04:56.935Z","etag":null,"topics":["itchat","wechat"],"latest_commit_sha":null,"homepage":"http://itchat.readthedocs.io","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"littlecodersh/ItChat","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/why2lyj.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-06-22T01:24:37.000Z","updated_at":"2025-02-21T10:58:54.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/why2lyj/ItChat-UOS","commit_stats":null,"previous_names":[],"tags_count":34,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/why2lyj%2FItChat-UOS","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/why2lyj%2FItChat-UOS/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/why2lyj%2FItChat-UOS/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/why2lyj%2FItChat-UOS/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/why2lyj","download_url":"https://codeload.github.com/why2lyj/ItChat-UOS/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245584595,"owners_count":20639582,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["itchat","wechat"],"created_at":"2024-07-31T15:00:59.647Z","updated_at":"2025-03-26T03:30:57.117Z","avatar_url":"https://github.com/why2lyj.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"# itchat-uos\r\n\r\n[![itchat_vesion](https://img.shields.io/badge/itchat--uos-1.4.1-green)](https://github.com/why2lyj/ItChat-UOS)\r\n[![Downloads](https://pepy.tech/badge/itchat-uos)](https://pepy.tech/project/itchat-uos)\r\n\r\n2017年后，新注册的微信基本登录不了网页版，itchat-uos版本利用统信UOS的网页版微信，可以让你绕过网页微信的登录限制。\r\n\r\n你只需要执行下条命令便能复活Itchat\r\n\r\n```python \r\npip install itchat-uos==1.5.0.dev0\r\n```\r\n\r\n祝各位好运 —— By Snow\r\n\r\n### 更新 - 2023/02/10\r\n\r\n目前使用 `1.5.0.dev0` 大多数使用者可能出现微信被官方封禁提醒，从已知收集的封禁情况，暂未有可解决方案。\r\n\r\n猜测可能与近期ChatGPT结合本仓库实现个性化机器人导致相关封禁，请合理，谨慎使用本仓库。\r\n\r\n\r\n# itchat\r\n\r\n[![Gitter][gitter-picture]][gitter] ![py27][py27] ![py35][py35] [English version][english-version]\r\n\r\nitchat是一个开源的微信个人号接口，使用python调用微信从未如此简单。\r\n\r\n使用不到三十行的代码，你就可以完成一个能够处理所有信息的微信机器人。\r\n\r\n当然，该api的使用远不止一个机器人，更多的功能等着你来发现，比如[这些][tutorial2]。\r\n\r\n该接口与公众号接口[itchatmp][itchatmp]共享类似的操作方式，学习一次掌握两个工具。\r\n\r\n如今微信已经成为了个人社交的很大一部分，希望这个项目能够帮助你扩展你的个人的微信号、方便自己的生活。\r\n\r\n## 安装\r\n\r\n可以通过本命令安装itchat：\r\n\r\n```python\r\npip install itchat-uos\r\n```\r\n\r\n## 简单入门实例\r\n\r\n有了itchat，如果你想要给文件传输助手发一条信息，只需要这样：\r\n\r\n```python\r\nimport itchat\r\n\r\nitchat.auto_login()\r\n\r\nitchat.send('Hello, filehelper', toUserName='filehelper')\r\n```\r\n\r\n如果你想要回复发给自己的文本消息，只需要这样：\r\n\r\n```python\r\nimport itchat\r\n\r\n@itchat.msg_register(itchat.content.TEXT)\r\ndef text_reply(msg):\r\n    return msg.text\r\n\r\nitchat.auto_login()\r\nitchat.run()\r\n```\r\n\r\n一些进阶应用可以在下面的开源机器人的源码和进阶应用中看到，或者你也可以阅览[文档][document]。\r\n\r\n## 试一试\r\n\r\n这是一个基于这一项目的[开源小机器人][robot-source-code]，百闻不如一见，有兴趣可以尝试一下。\r\n\r\n由于好友数量实在增长过快，自动通过好友验证的功能演示暂时关闭。\r\n\r\n![QRCode][robot-qr]\r\n\r\n## 截屏\r\n\r\n![file-autoreply][robot-demo-file] ![login-page][robot-demo-login]\r\n\r\n## 进阶应用\r\n\r\n### 特殊的字典使用方式\r\n\r\n通过打印itchat的用户以及注册消息的参数，可以发现这些值都是字典。\r\n\r\n但实际上itchat精心构造了相应的消息、用户、群聊、公众号类。\r\n\r\n其所有的键值都可以通过这一方式访问：\r\n\r\n```python\r\n@itchat.msg_register(TEXT)\r\ndef _(msg):\r\n    # equals to print(msg['FromUserName'])\r\n    print(msg.fromUserName)\r\n```\r\n\r\n属性名为键值首字母小写后的内容。\r\n\r\n```python\r\nauthor = itchat.search_friends(nickName='LittleCoder')[0]\r\nauthor.send('greeting, littlecoder!')\r\n```\r\n\r\n### 各类型消息的注册\r\n\r\n通过如下代码，微信已经可以就日常的各种信息进行获取与回复。\r\n\r\n```python\r\nimport itchat, time\r\nfrom itchat.content import *\r\n\r\n@itchat.msg_register([TEXT, MAP, CARD, NOTE, SHARING])\r\ndef text_reply(msg):\r\n    msg.user.send('%s: %s' % (msg.type, msg.text))\r\n\r\n@itchat.msg_register([PICTURE, RECORDING, ATTACHMENT, VIDEO])\r\ndef download_files(msg):\r\n    msg.download(msg.fileName)\r\n    typeSymbol = {\r\n        PICTURE: 'img',\r\n        VIDEO: 'vid', }.get(msg.type, 'fil')\r\n    return '@%s@%s' % (typeSymbol, msg.fileName)\r\n\r\n@itchat.msg_register(FRIENDS)\r\ndef add_friend(msg):\r\n    msg.user.verify()\r\n    msg.user.send('Nice to meet you!')\r\n\r\n@itchat.msg_register(TEXT, isGroupChat=True)\r\ndef text_reply(msg):\r\n    if msg.isAt:\r\n        msg.user.send(u'@%s\\u2005I received: %s' % (\r\n            msg.actualNickName, msg.text))\r\n\r\nitchat.auto_login(True)\r\nitchat.run(True)\r\n```\r\n\r\n### 命令行二维码\r\n\r\n通过以下命令可以在登陆的时候使用命令行显示二维码：\r\n\r\n```python\r\nitchat.auto_login(enableCmdQR=True)\r\n```\r\n\r\n部分系统可能字幅宽度有出入，可以通过将enableCmdQR赋值为特定的倍数进行调整：\r\n\r\n```python\r\n# 如部分的linux系统，块字符的宽度为一个字符（正常应为两字符），故赋值为2\r\nitchat.auto_login(enableCmdQR=2)\r\n```\r\n\r\n默认控制台背景色为暗色（黑色），若背景色为浅色（白色），可以将enableCmdQR赋值为负值：\r\n\r\n```python\r\nitchat.auto_login(enableCmdQR=-1)\r\n```\r\n\r\n### 退出程序后暂存登陆状态\r\n\r\n通过如下命令登陆，即使程序关闭，一定时间内重新开启也可以不用重新扫码。\r\n\r\n```python\r\nitchat.auto_login(hotReload=True)\r\n```\r\n\r\n### 用户搜索\r\n\r\n使用`search_friends`方法可以搜索用户，有四种搜索方式：\r\n1. 仅获取自己的用户信息\r\n2. 获取特定`UserName`的用户信息\r\n3. 获取备注、微信号、昵称中的任何一项等于`name`键值的用户\r\n4. 获取备注、微信号、昵称分别等于相应键值的用户\r\n\r\n其中三、四项可以一同使用，下面是示例程序：\r\n\r\n```python\r\n# 获取自己的用户信息，返回自己的属性字典\r\nitchat.search_friends()\r\n# 获取特定UserName的用户信息\r\nitchat.search_friends(userName='@abcdefg1234567')\r\n# 获取任何一项等于name键值的用户\r\nitchat.search_friends(name='littlecodersh')\r\n# 获取分别对应相应键值的用户\r\nitchat.search_friends(wechatAccount='littlecodersh')\r\n# 三、四项功能可以一同使用\r\nitchat.search_friends(name='LittleCoder机器人', wechatAccount='littlecodersh')\r\n```\r\n\r\n关于公众号、群聊的获取与搜索在文档中有更加详细的介绍。\r\n\r\n### 附件的下载与发送\r\n\r\nitchat的附件下载方法存储在msg的Text键中。\r\n\r\n发送的文件的文件名（图片给出的默认文件名）都存储在msg的FileName键中。\r\n\r\n下载方法接受一个可用的位置参数（包括文件名），并将文件相应的存储。\r\n\r\n```python\r\n@itchat.msg_register([PICTURE, RECORDING, ATTACHMENT, VIDEO])\r\ndef download_files(msg):\r\n    msg.download(msg.fileName)\r\n    itchat.send('@%s@%s' % (\r\n        'img' if msg['Type'] == 'Picture' else 'fil', msg['FileName']),\r\n        msg['FromUserName'])\r\n    return '%s received' % msg['Type']\r\n```\r\n\r\n如果你不需要下载到本地，仅想要读取二进制串进行进一步处理可以不传入参数，方法将会返回图片的二进制串。\r\n\r\n```python\r\n@itchat.msg_register([PICTURE, RECORDING, ATTACHMENT, VIDEO])\r\ndef download_files(msg):\r\n    with open(msg.fileName, 'wb') as f:\r\n        f.write(msg.download())\r\n```\r\n\r\n### 用户多开\r\n\r\n使用如下命令可以完成多开的操作：\r\n\r\n```python\r\nimport itchat\r\n\r\nnewInstance = itchat.new_instance()\r\nnewInstance.auto_login(hotReload=True, statusStorageDir='newInstance.pkl')\r\n\r\n@newInstance.msg_register(itchat.content.TEXT)\r\ndef reply(msg):\r\n    return msg.text\r\n\r\nnewInstance.run()\r\n```\r\n\r\n### 退出及登陆完成后调用特定方法\r\n\r\n登陆完成后的方法需要赋值在`loginCallback`中。\r\n\r\n而退出后的方法需要赋值在`exitCallback`中。\r\n\r\n```python\r\nimport time\r\n\r\nimport itchat\r\n\r\ndef lc():\r\n    print('finish login')\r\ndef ec():\r\n    print('exit')\r\n\r\nitchat.auto_login(loginCallback=lc, exitCallback=ec)\r\ntime.sleep(3)\r\nitchat.logout()\r\n```\r\n\r\n若不设置loginCallback的值，则将会自动删除二维码图片并清空命令行显示。\r\n\r\n## 常见问题与解答\r\n\r\nQ: 如何通过这个包将自己的微信号变为控制器？\r\n\r\nA: 有两种方式：发送、接受自己UserName的消息；发送接收文件传输助手（filehelper）的消息\r\n\r\nQ: 为什么我发送信息的时候部分信息没有成功发出来？\r\n\r\nA: 有些账号是天生无法给自己的账号发送信息的，建议使用`filehelper`代替。\r\n\r\n## 作者\r\n\r\n[LittleCoder][littlecodersh]: 构架及维护Python2 Python3版本。\r\n\r\n[tempdban][tempdban]: 协议、构架及日常维护。\r\n\r\n[Chyroc][Chyroc]: 完成第一版本的Python3构架。\r\n\r\n## 类似项目\r\n\r\n[youfou/wxpy][youfou-wxpy]: 优秀的api包装和配套插件，微信机器人/优雅的微信个人号API\r\n\r\n[liuwons/wxBot][liuwons-wxBot]: 类似的基于Python的微信机器人\r\n\r\n[zixia/wechaty][zixia-wechaty]: 基于Javascript(ES6)的微信个人账号机器人NodeJS框架/库\r\n\r\n[sjdy521/Mojo-Weixin][Mojo-Weixin]: 使用Perl语言编写的微信客户端框架，可通过插件提供基于HTTP协议的api接口供其他语言调用\r\n\r\n[HanSon/vbot][HanSon-vbot]: 基于PHP7的微信个人号机器人，通过实现匿名函数可以方便地实现各种自定义的功能\r\n\r\n[yaphone/itchat4j][yaphone-itchat4j]: 用Java扩展个人微信号的能力\r\n\r\n[kanjielu/jeeves][kanjielu-jeeves]: 使用springboot开发的微信机器人\r\n\r\n## 问题和建议\r\n\r\n如果有什么问题或者建议都可以在这个[Issue][issue#1]和我讨论\r\n\r\n或者也可以在gitter上交流：[![Gitter][gitter-picture]][gitter]\r\n\r\n当然也可以加入我们新建的QQ群讨论：549762872, 205872856\r\n\r\n[gitter-picture]: https://badges.gitter.im/littlecodersh/ItChat.svg\r\n[gitter]: https://gitter.im/littlecodersh/ItChat?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge\r\n[py27]: https://img.shields.io/badge/python-2.7-ff69b4.svg\r\n[py35]: https://img.shields.io/badge/python-3.5-red.svg\r\n[english-version]: https://github.com/littlecodersh/ItChat/blob/master/README_EN.md\r\n[itchatmp]: https://github.com/littlecodersh/itchatmp\r\n[document]: https://itchat.readthedocs.org/zh/latest/\r\n[tutorial2]: http://python.jobbole.com/86532/\r\n[robot-source-code]: https://gist.github.com/littlecodersh/ec8ddab12364323c97d4e36459174f0d\r\n[robot-qr]: http://7xrip4.com1.z0.glb.clouddn.com/ItChat%2FQRCode2.jpg?imageView/2/w/400/\r\n[robot-demo-file]: http://7xrip4.com1.z0.glb.clouddn.com/ItChat%2FScreenshots%2F%E5%BE%AE%E4%BF%A1%E8%8E%B7%E5%8F%96%E6%96%87%E4%BB%B6%E5%9B%BE%E7%89%87.png?imageView/2/w/300/\r\n[robot-demo-login]: http://7xrip4.com1.z0.glb.clouddn.com/ItChat%2FScreenshots%2F%E7%99%BB%E5%BD%95%E7%95%8C%E9%9D%A2%E6%88%AA%E5%9B%BE.jpg?imageView/2/w/450/\r\n[littlecodersh]: https://github.com/littlecodersh\r\n[tempdban]: https://github.com/tempdban\r\n[Chyroc]: https://github.com/Chyroc\r\n[youfou-wxpy]: https://github.com/youfou/wxpy\r\n[liuwons-wxBot]: https://github.com/liuwons/wxBot\r\n[zixia-wechaty]: https://github.com/zixia/wechaty\r\n[Mojo-Weixin]: https://github.com/sjdy521/Mojo-Weixin\r\n[HanSon-vbot]: https://github.com/hanson/vbot\r\n[yaphone-itchat4j]: https://github.com/yaphone/itchat4j\r\n[kanjielu-jeeves]: https://github.com/kanjielu/jeeves\r\n[issue#1]: https://github.com/littlecodersh/ItChat/issues/1\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwhy2lyj%2FItChat-UOS","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwhy2lyj%2FItChat-UOS","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwhy2lyj%2FItChat-UOS/lists"}