Giter Site home page Giter Site logo

wxpy's Issues

貌似有内存泄漏

我开了5个微信,内存从开始的 110M,逐渐增长到 230M,而且还在持续增长,请问怎么解决

添加好友报错

接收用户消息,然后添加好友的时候报错

Fri, 28 Apr 2017 11:56:45 bot.py[line:330] ERROR
An error occurred in <function print_others at 0x7f6ea15c4730>.
Traceback (most recent call last):
File "/opt/python35/lib/python3.5/site-packages/wxpy/api/bot.py", line 326, in process
ret = config.func(msg)
File "ttsbot-prod.py", line 36, in print_others
bot.accept_friend(msg.chat)
File "/opt/python35/lib/python3.5/site-packages/wxpy/api/bot.py", line 253, in accept_friend
do()
File "/opt/python35/lib/python3.5/site-packages/wxpy/utils/misc.py", line 59, in wrapped
smart_map(check_response_body, ret)
File "/opt/python35/lib/python3.5/site-packages/wxpy/utils/misc.py", line 178, in smart_map
return func(i, *args, **kwargs)
File "/opt/python35/lib/python3.5/site-packages/wxpy/utils/misc.py", line 25, in check_response_body
raise ResponseError('ret: {}; err_msg: {}'.format(ret, err_msg))
wxpy.exceptions.ResponseError: ret: -1; err_msg:

创建群组出错

from wxpy import *
bot=Bot()
bot.create_group(['ken06o',],'hello')
-------------------------------------------错误代码----------------------------------------------
Traceback (most recent call last):
File "D:/app/math/add_friend.py", line 3, in
bot.create_group(['ken06o',],'hello')
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python35\lib\site-packages\wxpy\api\bot.py", line 365, in create_group
raise Exception('Failed to create group:\n{}'.format(pformat(ret)))
Exception: Failed to create group:
{'BaseResponse': {'ErrMsg': '请求成功',
'RawMsg': '\n'
'1\n'
'\n'
'\n'
'30\n'
'<Title></Title>\n'
'4\n'
'0\n'
'0\n'
'\n'
'\n'
'\n',
'Ret': 0},
'BlackList': '',
'ChatRoomName': '',
'MemberCount': 0,
'MemberList': [],
'PYInitial': '',
'QuanPin': '',
'Topic': ''}

进程已结束,退出代码1

how to use wxid to add friends

hi
老哥, 看到你commit了一个新功能,是add friend by wxid
请问一下 这个是怎么用呢。貌似没有文档出来.......

公众号类消息只能获得多图文的头条内容

目前对于公众号类消息可以用Sharing来捕获,但是似乎仅限于单图文的。

如果对方发布的是多图文格式的,只能获得第一条的所有信息,而第二条及随后的所有信息全部被忽略。

不知道能否将多图文的信息转变为一个列表,这样可以逐一查看各自的内容。

消息不知道突然乱发了

今天进到服务器里看了一下,发现控制台没反应,我按了几次回车之后,消息突然乱发了,本来只有个人聊天的监听返回的消息发到群里,公众号里,只发了最近的几个有使用的。不知道是什么原因,我重启了服务,后面如果有的话我把报错的发出来。

卡在登录后二维码那步了

大虾,首先为你创造了这么nb的项目点个赞哈……👍

然后我有个问题求教,就是登录之后返回验证码的问题

关于这个问题我尝试了以下两种方案

=================================================
1.控制台输出二维码,二维码太长了,超出屏幕了,分辨率也太低了,根本不行

2.保存二维码到指定路径,根本保存不出来,我去看了下二维码相关的代码,好像也没有保存逻辑呢

依然还是内存泄漏的问题

发送或者接收到消息后内存会增长,但是把 bot 对象销毁后,内存并没有得到释放,请问该如何处理

部分消息的 .text 为 None

Traceback (most recent call last):
File "/path/lib/python3.5/site-packages/wxpy/api/bot.py", line 295, in process
ret = config.func(msg)
File "wxbot.py", line 23, in reply_pt_kill
if 'pt' in msg.text and 'kill' in msg.text:
TypeError: argument of type 'NoneType' is not iterable

邀请入群

为什么没办法使用group的add_members和remove_members方法了。。里面username传微信昵称和微信号都不行。

报错是因为Bot被检测到?

我写了一个script,主要用来给微信群转发消息,还在测试,没有大规模用,但是log里总会有这样的报错,搜了一下有可能是被检测到是bot,所以没有正常response
http://stackoverflow.com/questions/33174804/python-requests-getting-connection-aborted-badstatusline-error
报错如下:
2017-05-13 19:59:50,616 requests.packages.urllib3.connectionpool WARNING Retrying (Retry(total=25, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', BadStatusLine('HTTP/1.1 0 -\r\n',))': /cgi-bin/mmwebwx-bin/synccheck?r=1494730776694&uin=342550695&skey=%40crypt_7a4288b7_8f6a503d952a2c85501b30509eefc69d&synckey=1_667084299%7C2_667084546%7C3_667084299%7C11_667084539%7C13_667084299%7C201_1494730774%7C203_1494730575%7C1000_1494723422%7C1001_1494723452%7C1004_1494344568&_=1494730776694&deviceid=e134616960240798&sid=sueBQ3Xfey7vC3co
你能确认是因为被检测到bot了吗?有什么办法吗?谢谢!

Unable get media_id

尝试发送图片消息的时候拿不到media_id , 尝试了forward 方法 , 是正常起作用的,但这个方法没法持久化的起作用,就还挺不方便的

Message are sent out successfully but then raise exeception "KeyError: 'self'"

Using python3.5, and in Linux ENV.

In [43]: my_wife.send("test")
Out[43]: <ItchatReturnValue: {'MsgID': '8287475435897459665', 'LocalID': '14904491571103', 'BaseResponse': {'RawMsg': '请求成功', 'Ret': 0, 'ErrMsg': '请求成功'}}>

In [44]: Traceback (most recent call last):
File "/home/mint/.local/lib/python3.5/site-packages/itchat/components/login.py", line 240, in maintain_loop
msgList = produce_msg(self, msgList)
File "/home/mint/.local/lib/python3.5/site-packages/itchat/components/messages.py", line 61, in produce_msg
produce_group_chat(core, m)
File "/home/mint/.local/lib/python3.5/site-packages/itchat/components/messages.py", line 250, in produce_group_chat
atFlag = '@' + (chatroom['self']['DisplayName']
KeyError: 'self'

获取二维码时出现 FileNotFoundError: [Errno 2] No such file or directory: 'xdg-open'

大大您好,我今天在自己的服务器上尝试配置wxpy,做到第二步获取二维码时报错,
机器是ubuntu14.04 root用户登陆
屏幕输出如下

>>> robot = Robot()
Getting uuid of QR code.
Downloading QR code.
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.4/dist-packages/wxpy/wx.py", line 1024, in __init__
    loginCallback=login_callback, exitCallback=logout_callback
  File "/usr/local/lib/python3.4/dist-packages/itchat/components/register.py", line 35, in auto_login
    loginCallback=loginCallback, exitCallback=exitCallback)
  File "/usr/local/lib/python3.4/dist-packages/itchat/components/login.py", line 39, in login
    picDir=picDir, qrCallback=qrCallback)
  File "/usr/local/lib/python3.4/dist-packages/itchat/components/login.py", line 96, in get_QR
    utils.print_qr(picDir)
  File "/usr/local/lib/python3.4/dist-packages/itchat/utils.py", line 82, in print_qr
    subprocess.call(['xdg-open', fileDir])
  File "/usr/lib/python3.4/subprocess.py", line 537, in call
    with Popen(*popenargs, **kwargs) as p:
  File "/usr/lib/python3.4/subprocess.py", line 859, in __init__
    restore_signals, start_new_session)
  File "/usr/lib/python3.4/subprocess.py", line 1457, in _execute_child
    raise child_exception_type(errno_num, err_msg)
FileNotFoundError: [Errno 2] No such file or directory: 'xdg-open'

请问是我遗漏了什么步骤吗

Message.reply_raw_msg(...)报错

试用文档中的例子:
@bot.register(msg_types=CARD) def reply_text(msg): msg.chat.send_raw_msg(msg.raw['MsgType'], msg.raw['Content'])
报错信息如下:

2017-05-02 23:23:07,260 root CRITICAL UNCAUGHT EXCEPTION:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/code.py", line 91, in runcode
exec(code, self.locals)
File "", line 1, in
File "/Users/rxu/dev/wxpy-master/wxpy/api/chats/chat.py", line 29, in wrapped
kwargs_, attrs_ = func(self, *args, **kwargs)
File "/Users/rxu/dev/wxpy-master/wxpy/api/chats/chat.py", line 229, in send_raw_msg
req = BaseRequest(self.bot, uri=uri)
File "/Users/rxu/dev/wxpy-master/wxpy/utils/base_request.py", line 25, in init
self.url = self.bot.core.loginInfo['url'] + uri
TypeError: Can't convert 'NoneType' object to str implicitly

SyntaxError: can use starred expression only as assignment target

环境:

Ubuntu 14.04, Python 3.4
wxpy 0.3.8,0.3.9 都有这个错误,0.3.6 无错误

代码:

from wxpy import embed, Bot

b1 = Bot()
embed()

错误:

Traceback (most recent call last):
  File "test.py", line 1, in <module>
    from wxpy import embed, Bot
  File "/lib/python3.4/site-packages/wxpy/__init__.py", line 48, in <module>
    from .api.bot import Bot
  File "/lib/python3.4/site-packages/wxpy/api/bot.py", line 12, in <module>
    from ..api.chats import Chat, Chats, Friend, Group, MP, User
  File "/lib/python3.4/site-packages/wxpy/api/chats/__init__.py", line 1, in <module>
    from .chat import Chat
  File "/lib/python3.4/site-packages/wxpy/api/chats/chat.py", line 8, in <module>
    from wxpy.utils import PuidMap, handle_response
  File "/lib/python3.4/site-packages/wxpy/utils/__init__.py", line 5, in <module>
    from .puid_map import PuidMap
  File "/lib/python3.4/site-packages/wxpy/utils/puid_map.py", line 121
    pickle.dump((*self.attr_dicts, self.captions), fp)
                            ^
SyntaxError: can use starred expression only as assignment target

关于图灵机器人的回复

我想实现只有@机器人的消息,机器人才出来回复,不然群里面任何人说话,机器人都跳出来,很乱啊,请问这个应该怎么设置?

报错 OSError: [Errno 9] Bad file descriptor

"""
In [1]: ---------------------------------------------------------------------------
OSError Traceback (most recent call last)
/root/pyprj/wxbot_pya/run.py in ()
111 pos_send()
112 complex_reply()
--> 113 embed()

/root/.virtualenvs/wxpy_bot/lib/python3.5/site-packages/wxpy/utils/console.py in embed(local, banner, shell)
64 for _shell in shell, _ipython, _bpython, _python:
65 try:
---> 66 _shell(local=local, banner=banner)
67 except (TypeError, ImportError):
68 continue

/root/.virtualenvs/wxpy_bot/lib/python3.5/site-packages/wxpy/utils/console.py in _ipython(local, banner)
12 config=load_default_config()
13 )
---> 14 shell()
15
16

/root/.virtualenvs/wxpy_bot/lib/python3.5/site-packages/IPython/terminal/embed.py in call(self, header, local_ns, module, dummy, stack_depth, global_ns, compile_flags, **kw)
226 # our call and get the original caller's namespaces.
227 self.mainloop(local_ns, module, stack_depth=stack_depth,
--> 228 global_ns=global_ns, compile_flags=compile_flags)
229
230 self.banner2 = self.old_banner2

/root/.virtualenvs/wxpy_bot/lib/python3.5/site-packages/IPython/terminal/embed.py in mainloop(self, local_ns, module, stack_depth, display_banner, global_ns, compile_flags)
321
322 with self.builtin_trap, self.display_trap:
--> 323 self.interact()
324
325 # now, purge out the local namespace of IPython's hidden variables.

/root/.virtualenvs/wxpy_bot/lib/python3.5/site-packages/IPython/terminal/interactiveshell.py in interact(self, display_banner)
467
468 try:
--> 469 code = self.prompt_for_code()
470 except EOFError:
471 if (not self.confirm_exit) \

/root/.virtualenvs/wxpy_bot/lib/python3.5/site-packages/IPython/terminal/interactiveshell.py in prompt()
222 # This is very limited, and only accepts a single line.
223 def prompt():
--> 224 return cast_unicode_py2(input('In [%d]: ' % self.execution_count))
225 self.prompt_for_code = prompt
226 return

/root/.virtualenvs/wxpy_bot/lib/python3.5/site-packages/IPython/utils/py3compat.py in input(prompt)
150 # to forward requests to a frontend.
151 def input(prompt=''):
--> 152 return builtin_mod.input(prompt)
153
154 builtin_mod_name = "builtins"

OSError: [Errno 9] Bad file descriptor
"""

[建议]建议增加消息尾巴选项

有时候想注明消息是由机器人发出来的,避免机器人造成不必要的误解,希望大神能增加一个可选参数,定义消息的尾巴。。。。。。。

请问如何删除好友

api中只看到了添加好友和通过好友,如果好友数量超过5000是否就添加不上了?

增加消息管道

在 Bot 对象中增加一个新的接口,用于设置消息管道。

消息管道 (message_pipe):

  • 每当收到新消息时,除了执行相应的注册函数,还将执行用户设定的“消息管道”函数
  • 消息管道函数,通常用于执行类似“记录消息到数据库”的操作
  • 消息管道函数的执行,为一个单独线程,且始终顺序执行(只有一个线程)

请问如何填加多个好友,同时发送信息??

my_friend = robot.friends().search('游否', sex=MALE, city="深圳")[0]
robot.my_friend.send('Hello WeChat!')

此代码只能给一个好友发送信息,请问有什么方法,可以填加2个以上的好友,同时发送??

如何移除指定的用户

我想@机器人 移除 某用户,这样该怎么写?
我写了一半如下:
@bot.register(teamgroup)
def remove_msg(msg):
if msg.is_at:
if '移除' in msg.text.lower():
remove_members( ) <------这个“某用户”的参数该如何传递?

提示登录了两次,然后bot啥都获取不到

如题,如果第二次不登陆,会卡在 Please scan the QR code to log in.

Getting uuid of QR code.
Downloading QR code.
Please scan the QR code to log in.
Please press confirm on your phone.
Loading the contact, this may take a little while.
Login successfully as xxx
Getting uuid of QR code.
Downloading QR code.
Please scan the QR code to log in.
Please press confirm on your phone.
LOG OUT!
Loading the contact, this may take a little while.
Login successfully as xxx
>>> bot.friends()
[]
>>> ```

how to get the avatar url

friend = bot.friends()[6]  
friend.get_avatar(save_path='/tmp/f.jpg')

the upper code will save the avatar to the filesystem, but i just want the url weixin server returned, how can i get it?

【建议】能不能支持小冰啊?

小冰是个公众号,支持自动回复图片,声音,文字,所以我就想啊,能不能把非小冰发给我的消息全部自动发给小冰,然后提取小冰的回复,回复给非小冰对象,难点就是:有时候,你说一句,小冰有时要回复多句,而且不能分辨小冰的回复到底是回复哪一句的。。。不知道大神有没有法?

如何获取群二维码?

请问如何获取群二维码?我查看了 Group 对象的所以方法 并没有关于二维码的。谢谢!

好友将自己拉黑后,给对方发消息会发送多条消息

我测试的时候,让好友把发送方拉黑,发送消息的时候,会出现多条发送日志。
连续多条日志:
至尊宝: 消息已发出,但被对方拒收了。 (Note)
最后,导致该微信号被限制:
再给其他正常好友发消息也出错:
发送消息过于频繁,等待对方接受你的好友请求后再发。 (Note)

不知道有没有什么设置?感谢!

如何创建群聊

bot.create_group(users=[baisong], topic='test2')
ResponseError: ret: 1101; err_msg:

报错……

Can wxpy get context conversation?

您好~

wxpy可以获取响应上下消息么?

因为 一般的注册事件都是单句响应,图灵的上下文响应是通过特殊的uid实现的。

那么但就微信消息本身,能否做到呢?

比如

User - 用户
Bot - wxpy 程序

User: 下载xxx.mp4
下载完成是否上传? Bot
User:上传
上传完成,地址是:xxx Bot

如何实现这样的注册事件呢?现在的情况似乎无法实现,我尝试了一下。

再次感谢~

msg.chat.accept()方法报错

你好 代码如下
@bot.register()
def print_others(msg):
logging.info(msg)

if msg.type == "Note" and "刚刚把你添加到通讯录" in msg.text:
logging.info("add new friend: " + msg.chat.nick_name)
msg.chat.send_image('new_user.jpg')
msg.chat.accept()
return

我的微信机器人账号设置的加我好友时不需要验证,所以用户添加我到通讯录之后可以直接发消息给我,然后调用msg.chat.accept()时就有报错,报错信息如下

Fri, 28 Apr 2017 11:56:45 bot.py[line:330] ERROR
An error occurred in <function print_others at 0x7f6ea15c4730>.
Traceback (most recent call last):
File "/opt/python35/lib/python3.5/site-packages/wxpy/api/bot.py", line 326, in process
ret = config.func(msg)
File "ttsbot-prod.py", line 36, in print_others
bot.accept_friend(msg.chat)
File "/opt/python35/lib/python3.5/site-packages/wxpy/api/bot.py", line 253, in accept_friend
do()
File "/opt/python35/lib/python3.5/site-packages/wxpy/utils/misc.py", line 59, in wrapped
smart_map(check_response_body, ret)
File "/opt/python35/lib/python3.5/site-packages/wxpy/utils/misc.py", line 178, in smart_map
return func(i, *args, **kwargs)
File "/opt/python35/lib/python3.5/site-packages/wxpy/utils/misc.py", line 25, in check_response_body
raise ResponseError('ret: {}; err_msg: {}'.format(ret, err_msg))
wxpy.exceptions.ResponseError: ret: -1; err_msg:

总是提示groups()没有search()方法

groupWolf = robot.groups().search('狼群')[0]
robot.register(groupWolf)
到这总会报错,提示没有search方法,改成如下:
print(robot.groups())
输出结果为[]。
改成
robot.register() print(robot.groups())
才会有内容,求修复啊

TypeError: 'DataFrame' objects are mutable, thus they cannot be hashed

报错哎,请问怎么解决?

代码:
my_friend = bot.friends().search('Yang Hui')[0]
print(my_friend)
my_friend.send('Hello WeChat!')

log:
Getting uuid of QR code.
Downloading QR code.
Please scan the QR code to log in.
Please press confirm on your phone.
Loading the contact, this may take a little while.
TERM environment variable not set.
Login successfully as Yang Hui
<Friend: Yang Hui>
Traceback (most recent call last):
File "/Users/yanghui/PycharmProjects/quantest/my_strategy/复盘/notices.py", line 23, in
if key_word in notices.title:
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pandas/core/generic.py", line 871, in contains
return key in self._info_axis
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pandas/indexes/base.py", line 1393, in contains
hash(key)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pandas/core/generic.py", line 831, in hash
' hashed'.format(self.class.name))
TypeError: 'DataFrame' objects are mutable, thus they cannot be hashed

Process finished with exit code 1

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.