添加了一个关于个人微信掉线的邮件提醒 #1601
dentes9988
started this conversation in
Ideas
Replies: 1 comment 1 reply
-
这个python脚本能保持后台一直运行吗,会不会也被踢出去 |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
用gpt去写的代码,真的好玩
import time
import smtplib
from email.mime.text import MIMEText
from email.header import Header
def send_email():
sender = '[email protected]' # 替换为您的发送邮箱
receivers = '[email protected]' # 替换为接收者的邮箱
message = MIMEText('AI机器人已掉线', 'plain', 'utf-8')
message['From'] = sender
message['To'] = receivers
subject = 'AI机器人已掉线'
message['Subject'] = Header(subject, 'utf-8')
def check_log(last_position):
with open('/path/to/your/logfile.log', 'r') as file: # 替换为您的日志文件路径
file.seek(last_position)
content = file.read()
new_position = file.tell()
last_position = 0
last_position = check_log(last_position) # 执行初始检测
while True:
last_position = check_log(last_position)
time.sleep(180) # 每隔3分钟执行一次
Beta Was this translation helpful? Give feedback.
All reactions