public frmTelegramBotSetting()
        {
            InitializeComponent();
            var a = TelegramBotSettingBussines.GetAll();

            cls = a.Count > 0 ? a[0] : new TelegramBotSettingBussines();
        }
Ejemplo n.º 2
0
        public async Task StartSending(TelegramSendType type, string token = "", string chatId = "", string fileName = "", string caption = "", string smsReciver = "", string smsText = "")
        {
            var allPrx = await ProxyBussines.GetAllAsync();

            foreach (var item in allPrx)
            {
                try
                {
                    var socks5 = new HttpToSocks5Proxy(item.Server, item.Port, item.UserName, item.Password)
                    {
                        ResolveHostnamesLocally = false
                    };
                    var mtpropto = new WebProxy(Address: item.Server)
                    {
                        Credentials = new NetworkCredential(item.UserName, item.Password)
                    };
                    var a   = TelegramBotSettingBussines.GetAll();
                    var cls = a.Count > 0 ? a[0] : new TelegramBotSettingBussines();
                    if (string.IsNullOrEmpty(cls.Token) || string.IsNullOrEmpty(cls.ChanelForAds))
                    {
                        return;
                    }
                    token = cls.Token;
                    bot   = item.Type == ProxyType.Socks5
                        ? new TelegramBotClient(token, socks5)
                        : new TelegramBotClient(token, mtpropto);
                    if (type == TelegramSendType.SendBackUp)
                    {
                        await Send_(bot, fileName, cls.ChanelForAds, 10);
                    }
                    else
                    {
                        await Send_(bot, chatId : chatId, passage : caption, picPath : fileName, tryCount : 10,
                                    smsReciver : smsReciver, smsText : smsText);
                    }

                    break;
                }
                catch
                {
                    continue;
                }
            }
        }