我是电报机器人的新手,并将这段代码写入来自机器人的检查信息:
var updates = await Bot.GetUpdatesAsync(offset);
foreach (var update in updates)
{
if (update.Message.Text.Contains("hi") || update.Message.Text.Contains("Hi"))
{
//for first time that code work correct but after 4 hourse in this line
var updates = await Bot.GetUpdatesAsync(offset);
}
}
得到错误,但我无法读取错误,因为1分钟后重置Visual studio错误解决了,发生了什么?我怎么能解决这个问题?谢谢。
答案 0 :(得分:0)
如果您使用桌面应用程序,最好使用每1秒调用一次代码的计时器
private void timer1_Tick(object sender, EventArgs e)
{
yourGetUpdateFunc();
}
void yourGetUpdateFunc(){
var updates = await Bot.GetUpdatesAsync(offset);
foreach (var update in updates)
{
if (update.Message.Text.Contains("hi") || update.Message.Text.Contains("Hi"))
{
// do work
}
}
}