mdserver-web/plugins/tgbot/startup/extend/push_notice_msg.py

118 lines
3.8 KiB
Python
Raw Permalink Normal View History

2023-03-16 06:42:42 -04:00
# coding:utf-8
import sys
import io
import os
import time
import re
import json
import base64
import threading
2024-12-01 13:33:32 -05:00
web_dir = os.getcwd() + "/web"
if os.path.exists(web_dir):
sys.path.append(web_dir)
os.chdir(web_dir)
import core.mw as mw
2023-03-16 06:42:42 -04:00
import telebot
from telebot import types
from telebot.util import quick_markup
2023-03-16 10:36:25 -04:00
# 轮播实例
2023-03-18 12:20:23 -04:00
chat_id = -1001578009023
# chat_id = 5568699210
2023-05-08 21:17:54 -04:00
def writeLog(log_str):
if __name__ == "__main__":
print(log_str)
now = mw.getDateFromNow()
log_file = mw.getServerDir() + '/tgbot/task.log'
mw.writeFileLog(now + ':' + log_str, log_file, limit_size=5 * 1024)
return True
2023-03-18 12:20:23 -04:00
def send_msg(bot, tag='ad', trigger_time=300):
# 信号只在一个周期内执行一次|start
lock_file = mw.getServerDir() + '/tgbot/lock.json'
if not os.path.exists(lock_file):
mw.writeFile(lock_file, '{}')
lock_data = json.loads(mw.readFile(lock_file))
if tag in lock_data:
diff_time = time.time() - lock_data[tag]['do_time']
if diff_time >= trigger_time:
lock_data[tag]['do_time'] = time.time()
else:
return False, 0, 0
else:
lock_data[tag] = {'do_time': time.time()}
mw.writeFile(lock_file, json.dumps(lock_data))
# 信号只在一个周期内执行一次|end
2025-12-19 02:42:20 -05:00
# 实名认证/过人脸🕵️‍♀️各种账号处理✅ | 30/m| next,6/30 | @nngzs
2026-01-11 22:23:13 -05:00
# 18+资源采集| 4/m | next,7/14 | @liuxingyu123
2026-03-17 06:41:35 -04:00
# 海内外实名KYC-执照代付✅域名| 17/m | next,6/17 | @kdgzs
2026-05-21 05:35:19 -04:00
# 98影视采集| 21/m | next,11/21 | @liuxingyu123
2025-11-06 03:11:22 -05:00
2023-03-18 12:20:23 -04:00
keyboard = [
[
types.InlineKeyboardButton(
2026-04-02 22:51:29 -04:00
text="海内外实名KYC-执照代付✅域名", url='https://t.me/kuadugongzuoshi')
2026-03-17 06:08:50 -04:00
],
[
types.InlineKeyboardButton(
2025-07-11 03:34:42 -04:00
text="高价收一切流量 @caifutong555", url='https://t.me/caifutong555')
2025-07-11 03:28:57 -04:00
],
[
types.InlineKeyboardButton(
2025-07-03 20:40:56 -04:00
text="18+资源采集", url='https://ckzy1.com')
],
[
types.InlineKeyboardButton(
2023-12-29 11:04:39 -05:00
text="实名认证/过人脸🕵️‍♀️各种账号处理✅", url='https://t.me/niuniu234')
],
2023-03-28 08:18:52 -04:00
[
types.InlineKeyboardButton(
2023-06-10 03:09:31 -04:00
text="官网", url='https://github.com/midoks/mdserver-web'),
2023-04-20 00:19:33 -04:00
types.InlineKeyboardButton(
2023-03-18 12:20:23 -04:00
text="💎DigitalVirt(赞助商)", url='https://digitalvirt.com/aff.php?aff=154')
],
[
types.InlineKeyboardButton(
2023-11-30 23:09:20 -05:00
text="论坛", url='https://bbs.midoks.icu'),
2023-03-18 12:20:23 -04:00
types.InlineKeyboardButton(
2023-11-30 23:09:20 -05:00
text="搜索", url='https://bbs.midoks.icu/search.php'),
2023-03-29 01:17:38 -04:00
types.InlineKeyboardButton(
2023-04-16 08:50:30 -04:00
text="@ME", url='tg://user?id=5568699210'),
types.InlineKeyboardButton(
2025-07-20 01:31:18 -04:00
text="300RMB/月", url='tg://user?id=5568699210')
2023-03-18 12:20:23 -04:00
]
]
markup = types.InlineKeyboardMarkup(keyboard)
2023-03-29 01:17:38 -04:00
msg_notice = "由于在解决的问题的时候不给信息无法了解情况。以后不再群里回答技术问题。全部去论坛提问。在解决问题的过程中可能需要面板信息和SSH信息如无法提供请不要提问。为了让群里都知晓。轮播一年\n"
2023-08-20 12:12:30 -04:00
msg_notice += "为了不打扰双方私聊解决问题先转1000U否则无视!\n"
2023-03-29 01:17:38 -04:00
msg = bot.send_message(chat_id, msg_notice, reply_markup=markup)
2023-03-16 06:42:42 -04:00
# print(msg.message_id)
2023-05-28 07:00:42 -04:00
time.sleep(90)
2023-03-22 05:01:50 -04:00
try:
bot.delete_message(
chat_id=chat_id, message_id=msg.message_id)
except Exception as e:
pass
2023-03-16 06:42:42 -04:00
def run(bot):
2023-03-29 23:22:19 -04:00
try:
2023-05-28 07:00:42 -04:00
send_msg(bot, 'notice_msg', 90)
2023-03-29 23:22:19 -04:00
except Exception as e:
writeLog('-----push_notice_msg error start -------')
print(mw.getTracebackInfo())
writeLog('-----push_notice_msg error start -------')