-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
yu lkiu
committed
May 20, 2023
1 parent
bd8d9b1
commit 4e670e1
Showing
10 changed files
with
141 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
using DbusSmsForward.SendMethod; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace DbusSmsForward.ProcessUserSend | ||
{ | ||
public class ProcessSend | ||
{ | ||
public static void sendSms(string sendMethodGuideResult,string tel,string body) | ||
{ | ||
try | ||
{ | ||
if (sendMethodGuideResult == "1") | ||
{ | ||
SendByEmail.SendSms(tel, body); | ||
} | ||
if (sendMethodGuideResult == "2") | ||
{ | ||
SendByPushPlus.SendSms(tel, body); | ||
} | ||
if (sendMethodGuideResult == "3") | ||
{ | ||
SendByWeComApplication.SendSms(tel, body); | ||
} | ||
if (sendMethodGuideResult == "4") | ||
{ | ||
SendByTelegramBot.SendSms(tel, body); | ||
} | ||
} | ||
catch(Exception e) | ||
{ | ||
Console.WriteLine(e.Message); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
using DbusSmsForward.Helper; | ||
using Newtonsoft.Json.Linq; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Configuration; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace DbusSmsForward.SendMethod | ||
{ | ||
public static class SendByTelegramBot | ||
{ | ||
public static void SetupTGBotInfo() | ||
{ | ||
string TGBotToken = ConfigurationManager.AppSettings["TGBotToken"]; | ||
string TGBotChatID = ConfigurationManager.AppSettings["TGBotChatID"]; | ||
|
||
if (string.IsNullOrEmpty(TGBotToken) && string.IsNullOrEmpty(TGBotChatID)) | ||
{ | ||
Configuration cfa = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); | ||
Console.WriteLine("首次运行请输入TG机器人Token:"); | ||
TGBotToken = Console.ReadLine().Trim(); | ||
cfa.AppSettings.Settings["TGBotToken"].Value = TGBotToken; | ||
Console.WriteLine("首次运行请输入机器人要转发到的ChatId"); | ||
TGBotChatID = Console.ReadLine().Trim(); | ||
cfa.AppSettings.Settings["TGBotChatID"].Value = TGBotChatID; | ||
cfa.Save(); | ||
} | ||
} | ||
|
||
public static void SendSms(string number, string body) | ||
{ | ||
ConfigurationManager.RefreshSection("appSettings"); | ||
string TGBotToken = ConfigurationManager.AppSettings["TGBotToken"]; | ||
string TGBotChatID = ConfigurationManager.AppSettings["TGBotChatID"]; | ||
string url = "https://api.telegram.org/bot" + TGBotToken + "/sendMessage?chat_id=" + TGBotChatID + "&text="; | ||
url += System.Web.HttpUtility.UrlEncode(body); | ||
string msgresult = HttpHelper.HttpGet(url); | ||
JObject jsonObjresult = JObject.Parse(msgresult); | ||
string status = jsonObjresult["ok"].ToString(); | ||
if (status == "True") | ||
{ | ||
Console.WriteLine("TGBot转发成功"); | ||
} | ||
else | ||
{ | ||
Console.WriteLine(jsonObjresult["error_code"].ToString()); | ||
Console.WriteLine(jsonObjresult["description"].ToString()); | ||
} | ||
|
||
} | ||
|
||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters