sync
This commit is contained in:
45
SignalsTestCmd/Messenger.cs
Normal file
45
SignalsTestCmd/Messenger.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Telegram.Bot;
|
||||
using Telegram.Bot.Exceptions;
|
||||
using Telegram.Bot.Polling;
|
||||
using Telegram.Bot.Types;
|
||||
using Telegram.Bot.Types.Enums;
|
||||
|
||||
namespace SignalsTest
|
||||
{
|
||||
public class Messenger
|
||||
{
|
||||
TelegramBotClient botClient;
|
||||
|
||||
private static Messenger m_instance;
|
||||
public static Messenger instance { get { if (m_instance == null) { m_instance = new Messenger(); } return m_instance; } }
|
||||
|
||||
public async Task SendMessage(string text, string chat = "@doralockscryptosignals")
|
||||
{
|
||||
await botClient.SendTextMessageAsync(chat, text);
|
||||
}
|
||||
|
||||
public async Task SendLastChart(string chat = "@doralockscryptosignals"){
|
||||
FileStream fsSource = new FileStream("/var/www/html/test.png", FileMode.Open, FileAccess.Read);
|
||||
InputFile photo = InputFile.FromStream(fsSource);
|
||||
await botClient.SendPhotoAsync(chat, photo);
|
||||
Console.WriteLine("Photo sent success");
|
||||
}
|
||||
|
||||
public Messenger()
|
||||
{
|
||||
botClient = new TelegramBotClient("6878629725:AAGWFqmtsvf2xFLOTvsixY-LEG4ho2sLqrw");
|
||||
using CancellationTokenSource cts = new();
|
||||
|
||||
// StartReceiving does not block the caller thread. Receiving is done on the ThreadPool.
|
||||
ReceiverOptions receiverOptions = new()
|
||||
{
|
||||
AllowedUpdates = Array.Empty<UpdateType>() // receive all update types except ChatMember related updates
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user