Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BillLi
ItChat
提交
03e3b7f0
I
ItChat
项目概览
BillLi
/
ItChat
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
I
ItChat
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
03e3b7f0
编写于
3月 28, 2016
作者:
L
LittleCoder
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Upload to pypi
上级
292821c8
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
116 addition
and
11 deletion
+116
-11
.gitignore
.gitignore
+2
-0
itchat/__init__.py
itchat/__init__.py
+10
-7
itchat/client.py
itchat/client.py
+1
-4
itchat/config.py
itchat/config.py
+0
-0
itchat/out.py
itchat/out.py
+0
-0
itchat/storage.py
itchat/storage.py
+0
-0
itchat/tools.py
itchat/tools.py
+0
-0
requirement.txt
requirement.txt
+2
-0
run.py
run.py
+43
-0
setup.py
setup.py
+58
-0
未找到文件。
.gitignore
浏览文件 @
03e3b7f0
dist/*
itchat.egg-info/*
*.pyc
*.swp
__init__.py
→
itchat/
__init__.py
浏览文件 @
03e3b7f0
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
...
...
client.py
→
itchat/
client.py
浏览文件 @
03e3b7f0
...
...
@@ -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'
,
...
...
config.py
→
itchat/
config.py
浏览文件 @
03e3b7f0
文件已移动
out.py
→
itchat/
out.py
浏览文件 @
03e3b7f0
文件已移动
storage.py
→
itchat/
storage.py
浏览文件 @
03e3b7f0
文件已移动
tools.py
→
itchat/
tools.py
浏览文件 @
03e3b7f0
文件已移动
requirement.txt
0 → 100644
浏览文件 @
03e3b7f0
requests==2.9.1
run.py
0 → 100644
浏览文件 @
03e3b7f0
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
\u2005
I received: %s'
%
(
msg
[
'ActualNickName'
],
msg
[
'Content'
]),
msg
[
'FromUserName'
])
itchat
.
run
()
if
__name__
==
'__main__'
:
complex_reply
()
setup.py
0 → 100644
浏览文件 @
03e3b7f0
""" 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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录