Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
whtsky committed Aug 16, 2015
2 parents 61e5447 + 6a5177c commit f985b03
Show file tree
Hide file tree
Showing 12 changed files with 58 additions and 22 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Expand Up @@ -45,8 +45,13 @@ docs/_
#VirtualEnv
.Python
include/
Scripts/
pyvenv.cfg

werobot_session.db

.coveralls.yml

werobot_session
pip-selfcheck.json

1 change: 1 addition & 0 deletions .travis.yml
Expand Up @@ -3,6 +3,7 @@ python:
- 2.6
- 2.7
- 3.3
- 3.4
- pypy

services:
Expand Down
8 changes: 0 additions & 8 deletions docs/_templates/sidebarintro.html
@@ -1,8 +0,0 @@
<h3>关于</h3>
WeRoBot 是一个高中生利用闲暇时间写成的微信公共平台开发框架。如果你喜欢 WeRoBot ,请考虑捐助:
<ul>
<li><a href="https://www.gittip.com/whtsky/">GitTip</a></li>
</ul>

<h3>帮助</h3>
如果你在使用过程中有任何建议或者疑惑,欢迎<a href="mailto:whtsky@gmail.com">给我发信</a>
6 changes: 6 additions & 0 deletions docs/changelog.rst
@@ -1,6 +1,12 @@
Changelog
=============

Version 0.6.1
----------------

+ Fix wrong URL in ``upload_media``
+ Add VideoMessage

Version 0.6.0
----------------

Expand Down
6 changes: 3 additions & 3 deletions docs/deploy.rst
Expand Up @@ -13,7 +13,7 @@
def echo(message):
return 'Hello World!'

robot.run(server='gevent')
robot.run(server='gevent', port=12233)

server 支持以下几种:

Expand Down Expand Up @@ -77,11 +77,11 @@ server 支持以下几种:
location / {
proxy_pass_header Server;
proxy_redirect off;
proxy_pass http://127.0.0.1:8888;
proxy_pass http://127.0.0.1:12233;
}
}

.. note:: 在这个例子中, WeRoBot 的端口号为8888。你应该在微信管理后台中将服务器地址设为 ``http://example.com`` 。
.. note:: 在这个例子中, WeRoBot 的端口号为 12233。你应该在微信管理后台中将服务器地址设为 ``http://example.com`` 。

在SAE上部署
-----------------
Expand Down
22 changes: 17 additions & 5 deletions docs/messages.rst
@@ -1,6 +1,5 @@
消息
==========
目前WeRoBot共有以下几种Message: `TextMessage` , `ImageMessage` , `LocationMessage` , `EventMessage` , `VoiceMessage` [3]_ 和 `UnknownMessage` 。他们都继承自 WeChatMessage 。

公共属性
--------------
Expand All @@ -11,8 +10,8 @@
name value
======== ===================================
id 消息id,64位整型 [2]_
target 信息的目标用户。通常是机器人用户。
source 信息的来源用户。通常是发送信息的用户。
target 开发者账号( OpenID )
source 发送方账号( OpenID )
time 信息发送的时间,一个UNIX时间戳。
raw 信息的原始 XML 格式
======== ===================================
Expand Down Expand Up @@ -92,11 +91,24 @@ VoiceMessage的属性:
name value
============ =====================================
type 'voice'
media_id 微信内部的一个文件ID。
media_id 消息媒体 ID
format 声音格式
recognition 未公开字段,猜测为语音识别后的文字。
recognition 语音识别结果
============ =====================================

VideoMessage
--------------------

VideoMessage:

================ =====================================
name value
================ =====================================
type 'video'
media_id 消息媒体 ID
thumb_media_id 视频缩略图媒体 ID
=============== =====================================

UnknownMessage
---------------

Expand Down
6 changes: 3 additions & 3 deletions requirements.txt
@@ -1,3 +1,3 @@
bottle==0.11.6
requests==2.2.1
six==1.5.2
bottle
requests
six
5 changes: 4 additions & 1 deletion setup.cfg
@@ -1,2 +1,5 @@
[aliases]
release = sdist --formats=zip,gztar register upload
release = sdist --formats=zip,gztar bdist_wheel register upload

[bdist_wheel]
universal = 1
8 changes: 8 additions & 0 deletions setup.py
Expand Up @@ -28,6 +28,14 @@
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: Implementation :: CPython',
'Programming Language :: Python :: Implementation :: PyPy',
'Intended Audience :: Developers',
'Topic :: Software Development :: Libraries',
'Topic :: Software Development :: Libraries :: Python Modules',
'Topic :: Utilities',
],
tests_require=['nose'],
test_suite='nose.collector',
Expand Down
2 changes: 1 addition & 1 deletion werobot/__init__.py
@@ -1,4 +1,4 @@
__version__ = '0.6.0'
__version__ = '0.6.1'
__author__ = 'whtsky'
__license__ = 'MIT'

Expand Down
2 changes: 1 addition & 1 deletion werobot/client.py
Expand Up @@ -170,7 +170,7 @@ def upload_media(self, media_type, media_file):
:return: 返回的 JSON 数据包
"""
return self.post(
url="https://api.weixin.qq.com/cgi-bin/menu/create",
url="http://file.api.weixin.qq.com/cgi-bin/media/upload",
params={
"access_token": self.token,
"type": media_type
Expand Down
9 changes: 9 additions & 0 deletions werobot/messages.py
Expand Up @@ -76,6 +76,15 @@ def __init__(self, message):
super(VoiceMessage, self).__init__(message)


@handle_for_type("video")
@handle_for_type("shortvideo")
class VideoMessage(WeChatMessage):
def __init__(self, message):
self.media_id = message.pop('MediaId')
self.thumb_media_id = message.pop('ThumbMediaId')
super(VideoMessage, self).__init__(message)


class UnknownMessage(WeChatMessage):
def __init__(self, message):
self.type = 'unknown'
Expand Down

0 comments on commit f985b03

Please sign in to comment.