我想使用 Microsoft Bot Framework (C#) 构建简单的 Telegram bot 我现在要做的是创建一个列表,该列表可由群聊中的每个人填写。我想要的结果:user a: /add hellouser b: /add worlduser a: /showbot: hello worlduser b: /showbot: hello world但我现在拥有的是:user a: /add hellouser b: /add worlduser a: /showbot: hellouser b: /showbot: world[Serializable]public class RootDialog : IDialog<object>{ private List<string> list = new List<string>(); public Task StartAsync(IDialogContext context) { context.Wait(MessageReceivedAsync); return Task.CompletedTask; } private async Task MessageReceivedAsync(IDialogContext context, IAwaitable<object> result) { var activity = await result as Activity; switch (Parser.GetCommand(activity)) { case "/add": AddNewThingToList(activity); break; case "/show": ShowList(context); break; } context.Wait(MessageReceivedAsync); } private void AddNewThingToList(Activity activity) { list.Add(Parser.GetAfterCommandText(activity)); } private void ShowList(IDialogContext context) { var response = new StringBuilder(); for (var i = 0; i < list.Count; i++) { response.Append($"{i}. {list[i]}{Environment.NewLine}"); } context.PostAsync(response.ToString()); }}创建公共列表的最简单方法是什么?
1 回答
- 1 回答
- 0 关注
- 103 浏览
添加回答
举报
0/150
提交
取消