| 12345678910111213141516171819202122232425262728293031323334 |
- package com.cyksj.service.telegram;
- import cn.hutool.http.HttpUtil;
- import com.cyksj.common.util.Jsons;
- import com.cyksj.dto.RedisKey;
- import com.cyksj.model.request.TelegramBotMsgReq;
- import com.cyksj.redis.RedisService;
- import lombok.RequiredArgsConstructor;
- import lombok.extern.slf4j.Slf4j;
- import org.springframework.stereotype.Service;
- /**
- * @author chan
- * @date 2023/9/12 14:17
- */
- @Service
- @RequiredArgsConstructor
- @Slf4j
- public class TelegramService {
- private final String URL = "https://yinhedvd.com/8082/api/movies/sendMsg";
- private final RedisService redisService;
- public void sendMsg(TelegramBotMsgReq botMsg) throws Exception {
- Boolean flag = redisService.hasKey(RedisKey.TELEGRAM_BOT_MSG);
- if(!flag){
- log.info("电报购买推送 推送内容:{}",botMsg);
- HttpUtil.post(URL, Jsons.toJson(botMsg));
- redisService.set(RedisKey.TELEGRAM_BOT_MSG,1,60L*3L);
- }else {
- log.info("推送未间隔2分钟,暂不推送.");
- }
- }
- }
|