提交 03e3b7f0 编写于 作者: L LittleCoder

Upload to pypi

上级 292821c8
dist/*
itchat.egg-info/*
*.pyc
*.swp
import time, thread
from client import client
import traceback
__version__ = '0.1b'
__client = client()
......@@ -34,7 +36,7 @@ def send(msg = 'Test Message', toUserName = None):
return __client.send_msg(toUserName, msg)
# decorations
__functionDict = {}
__functionDict = {'GroupChat': {}}
def configured_reply():
try:
msg = __client.storageClass.msgList.pop()
......@@ -59,12 +61,13 @@ def msg_dealer(_type = None, *args, **kwargs):
elif _type is None:
return configured_reply
else:
def _msg_dealer(fn, *args, **kwargs):
if kwargs.get('isGroupChat', False):
__functionDict['GroupChat'][_type] = fn
else:
__functionDict[_type] = fn
return fn
if not isinstance(_type, list): _type = [_type]
def _msg_dealer(fn, *_args, **_kwargs):
for msgType in _type:
if kwargs.get('isGroupChat', False):
__functionDict['GroupChat'][msgType] = fn
else:
__functionDict[msgType] = fn
return _msg_dealer
# in-build run
......
......@@ -244,11 +244,8 @@ class client:
'Type': 'Friends',
'Text': {
'Status': m['Status'],
'UserName': m['UserName'],
'UserName': m['RecommendInfo']['UserName'],
'Ticket': m['Ticket'], }, }
# self.add_friend(m['Status'], m['RecommendInfo']['UserName'], m['Ticket'])
# self.get_contract()
# self.send_msg(m['RecommendInfo']['UserName'], config.WELCOME_WORDS)
elif m['MsgType'] == 42: # name card
msg = {
'Type': 'Card',
......
requests==2.9.1
import time
import itchat
itchat.auto_login()
def simple_reply():
@itchat.msg_dealer
def simple_reply(msg):
if msg.get('Type', '') == 'Text':
return 'I received: %s'%msg.get('Content', '')
while 1:
simple_reply()
time.sleep(1)
def complex_reply():
@itchat.msg_dealer(['Text', 'Map', 'Card', 'Note', 'Sharing'])
def text_reply(msg):
itchat.send('%s: %s'%(msg['Type'], msg['Text']), msg['FromUserName'])
@itchat.msg_dealer(['Picture', 'Recording', 'Attachment', 'Video'])
def download_files(msg):
fileDir = '%s%s'%(msg['Type'], int(time.time()))
msg['Text'](fileDir)
itchat.send('%s received'%msg['Type'], msg['FromUserName'])
itchat.send('@%s@%s'%('img' if msg['Type'] == 'Picture' else 'fil', fileDir), msg['FromUserName'])
@itchat.msg_dealer('Friends')
def add_friend(msg):
print msg['Text']
itchat.add_friend(**msg['Text'])
itchat.get_contract()
itchat.send_msg(msg['RecommendInfo']['UserName'], 'Nice to meet you!')
@itchat.msg_dealer('Text', isGroupChat = True)
def text_reply(msg):
itchat.send(u'@%s\u2005I received: %s'%(msg['ActualNickName'], msg['Content']), msg['FromUserName'])
itchat.run()
if __name__ == '__main__':
complex_reply()
""" A wechat personal account api project
See:
https://github.com/littlecodersh/ItChat/tree/api
https://github.com/littlecodersh/ItChat
"""
from setuptools import setup, find_packages
from codecs import open
from os import path
here = path.abspath(path.dirname(__file__))
with open(path.join(here, 'README.md'), encoding='utf-8') as f:
long_description = f.read()
setup(
name='itchat',
version='1.0.0',
description='A complete wechat personal account api',
long_description=long_description,
url='https://github.com/littlecodersh/ItChat/tree/api',
author='LittleCoder',
author_email='i7meavnktqegm1b@qq.com',
license='MIT',
classifiers=[
'Development Status :: 3 - Alpha',
'Intended Audience :: Developers',
'Topic :: Software Development :: Libraries :: Python Modules',
'License :: OSI Approved :: MIT License',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
# 'Programming Language :: Python :: 3',
# 'Programming Language :: Python :: 3.3',
# 'Programming Language :: Python :: 3.4',
# 'Programming Language :: Python :: 3.5',
],
keywords='wechat itchat api robot weixin personal extend',
# You can just specify the packages manually here if your project is
# simple. Or you can use find_packages().
# packages=find_packages(exclude=['contrib', 'docs', 'tests']),
install_requires=['requests'],
# List additional groups of dependencies here
extras_require={},
)
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册