This commit is contained in:
2021-02-05 21:17:50 +03:00
parent 384d8eae9d
commit 0908f2bb7f
2 changed files with 15 additions and 5 deletions
-2
View File
@@ -3,8 +3,6 @@ using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Text.Json.Serialization;
using Newtonsoft.Json;
using RgDevBot.Config;
using RgDevBot.ObjectModel;
+15 -3
View File
@@ -6,13 +6,25 @@ namespace RgDevBot
public class TelegramBot
{
private readonly TelegramBotClient _telegram;
public string Token => "1479535614:AAFqHdsUFikzOti0zknK_pN2sEONNAXecPY";
public long MainChatId;
public TelegramBot(long chatId = -1001448086132)
public TelegramBot()
{
var token = Environment.GetEnvironmentVariable("TELEGRAM_TOKEN");
if (string.IsNullOrEmpty(token))
{
Console.WriteLine("Please define TELEGRAM_TOKEN variable.");
return;
}
int.TryParse(Environment.GetEnvironmentVariable("TELEGRAM_CHAT_ID"), out var chatId);
if (chatId == 0)
{
Console.WriteLine("Please define TELEGRAM_CHAT_ID variable.");
return;
}
MainChatId = chatId;
_telegram = new TelegramBotClient(Token);
_telegram = new TelegramBotClient(token);
_telegram.OnMessage += Bot_OnMessage;
_telegram.StartReceiving();
}