写tg bot时出错.该怎么办?



在StartReceiving行显示以下错误:

项目文件字符串抑制状态以下方法或属性的调用有歧义:"Telegram.Bot.TelegramBotClientPollingExtensions.StartReceiving (Telegram.Bot。ITelegramBotClient System.Func<Telegram.Bot。ITelegramBotClient>

整个代码:

using System;
using System.Threading.Tasks;
using Telegram.Bot;
using Telegram.Bot.Types;
using System.Threading;
namespace Telegram_bot_Secret
{
internal class Program
{
static void Main()
{
var client = new TelegramBotClient("TOKEN");
client.StartReceiving(Update, null);
Console.ReadLine();
}

async static Task Update(ITelegramBotClient botClient, Update update, CancellationToken tocen)
{
var message = update.Message;
if (message.Text != null)
{
if (message.Text.ToLower().Contains("Hello"))
{
await botClient.SendTextMessageAsync(message.Chat.Id, "Hello?");
return;
}
}
Console.ReadKey();
}
}
}

互联网上没有一个帖子能帮助解决这个问题。

编译器不知道你要使用哪个StartReceiving重载。为你的参数命名可能会有帮助

StartReceiving(parameter1Name: xxx, paramter2Name: xxx) 

特别是当使用null时,这可能会发生,null可以用于很多参数。

边注

message.Text.ToLower().Contains("Hello")

不能正常工作,如果你使用了小写字母("hello")

最新更新