Skip to content

Commit 7cab613

Browse files
committed
red pocket alarm
1 parent 6116559 commit 7cab613

File tree

3 files changed

+50
-0
lines changed

3 files changed

+50
-0
lines changed

red_pocket/readme.md

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
## 微信红包提醒
2+
3+
需要安装库:itchat
4+
5+
参考阅读:
6+
7+
效果演示:
8+
9+
![](redpocket.gif)
10+
11+
12+
13+
更多实用有趣的例程
14+
15+
欢迎关注“**Crossin的编程教室**”及同名 [知乎专栏](https://zhuanlan.zhihu.com/crossin)
16+
17+
![crossincode](../crossin-logo.png)

red_pocket/red_pocket.py

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# coding: utf-8
2+
import itchat
3+
import tkinter.messagebox
4+
import winsound
5+
# import os
6+
# import pygame
7+
8+
def alarm():
9+
# Windows嗡鸣声
10+
winsound.Beep(1000, 3000)
11+
# # Mac语音
12+
# os.system('say "有人发红包了,赶紧去抢啊!红红火火恍恍惚惚哈哈哈哈"')
13+
# # 播放MP3
14+
# pygame.mixer.init()
15+
# track = pygame.mixer.music.load('alarm.mp3')
16+
# pygame.mixer.music.play()
17+
tkinter.messagebox.showinfo('重要提醒','有人发红包了!')
18+
19+
20+
@itchat.msg_register('Note', isGroupChat=True)
21+
def get_note(msg):
22+
if '红包' in msg['Text']:
23+
print('note:',msg['Text'])
24+
alarm()
25+
26+
@itchat.msg_register(itchat.content.TEXT, isGroupChat=True)
27+
def _(msg):
28+
print('text:',msg['Text'])
29+
30+
itchat.auto_login(hotReload=True)
31+
itchat.run()
32+
itchat.logout()
33+

red_pocket/redpocket.gif

1.91 MB
Loading

0 commit comments

Comments
 (0)