forked from littlecodersh/ItChat
-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
292821c
commit 03e3b7f
Showing
10 changed files
with
116 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
dist/* | ||
itchat.egg-info/* | ||
*.pyc | ||
*.swp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
|
||
requests==2.9.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
""" 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='[email protected]', | ||
|
||
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={}, | ||
) |