TeleTok/Program.cs

43 lines
1.4 KiB
C#
Raw Normal View History

2023-02-13 16:34:22 -05:00
using Microsoft.Extensions.Configuration;
using System;
namespace TeleTok
{
2023-02-14 12:04:24 -05:00
public class TeleTok
2023-02-13 16:34:22 -05:00
{
2023-02-14 12:04:24 -05:00
public static IConfigurationRoot config = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("config.json", true)
.Build();
2023-02-13 16:34:22 -05:00
2023-02-14 12:04:24 -05:00
public static string token = config.GetSection("TeleTokConf:token").Value;
public static string ptInstance = config.GetSection("TeleTokConf:proxitokInstance").Value;
2023-02-13 16:34:22 -05:00
2023-02-14 12:04:24 -05:00
static async Task Main(string[] args)
{
2023-02-15 13:53:47 -05:00
//Checks if the config json data is valid
if(token == "" || token == null || token == "INSERT TOKEN HERE")
{
LogMessage("Telegram bot token is invalid! Exiting...");
}
else if(ptInstance == "" || ptInstance == null || ptInstance == "PROXITOK INSTANCE URL")
{
LogMessage("Proxitok instance is invalid! Exiting...");
}
else
{
TelegramListener listener = new TelegramListener();
2023-02-15 16:33:45 -05:00
LogMessage("Now listening...");
2023-02-14 13:59:20 -05:00
2023-02-15 13:53:47 -05:00
listener.RunListener();
}
2023-02-13 16:34:22 -05:00
}
2023-02-15 12:17:08 -05:00
public static void LogMessage(string text)
{
DateTime now =DateTime.Now;
Console.WriteLine("[" + now.ToString() + "] " + text);
}
2023-02-13 16:34:22 -05:00
}
}