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

71 lines
2.1 KiB
Python
Raw 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
sys.path.append(os.getcwd() + "/class/core")
import mw
import telebot
from telebot import types
from telebot.util import quick_markup
2023-03-16 10:36:25 -04:00
# 轮播实例
2023-03-16 06:42:42 -04:00
chat_id = -1001578009023
# chat_id = 5568699210
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
keyboard = [
[
types.InlineKeyboardButton(
text="为了不打扰双方私聊解决问题先转100U否则无视!", url='tg://user?id=5568699210')
],
[
types.InlineKeyboardButton(
2023-03-18 06:32:30 -04:00
text="💎DigitalVirt(赞助商)", url='https://digitalvirt.com/aff.php?aff=154')
],
[
types.InlineKeyboardButton(
2023-03-16 06:42:42 -04:00
text="论坛", url='https://bbs.midoks.me'),
types.InlineKeyboardButton(
text="搜索", url='https://bbs.midoks.me/search.php')
]
]
2023-03-16 06:48:19 -04:00
markup = types.InlineKeyboardMarkup(keyboard)
2023-03-16 06:42:42 -04:00
msg = bot.send_message(
2023-03-16 10:36:25 -04:00
chat_id, "由于在解决的问题的时候不给信息无法了解情况。以后不再群里回答技术问题。全部去论坛提问。在解决问题的过程中可能需要面板信息和SSH信息如无法提供请不要提问。为了让群里都知晓。轮播一年", reply_markup=markup)
2023-03-16 06:42:42 -04:00
# print(msg.message_id)
2023-03-18 06:32:30 -04:00
time.sleep(20)
2023-03-16 06:42:42 -04:00
del_msg = bot.delete_message(chat_id=chat_id, message_id=msg.message_id)
# print(del_msg)
def run(bot):
2023-03-18 06:32:30 -04:00
send_msg(bot, 'tmp_msg', 90)