forked from littlecodersh/ItChat
-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
3 changed files
with
61 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#!/usr/bin/python | ||
# -*- coding: UTF-8 -*- | ||
# coding:utf-8 | ||
|
||
import sys | ||
import itchat, time | ||
from itchat.content import * | ||
import time, easygui | ||
|
||
easygui.msgbox("别忘了打卡!", title="提醒",ok_button="知道啦") | ||
|
||
reload(sys) | ||
sys.setdefaultencoding("utf-8") | ||
|
||
|
||
@itchat.msg_register([TEXT, MAP, CARD, NOTE, SHARING]) | ||
def text_reply(msg): | ||
msg.user.send('%s: %s' % (msg.type, msg.text)) | ||
|
||
@itchat.msg_register([PICTURE, RECORDING, ATTACHMENT, VIDEO]) | ||
def download_files(msg): | ||
msg.download(msg.fileName) | ||
typeSymbol = { | ||
PICTURE: 'img', | ||
VIDEO: 'vid', }.get(msg.type, 'fil') | ||
return '@%s@%s' % (typeSymbol, msg.fileName) | ||
|
||
@itchat.msg_register(FRIENDS) | ||
def add_friend(msg): | ||
msg.user.verify() | ||
msg.user.send('Nice to meet you!') | ||
|
||
@itchat.msg_register(TEXT, isGroupChat=True) | ||
def text_reply(msg): | ||
print "from %s: %s" % (msg.actualNickName, msg.text) | ||
if msg.isAt: | ||
chatrooms = itchat.search_chatrooms(name=u'淘宝黑车') | ||
chatroom = itchat.update_chatroom(chatrooms[0]['UserName']) | ||
print len(chatroom['MemberList']) | ||
msg.user.send(u'@%s\u2005 你喊我干啥? %s? 噢,对啦,咱们这个群里一共有%d个人了,等会儿切群,我来操作。' % ( | ||
msg.actualNickName, msg.text, len(chatroom['MemberList']))) | ||
|
||
itchat.auto_login(True) | ||
itchat.run(True) |
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,17 @@ | ||
|
||
def run(f): | ||
f("gogo") | ||
|
||
def register_msg(): | ||
print "begin register" | ||
return run | ||
|
||
@register_msg() | ||
def text_reply(msg): | ||
print msg | ||
|
||
''' | ||
1. register_msg is called and return a functor | ||
2. functor called with registered function as param | ||
''' | ||
|