Compare commits

...
17 Commits
Author SHA1 Message Date
Mr Chen e1820ad5b3 Merge pull request #400 from midoks/dev
0.13.5
2023-03-30 17:31:54 +08:00
midoks 22133f1a6c 0.13.5
### 版本更新 0.13.5

* 添加邮件通知功能。
* 修复初始安装脚本。
2023-03-30 17:30:15 +08:00
midoks 0041cbdff3 添加邮件通知功能 2023-03-30 17:18:40 +08:00
midoks 889da3c769 Update install.sh 2023-03-30 11:59:55 +08:00
midoks d086eb9c61 Update install.sh 2023-03-30 11:56:48 +08:00
midoks 832fa9cd1a Update install_dev.sh 2023-03-30 11:54:40 +08:00
midoks 8c19fb9629 Update config_api.py 2023-03-30 11:22:36 +08:00
midoks a2e4dd6753 Update push_notice_msg.py 2023-03-30 11:22:19 +08:00
midoks 22ba7dda55 Update install.sh 2023-03-29 16:35:09 +08:00
midoks 2ffa36eecb up 2023-03-29 16:32:46 +08:00
Mr Chen fe5843b35d Merge pull request #398 from midoks/dev
修复python pip源安装
2023-03-29 16:27:46 +08:00
midoks e95acbe947 Update lib.sh 2023-03-29 16:08:55 +08:00
midoks aed8319dd3 Update push_ad.py 2023-03-29 14:08:06 +08:00
midoks babe1b885e Update push_notice_msg.py 2023-03-29 13:17:38 +08:00
midoks 0612f52402 Update push_notice_msg.py 2023-03-29 13:03:52 +08:00
midoks db67cea737 AD 2023-03-29 13:01:12 +08:00
midoks 52cf675843 Update install_dev.sh 2023-03-29 08:49:26 +08:00
11 changed files with 345 additions and 40 deletions
+3 -5
View File
@@ -99,12 +99,10 @@ docker run -itd --name mw-server --privileged=true -p 7200:7200 -p 80:80 -p 443:
```
### 版本更新 0.13.4
### 版本更新 0.13.5
无重大更新
* 国内安装不在依赖gitee。
* tgbot优化。
* 添加邮件通知功能。
* 修复初始安装脚本。
### JSDelivr安装地址
+8 -1
View File
@@ -27,7 +27,7 @@ from flask import request
class config_api:
__version = '0.13.4'
__version = '0.13.5'
__api_addr = 'data/api.json'
def __init__(self):
@@ -788,6 +788,13 @@ class config_api:
return mw.returnData(True, '验证成功')
return mw.returnData(False, '验证失败')
if tag == 'email':
t = json.loads(tag_data)
test_bool = mw.emailNotifyTest(t)
if test_bool:
return mw.returnData(True, '验证成功')
return mw.returnData(False, '验证失败')
return mw.returnData(False, '暂时未支持该验证')
def setNotifyEnableApi(self):
+36 -1
View File
@@ -1697,7 +1697,7 @@ def getNotifyData(is_parse=False):
data = json.loads(notify_data)
if is_parse:
tag_list = ['tgbot']
tag_list = ['tgbot', 'email']
for t in tag_list:
if t in data and 'cfg' in data[t]:
data[t]['data'] = json.loads(deDoubleCrypt(t, data[t]['cfg']))
@@ -1759,6 +1759,34 @@ def tgbotNotifyTest(app_token, chat_id):
return tgbotNotifyHttpPost(app_token, chat_id, msg)
def emailNotifyMessage(data):
'''
邮件通知
'''
sys.path.append(os.getcwd() + "/class/plugin")
import memail
try:
if data['smtp_ssl'] == 'ssl':
memail.sendSSL(data['smtp_host'], data['smtp_port'],
data['username'], data['password'],
data['to_mail_addr'], data['subject'], data['content'])
else:
memail.send(data['smtp_host'], data['smtp_port'],
data['username'], data['password'],
data['to_mail_addr'], data['subject'], data['content'])
return True
except Exception as e:
print(getTracebackInfo())
return False
def emailNotifyTest(data):
print(data)
data['subject'] = 'MW通知测试'
data['content'] = data['mail_test']
return emailNotifyMessage(data)
def notifyMessageTry(msg, stype='common', trigger_time=300, is_write_log=True):
lock_file = getPanelTmp() + '/notify_lock.json'
@@ -1796,6 +1824,13 @@ def notifyMessageTry(msg, stype='common', trigger_time=300, is_write_log=True):
else:
do_notify = tgbotNotifyMessage(
t['app_token'], t['chat_id'], msg)
if 'email' in data and 'enable' in data['email']:
if data['email']['enable']:
t = data['email']['data']
t['subject'] = 'MW通知'
t['content'] = msg
do_notify = emailNotifyMessage(t)
return do_notify
+43
View File
@@ -0,0 +1,43 @@
# coding: utf-8
import smtplib
from email import encoders
from email.header import Header
from email.mime.text import MIMEText
from email.utils import parseaddr, formataddr
def _format_addr(s):
name, addr = parseaddr(s)
return formataddr((Header(name, 'utf-8').encode(), addr))
def send(smtp_host, smtp_port, username, password, to_mail, subject, content):
smtp = smtplib.SMTP()
smtp.connect(smtp_host, port=smtp_port)
smtp.login(user=username, password=password)
msg = MIMEText(content, 'plain', 'utf-8')
msg['From'] = _format_addr(username)
msg['To'] = _format_addr(to_mail)
msg['Subject'] = Header(subject, 'utf-8').encode()
smtp.sendmail(from_addr=username, to_addrs=to_mail, msg=msg.as_string())
return True
def sendSSL(smtp_host, smtp_port, username, password, to_mail, subject, content):
smtp = smtplib.SMTP_SSL(smtp_host, port=smtp_port)
smtp.login(user=username, password=password)
msg = MIMEText(content, 'plain', 'utf-8')
msg['From'] = _format_addr(username)
msg['To'] = _format_addr(to_mail)
msg['Subject'] = Header(subject, 'utf-8').encode()
smtp.sendmail(from_addr=username, to_addrs=to_mail, msg=msg.as_string())
smtp.quit()
return True
+4 -2
View File
@@ -44,7 +44,7 @@ def send_msg(bot, tag='ad', trigger_time=300):
keyboard = [
[
types.InlineKeyboardButton(
text="赞助联系ME", url='tg://user?id=5568699210')
text="CK资源采集", url='https://ckzy1.com/')
],
[
types.InlineKeyboardButton(
@@ -66,7 +66,9 @@ def send_msg(bot, tag='ad', trigger_time=300):
types.InlineKeyboardButton(
text="论坛", url='https://bbs.midoks.me'),
types.InlineKeyboardButton(
text="搜索", url='https://bbs.midoks.me/search.php')
text="搜索", url='https://bbs.midoks.me/search.php'),
types.InlineKeyboardButton(
text="@ME", url='tg://user?id=5568699210')
]
]
markup = types.InlineKeyboardMarkup(keyboard)
@@ -42,10 +42,11 @@ def send_msg(bot, tag='ad', trigger_time=300):
# https://t.me/gjgzs2022 | 19/m
# ♻️CMS导航网♻️/💰流量变现💰 | 28/m
# CK资源采集 |29/m
keyboard = [
[
types.InlineKeyboardButton(
text="为了不打扰双方,私聊解决问题先转100U,否则无视!", url='tg://user?id=5568699210')
text="CK资源采集", url='https://ckzy1.com/')
],
[
types.InlineKeyboardButton(
@@ -67,15 +68,19 @@ def send_msg(bot, tag='ad', trigger_time=300):
types.InlineKeyboardButton(
text="论坛", url='https://bbs.midoks.me'),
types.InlineKeyboardButton(
text="搜索", url='https://bbs.midoks.me/search.php')
text="搜索", url='https://bbs.midoks.me/search.php'),
types.InlineKeyboardButton(
text="@ME", url='tg://user?id=5568699210')
]
]
markup = types.InlineKeyboardMarkup(keyboard)
msg = bot.send_message(
chat_id, "由于在解决的问题的时候,不给信息,无法了解情况。以后不再群里回答技术问题。全部去论坛提问。在解决问题的过程中,可能需要面板信息,和SSH信息,如无法提供请不要提问。为了让群里都知晓。轮播一年", reply_markup=markup)
msg_notice = "由于在解决的问题的时候,不给信息,无法了解情况。以后不再群里回答技术问题。全部去论坛提问。在解决问题的过程中,可能需要面板信息,和SSH信息,如无法提供请不要提问。为了让群里都知晓。轮播一年!\n"
msg_notice += "为了不打扰双方,私聊解决问题先转100U,否则无视!"
msg = bot.send_message(chat_id, msg_notice, reply_markup=markup)
# print(msg.message_id)
time.sleep(50)
time.sleep(60)
try:
bot.delete_message(
chat_id=chat_id, message_id=msg.message_id)
@@ -84,4 +89,9 @@ def send_msg(bot, tag='ad', trigger_time=300):
def run(bot):
send_msg(bot, 'tmp_msg', 200)
try:
send_msg(bot, 'notice_msg', 180)
except Exception as e:
writeLog('-----push_notice_msg error start -------')
print(mw.getTracebackInfo())
writeLog('-----push_notice_msg error start -------')
+192 -1
View File
@@ -382,7 +382,7 @@ function getTgbot(){
layer.open({
type: 1,
area: "500px",
title: '配置TgBot配置',
title: 'TgBot配置',
closeBtn: 1,
shift: 5,
btn:["确定","关闭","验证"],
@@ -401,6 +401,17 @@ function getTgbot(){
var pdata = {};
pdata['app_token'] = $('input[name="app_token"]').val();
pdata['chat_id'] = $('input[name="chat_id"]').val();
if (pdata['app_token'] == ''){
layer.msg('app_token不能为空!', {icon:2});
return false;
}
if (pdata['chat_id'] == ''){
layer.msg('chat_id不能为空!', {icon:2});
return false;
}
$.post('/config/set_notify',{'tag':'tgbot', 'data':JSON.stringify(pdata)},function(rdata){
showMsg(rdata.msg, function(){
if (rdata.status){
@@ -414,6 +425,17 @@ function getTgbot(){
var pdata = {};
pdata['app_token'] = $('input[name="app_token"]').val();
pdata['chat_id'] = $('input[name="chat_id"]').val();
if (pdata['app_token'] == ''){
layer.msg('app_token不能为空!', {icon:2});
return false;
}
if (pdata['chat_id'] == ''){
layer.msg('chat_id不能为空!', {icon:2});
return false;
}
$.post('/config/set_notify_test',{'tag':'tgbot', 'data':JSON.stringify(pdata)},function(rdata){
showMsg(rdata.msg, function(){
if (rdata.status){
@@ -427,6 +449,175 @@ function getTgbot(){
});
}
function getEmailCfg(){
var loadT = layer.msg('正在获取邮件配置信息...',{icon:16,time:0,shade: [0.3, '#000']});
$.post('/config/get_notify',{},function(data){
layer.close(loadT);
var smtp_host = 'smtp.163.com';
var smtp_port = '25';
var username = 'admin';
var password = '';
var to_mail_addr = '';
var smtp_ssl_no = 'checked';
var smtp_ssl_yes = '';
if (data.status){
if (typeof(data['data']['email']) !='undefined'){
smtp_host = data['data']['email']['data']['smtp_host'];
smtp_port = data['data']['email']['data']['smtp_port'];
username = data['data']['email']['data']['username'];
password = data['data']['email']['data']['password'];
to_mail_addr = data['data']['email']['data']['to_mail_addr'];
var smtp_ssl = data['data']['email']['data']['smtp_ssl'];
if (smtp_ssl == 'ssl'){
smtp_ssl_no = '';
smtp_ssl_yes = 'checked';
}
}
}
layer.open({
type: 1,
area: "500px",
title: '邮件配置',
closeBtn: 1,
shift: 5,
btn:["确定","关闭","验证"],
shadeClose: false,
content: "<div class='bt-form pd20'>\
<div class='line'>\
<span class='tname'>SMTP服务器</span>\
<div class='info-r'><input class='bt-input-text' type='text' name='smtp_host' value='"+smtp_host+"' style='width:100%'/></div>\
</div>\
<div class='line'>\
<span class='tname'>SMTP安全</span>\
<div class='info-r checkbox'>\
<label><input name='smtp_ssl' type='radio' value='' style='margin-right: 4px;' "+smtp_ssl_no+">None</label>\
<label><input name='smtp_ssl' type='radio' value='ssl' style='margin-right: 4px;' "+smtp_ssl_yes+">SSL</label>\
</div>\
</div>\
<div class='line'>\
<span class='tname'>SMTP端口</span>\
<div class='info-r'><input class='bt-input-text' type='text' name='smtp_port' value='"+smtp_port+"' style='width:100%' /></div>\
</div>\
<div class='line'>\
<span class='tname'>用户名</span>\
<div class='info-r'><input class='bt-input-text' type='text' name='username' value='"+username+"' style='width:100%' autocomplete='off'/></div>\
</div>\
<div class='line'>\
<span class='tname'>授权码</span>\
<div class='info-r'><input class='bt-input-text' type='password' name='password' value='"+password+"' style='width:100%' autocomplete='off'/></div>\
</div>\
<div class='line'>\
<span class='tname'>发送地址</span>\
<div class='info-r'><input class='bt-input-text' type='text' name='to_mail_addr' value='"+to_mail_addr+"' style='width:100%' autocomplete='off'/></div>\
</div>\
<div class='line'>\
<span class='tname'>验证测试</span>\
<div class='info-r'>\
<textarea class='bt-input-text' name='mail_test' style='width:100%; height: 80px; line-height: 20px; padding: 5px 8px;'>验证测试</textarea></div>\
</div>\
</div>",
yes:function(index){
var pdata = {};
pdata['smtp_host'] = $('input[name="smtp_host"]').val();
pdata['smtp_port'] = $('input[name="smtp_port"]').val();
pdata['smtp_ssl'] = $('input[name="smtp_ssl"]:checked').val();
pdata['username'] = $('input[name="username"]').val();
pdata['password'] = $('input[name="password"]').val();
pdata['to_mail_addr'] = $('input[name="to_mail_addr"]').val();
if (pdata['smtp_host'] == ''){
layer.msg('SMTP服务器不能为空!', {icon:2});
return false;
}
if (pdata['smtp_port'] == ''){
layer.msg('SMTP端口不能为空!', {icon:2});
return false;
}
if (pdata['username'] == ''){
layer.msg('用户名不能为空!', {icon:2});
return false;
}
if (pdata['password'] == ''){
layer.msg('授权码不能为空!', {icon:2});
return false;
}
if (pdata['to_mail_addr'] == ''){
layer.msg('发送地址不能为空!', {icon:2});
return false;
}
$.post('/config/set_notify',{'tag':'email', 'data':JSON.stringify(pdata)},function(rdata){
showMsg(rdata.msg, function(){
if (rdata.status){
layer.close(index);
}
},{icon:rdata.status?1:2},2000);
});
},
btn3:function(index){
var pdata = {};
pdata['smtp_host'] = $('input[name="smtp_host"]').val();
pdata['smtp_port'] = $('input[name="smtp_port"]').val();
pdata['smtp_ssl'] = $('input[name="smtp_ssl"]:checked').val();
pdata['username'] = $('input[name="username"]').val();
pdata['password'] = $('input[name="password"]').val();
pdata['to_mail_addr'] = $('input[name="to_mail_addr"]').val();
pdata['mail_test'] = $('textarea[name="mail_test"]').val();
if (pdata['smtp_host'] == ''){
layer.msg('SMTP服务器不能为空!', {icon:2});
return false;
}
if (pdata['smtp_port'] == ''){
layer.msg('SMTP端口不能为空!', {icon:2});
return false;
}
if (pdata['username'] == ''){
layer.msg('用户名不能为空!', {icon:2});
return false;
}
if (pdata['password'] == ''){
layer.msg('授权码不能为空!', {icon:2});
return false;
}
if (pdata['to_mail_addr'] == ''){
layer.msg('发送地址不能为空!', {icon:2});
return false;
}
if (pdata['mail_test'] == ''){
layer.msg('验证测试不能为空!', {icon:2});
return false;
}
$.post('/config/set_notify_test',{'tag':'email', 'data':JSON.stringify(pdata)},function(rdata){
showMsg(rdata.msg, function(){
if (rdata.status){
layer.close(index);
}
},{icon:rdata.status?1:2},2000);
});
return false;
}
});
});
}
function getPanelSSL(){
var loadT = layer.msg('正在获取证书信息...',{icon:16,time:0,shade: [0.3, '#000']});
$.post('/config/get_panel_ssl',{},function(cert){
+20
View File
@@ -161,7 +161,27 @@
<span class="set-info c7">Telegram Bot机器人通知【<b style="color:red;">国内可能无法使用</b>】</span>
</p>
<p class="mtb15">
<span class="set-tit text-right" title="绑定账号" style="float: left;">邮件通知</span>
<input id="cfg_email" name="cfg_email" onclick="setNotifyApi('email',this)" class="btswitch btswitch-ios" type="checkbox" {{data['notify_email_enable']}}>
<label class="btswitch-btn ml5" for="cfg_email" style="float: left;margin-top:4px;"></label>
<button ype="button" class="btn btn-default btn-xs panel_api_btn" style="vertical-align: middle; margin-left: 10px" onclick="getEmailCfg();">邮件配置</button>
<span class="set-info c7">邮件通知</span>
</p>
</div>
<!-- <div class="title c6 plr15"><h3 class="f16">VIP</h3></div>
<div class="setting-con pd15">
<p class="mtb15">
<span class="set-tit text-right" title="用户登录" style="float: left;">用户登录</span>
<input id="cfg_login" name="cfg_login" onclick="" class="btswitch btswitch-ios" type="checkbox">
<label class="btswitch-btn ml5" for="cfg_login" style="float: left;margin-top:4px;"></label>
<button ype="button" class="btn btn-default btn-xs" style="vertical-align: middle; margin-left: 10px" onclick="">绑定</button>
<span class="set-info c7">【<b style="color:red;">请勿使用</b>】(开发中)</span>
</p>
</div> -->
</div>
</div>
</div>
+11 -11
View File
@@ -82,16 +82,20 @@ if [ $OSNAME != "macos" ];then
# https://cdn.jsdelivr.net/gh/midoks/mdserver-web@latest/scripts/install.sh
if [ ! -d /www/server/mdserver-web ];then
if [ "$LOCAL_ADDR" != "common" ];then
curl --insecure -sSLo /tmp/master.zip https://gitee.com/midoks/mdserver-web/repository/archive/master.zip
if [ "$LOCAL_ADDR" == "common" ];then
curl --insecure -sSLo /tmp/master.zip ${HTTP_PREFIX}github.com/midoks/mdserver-web/archive/refs/heads/master.zip
cd /tmp && unzip /tmp/master.zip
mv -f /tmp/mdserver-web-master /www/server/mdserver-web
rm -rf /tmp/master.zip
rm -rf /tmp/mdserver-web-master
else
curl --insecure -sSLo /tmp/master.zip https://code.midoks.me/midoks/mdserver-web/archive/master.zip
mv -f /tmp/mdserver-web /www/server/mdserver-web
rm -rf /tmp/master.zip
rm -rf /tmp/mdserver-web
fi
cd /tmp && unzip /tmp/master.zip
mv -f /tmp/mdserver-web-master /www/server/mdserver-web
rm -rf /tmp/master.zip
rm -rf /tmp/mdserver-web-master
fi
# install acme.sh
@@ -112,11 +116,7 @@ fi
echo "use system version: ${OSNAME}"
if [ "${OSNAME}" == "macos" ];then
if [ "$LOCAL_ADDR" != "common" ];then
curl --insecure -fsSL https://code.midoks.me/midoks/mdserver-web/raw/branch/master/scripts/install/macos.sh | bash
else
curl --insecure -fsSL ${HTTP_PREFIX}https://raw.githubusercontent.com/midoks/mdserver-web/dev/scripts/install/macos.sh | bash
fi
curl --insecure -fsSL https://code.midoks.me/midoks/mdserver-web/raw/branch/master/scripts/install/macos.sh | bash
else
cd /www/server/mdserver-web && bash scripts/install/${OSNAME}.sh
fi
+11 -12
View File
@@ -85,14 +85,17 @@ if [ $OSNAME != "macos" ];then
if [ "$LOCAL_ADDR" == "common" ];then
curl --insecure -sSLo /tmp/dev.zip ${HTTP_PREFIX}github.com/midoks/mdserver-web/archive/refs/heads/dev.zip
cd /tmp && unzip /tmp/dev.zip
mv -f /tmp/mdserver-web-dev /www/server/mdserver-web
rm -rf /tmp/dev.zip
rm -rf /tmp/mdserver-web-dev
else
curl --insecure -sSLo /tmp/dev.zip https://code.midoks.me/midoks/mdserver-web/archive/dev.tar.gz
fi
cd /tmp && unzip /tmp/dev.zip
mv -f /tmp/mdserver-web-dev /www/server/mdserver-web
rm -rf /tmp/dev.zip
rm -rf /tmp/mdserver-web-dev
curl --insecure -sSLo /tmp/dev.zip https://code.midoks.me/midoks/mdserver-web/archive/dev.zip
cd /tmp && unzip /tmp/dev.zip
mv -f /tmp/mdserver-web /www/server/mdserver-web
rm -rf /tmp/dev.zip
rm -rf /tmp/mdserver-web
fi
fi
# install acme.sh
@@ -115,11 +118,7 @@ fi
echo "use system version: ${OSNAME}"
if [ "${OSNAME}" == "macos" ];then
if [ "$LOCAL_ADDR" != "common" ];then
curl --insecure -fsSL https://code.midoks.me/midoks/mdserver-web/raw/branch/master/scripts/install/macos.sh | bash
else
curl --insecure -fsSL ${HTTP_PREFIX}https://raw.githubusercontent.com/midoks/mdserver-web/dev/scripts/install/macos.sh | bash
fi
curl --insecure -fsSL https://code.midoks.me/midoks/mdserver-web/raw/branch/master/scripts/install/macos.sh | bash
else
cd /www/server/mdserver-web && bash scripts/install/${OSNAME}.sh
fi
+1 -1
View File
@@ -53,7 +53,7 @@ LOCAL_ADDR=common
ping -c 1 ipinfo.io > /dev/null 2>&1
if [ "$?" == "0" ];then
CN=$(curl -fsSL -m 10 http://ipinfo.io/json | grep "\"country\": \"CN\"")
if [ -z "$CN" ];then
if [ ! -z "$CN" ];then
LOCAL_ADDR=cn
HTTP_PREFIX="https://ghproxy.com/"
fi