void Awake() { instance = this; Messenger.AddListener <string>(GameEvents.EVT_UI_MESSAGE_POP.ToString(), GeneralMsgNotice); }
static async Task DoDifferentAction(string ip, string lastIp) { Log.Info($"检测到外网IP已变更,当前IP:{ip},历史IP:{lastIp}"); if (ConfigManager.Now.AppSettings.IsEnableEmailNotice) { if (string.IsNullOrEmpty(ConfigManager.Now.AppSettings.EmailApiConfig.Host) || string.IsNullOrEmpty(ConfigManager.Now.AppSettings.EmailApiConfig.Account) || string.IsNullOrEmpty(ConfigManager.Now.AppSettings.EmailApiConfig.Passwd)) { Log.Info($"邮件配置不正确,已跳过。"); } else { try { EmailNotice email = new EmailNotice(); (bool, string) result = email.Send(ip, lastIp); if (result.Item1) { Log.Info($"IP变更邮件提醒已发送,接收邮箱:{ConfigManager.Now.AppSettings.EmailApiConfig.ReceiveAddress}。"); } else { Log.Info($"IP变更邮件提醒发送失败,错误:{result.Item2}"); } } catch (Exception ex) { Log.Error(ex.Message, ex); } } } if (ConfigManager.Now.AppSettings.IsEnableMessageNotice) { if (string.IsNullOrEmpty(ConfigManager.Now.AppSettings.MessageApiConfig.AppKey) || string.IsNullOrEmpty(ConfigManager.Now.AppSettings.MessageApiConfig.MessageTemplate) || string.IsNullOrEmpty(ConfigManager.Now.AppSettings.MessageApiConfig.URL) || string.IsNullOrEmpty(ConfigManager.Now.AppSettings.MessageApiConfig.Mobile)) { Log.Info($"短信配置不正确,已跳过。"); } else { try { MessageNotice message = new MessageNotice(); (bool, string) result = await message.Send(ip, lastIp); if (result.Item1) { Log.Info($"IP变更短信提醒已发送,接收电话:{ConfigManager.Now.AppSettings.MessageApiConfig.Mobile}。"); } else { Log.Info($"IP变更短信提醒发送失败,错误:{result.Item2}"); } } catch (Exception ex) { Log.Error(ex.Message, ex); } } } if (ConfigManager.Now.DdnsConfig.IsEnableDdns) { if (ConfigManager.Now.DdnsConfig.Domains == null || ConfigManager.Now.DdnsConfig.Domains.Count == 0) { Log.Info($"未发现要设置DDNS的域名配置,DDNS已跳过。"); } if (ConfigManager.Now.DdnsConfig.DdnsServiceProviders == null || ConfigManager.Now.DdnsConfig.DdnsServiceProviders.Count == 0) { Log.Info($"未发现DDNS服务提供配置,DDNS已跳过。"); } else { try { new DomainDdnsService().UpdateDomainInfo(ip); } catch (Exception ex) { Log.Error(ex.Message, ex); } } } else { Log.Info($"DDNS已关闭,跳过域名DDNS。"); } }