| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- using Microsoft.AspNetCore.Http;
- using Microsoft.AspNetCore.Mvc.Controllers;
- using Microsoft.AspNetCore.Mvc.Filters;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using dodohold.core;
- namespace molilian.core
- {
- public partial class NotifyCore
- {
- static string _base_url = string.Empty;
- static string _anpush_url = string.Empty;
- static NotifyCore()
- {
- _anpush_url = Environment.GetEnvironmentVariable("ANPush");
- string? publish_url = Environment.GetEnvironmentVariable("NtfyServer");
- if (!string.IsNullOrEmpty(publish_url))
- {
- _base_url = publish_url;
- }
- }
- public static void Notify(string message)
- {
- if (!string.IsNullOrEmpty(_base_url))
- {
- NifyPlus.Send(_base_url, new NifyMessage { message = message });
- }
- }
- public static void Notify(NifyMessage message)
- {
- if (!string.IsNullOrEmpty(_base_url))
- {
- NifyPlus.Send(_base_url, message);
- }
- }
- public static void AnPushNotify(string title, string content)
- {
- #if DEBUG
- #else
- if (!string.IsNullOrEmpty(_anpush_url))
- {
- string url = _anpush_url;
- url = url.Replace("{title}", title?.UrlEncode());
- url = url.Replace("{content}", content?.UrlEncode());
- try
- {
- url.HttpRequest();
- }
- catch (Exception ex) { }
- }
- #endif
- }
- }
- }
|