如何通过注册为渠道管理员的机器人访问电报频道消息?
我试图从Telegram频道获取所有消息并将它们显示在ASP.NET网页中(c#)
当新消息直接发送到机器人时,我能够获得更新:
var json = wc.DownloadString(" https://api.telegram.org/bot<token>/getUpdates");
Run Code Online (Sandbox Code Playgroud)
但它不适用于频道.
我必须使用子列表更新我的实体,如下所示:
public class Entity1
{
int Id{get;set;}
ObservableCollection<Child1> ChildrenList {get;set;}
string Name{get;set;}
}
public class Child1
{
string Nome{get;set;}
string Cognome {get;set;}
}
Run Code Online (Sandbox Code Playgroud)
我用这种方式实现了补丁方法:
[AcceptVerbs("PATCH", "MERGE")]
public async Task<IHttpActionResult> Patch([FromODataUri] int key, Delta<Entity1> entityDelta)
{
if (!ModelState.IsValid)
{
return BadRequest(ModelState);
}
var entity = await Context.Entity1.FindAsync(key);
if (entity == null)
{
return NotFound();
}
entityDelta.Patch(entity);
try
{
await Context.SaveChangesAsync();
}
catch (DbUpdateConcurrencyException)
{
return NotFound();
}
return Updated(entity);
}
Run Code Online (Sandbox Code Playgroud)
但是当我尝试以这种方式从提琴手调用它时:
Url: http://localhost/odata4/Entity1(1)/ with patch request
Request Headers: Content-Type: application/json
Request …
Run Code Online (Sandbox Code Playgroud)