Skip to content

Commit

Permalink
add hongbao app
Browse files Browse the repository at this point in the history
  • Loading branch information
raywill committed Nov 15, 2017
1 parent 8b82f93 commit 0651330
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 0 deletions.
44 changes: 44 additions & 0 deletions app/hongbao.py
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.
17 changes: 17 additions & 0 deletions learn/at_notion.py
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
'''

0 comments on commit 0651330

Please sign in to comment.