2017-08-13 10 views
3

電報ボットを作成していますが、InlineKeyboardButtonオブジェクトを作成できません。c#InlineKeyboardButtonを作成できません

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Web; 
using Telegram.Bot.Types.InlineKeyboardButtons; 

namespace BuildAutomation.Controllers 
{ 
    public class Test 
    { 
     public TestMethod() 
    { 
     var none = new InlineKeyboardButton("No", "build|no"); 
     var yes = "Yes"; 
     var betaControl = new InlineKeyboardButton(yes, "build|betacontrol"); 
     var betaNode = new InlineKeyboardButton(yes, "build|betanode"); 
     var betaBoth = new InlineKeyboardButton(yes, "build|betaboth"); 

     InlineKeyboardMarkup menu; 

     menu = new InlineKeyboardMarkup(new[] { betaBoth, none }); 
    } 
    } 
} 

私はInlineKeyboardButton 『"抽象クラスやインタフェースのインスタンスを作成できません』エラーを取得しておきます。私はInlineKeyboardButtonは抽象クラスですが、InlineKeyboardButtonのオブジェクトを作成する多くの例があります。

私は何かを見逃しましたか? InlineKeyboardButton

example 1

example 2

example 3

答えて

3

インスタンス化は、直接以前バージョンで正しかったです。 約1ヶ月前に新しいコミットがあり、これはその後InlineKeyboardButtonが抽象化されていることを示します。代わりに派生クラスを使用する必要があります。 InlineKeyboardUrlButton,InlineKeyboardPayButtonなどはすべてInlineKeyboardButtonに由来します。 例のリポジトリはまだ更新されていないようです。

言及したの詳細について確認し、このリンクはコミット: https://github.com/TelegramBots/telegram.bot/commit/ddaa8b74e3ab5eab632dbe2e8916c2fe87b114a3

2

例の使用InlineKeyboardCallbackButtInlineKeyboardCallbackButton("Yes", "CallBackData")代わりのInlineKeyboardButton("Yes", "CallbackData")

関連する問題