C# телеграмм-бот получает ошибку «сбой вызова SSPI» - PullRequest
0 голосов
/ 14 апреля 2020

ТАК Я создаю свой первый бот Telegram, используя C# вот мой код:

using System;
using System.Net;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading;
using System.Windows.Forms;

namespace k4rn46ebot{
public partial class Form1 : Form
{

    private static string TOKEN = "";
    private Thread botThread;
    Telegram.Bot.TelegramBotClient bot;
    public Form1()
    {
        InitializeComponent();
    }

    private void Form1_Load(object sender, EventArgs e)
    {

    }

    private void btnstart_Click(object sender, EventArgs e)
    {
        TOKEN = ttoken.Text;
        botThread = new Thread(new ThreadStart(runBot));
        botThread.Start();
    }
    void runBot() {
        bot = new Telegram.Bot.TelegramBotClient(TOKEN);
        this.Invoke(new Action(() =>
        {
            lblstatus.Text = "Online";
            lblstatus.ForeColor = Color.Green;
        }));
        int offset = 0;
        while (true)
        {
            Telegram.Bot.Types.Update[] update = bot.GetUpdatesAsync(offset).Result;
            foreach (var up in update)
            {
                offset = up.Id + 1;
                if (up.Message == null)
                {
                    continue;
                }
                var message = up.Message.Text.ToLower();
                var from = up.Message.From;
                var chatid = up.Message.Chat.Id;

                if (message.Contains("/start"))
                {
                    StringBuilder sb = new StringBuilder();
                    sb.AppendLine(from.Username + "welcome to K4RN46E BOT");
                    bot.SendTextMessageAsync(chatid, sb.ToString());
                }
            }
        }
    }

    private void Form1_FormClosing(object sender, FormClosingEventArgs e)
    {
        botThread.Abort();
    }
}

}

Я получаю следующую ошибку: «необработанное исключение типа» system.aggregateexception «произошла ошибка в mscorlib.dll»: Telegram.Bot.Types.Update [] update = bot.GetUpdatesAsyn c (смещение) .Result;

На вкладке событий MS Visual Studio 2015 Я получаю: «Возникло исключение:« System.Security.Authentication.AuthenticationException »в System.dll (« Ошибка вызова SSPI, см. Внутреннее исключение. »)», А внутреннее исключение говорит: «Возникло исключение:» System.Security.Authentication.AuthenticationException 'в System.dll ("Ошибка вызова SSPI, см. Внутреннее исключение.") "Тоже.

Может кто-нибудь объяснить, почему я могу получить эту ошибку и что мне делать Исправить это? это мое событие windows: MS Viasual Studio 2015 Events

...