5 Star 8 Fork 6

合肥吃货食光/Python有趣的代码

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
转发微信群消息 1.93 KB
一键复制 编辑 原始数据 按行查看 历史
合肥吃货食光 提交于 2020-03-01 23:55 . add 转发微信群消息.
#coding=utf-8
import itchat
from itchat.content import *
@itchat.msg_register(TEXT, isGroupChat=True)
def group_text(msg):
group = itchat.get_chatrooms(update=True)
from_user = ''
for g in group:
if g['NickName'] == '材硕18级班长支书们':#从群中找到指定的群聊
from_group = g['UserName']
for menb in g['MemberList']:
#print(menb['NickName'])
if menb['NickName'] == "这是发布通知的大佬名字":
from_user = menb['UserName']
break
if g['NickName'] == '材硕1801':#把消息发到这个群
to_group = g['UserName']
if msg['FromUserName'] == from_group:
if msg['ActualUserName'] == from_user:
itchat.send('[大佬有话要说] %s:%s'%(msg['ActualNickName'],msg['Content']),to_group)
@itchat.msg_register([PICTURE, ATTACHMENT, VIDEO], isGroupChat=True)
def group_reply_media(msg):
group = itchat.get_chatrooms(update=True)
from_user = ''
for g in group:
if g['NickName'] == '材硕18级班长支书们':#从群中找到指定的群聊
from_group = g['UserName']
for menb in g['MemberList']:
#print(menb['NickName'])
if menb['NickName'] == "这是发布通知的大佬名字":
from_user = menb['UserName']
break
if g['NickName'] == '材硕1801':#把消息发到这个群
to_group = g['UserName']
msg['Text'](msg['FileName'])
if msg['FromUserName'] == from_group:
if msg['ActualUserName'] == from_user:
msg['Text'](msg['FileName'])
itchat.send('@%s@%s'%({'Picture': 'img', 'Video': 'vid'}.get(msg['Type'], 'fil'),msg['FileName']),to_group)
itchat.auto_login(hotReload=False,enableCmdQR=2)
itchat.run()
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/simon4055/fun.git
git@gitee.com:simon4055/fun.git
simon4055
fun
Python有趣的代码
master

搜索帮助