itchatmp is an open-source api for wechat massive platform.
Developing wechat massive platform with python has never been easier.
Based on tornado, efficiency is within a simple fetch.
You may use same command in sync way or coroutine way.
You may use it directly, with nginx or wsgi.
And it's similiar to itchat (api for personal wechat), learn once and get two tools.
So enjoy!
itchatmp will be installed using this command:
pip install itchatmp
If you want to reply a message to yourself:
import itchatmp
itchatmp.update_config(itchatmp.WechatConfig(
token='yourToken',
appId = 'yourAppId',
appSecret = 'yourAppSecret'))
@itchatmp.msg_register(itchatmp.content.TEXT)
def text_reply(msg):
return msg['content']
itchatmp.run()
Detailed introduction is in Advanced uses and document
This is a robot based on this project, you may have a try:
If you want to use itchatmp in coroutine way, you need to install another package:
pip install itchatmphttp
Also, if you delete this, itchatmp will fall back to sync.
Take reply as example, coroutine version of the is:
import itchatmp
from tornado import gen
itchatmp.update_config(itchatmp.WechatConfig(
token='yourToken',
appId = 'yourAppId',
appSecret = 'yourAppSecret'))
@itchatmp.msg_register(itchatmp.content.TEXT)
def text_reply(msg):
yield gen.sleep(3)
r = yield itchatmp.send('First message', msg['FromUserName'])
print('First message sent: %s' % r)
yield gen.sleep(3)
r = yield itchatmp.send('First message', msg['FromUserName'])
print('Second message sent: %s' % r)
itchatmp.run()
All the methods in itchatmp will become coroutine.
If you are not familiar with coroutine, I strongly advise you learn it before you try the coroutine version.
I sincerely hope questions like why time.sleep
stuck the main thread will not happen.
And for sync version, I also add thread pool for you, so don't worry about block too much.
If you want to deploy onto platform like SAE, app can be produced like this:
app = itchatmp.run(isWsgi=True)
For detailed information, you may need this part of the document.
If you have any problem or suggestion, contact me on this issue.
Or join our QQ group: 438747166.