如果设置了时间检测,C#bot自动发送消息 [英] C# bot Auto send a message if the time detect is set

查看:127
本文介绍了如果设置了时间检测,C#bot自动发送消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不知道该怎么问,但这是我想要的,我有一个固定的时间.

I dont know how to ask, but this is what i want, i have a set time.

int nyhours = 14;
int mymin = 00;
int mysec = 00;
TimeSpan stime = new TimeSpan(nyhours, mymin, mysec);
TimeSpan timeNow = DateTime.Now.TimeOfDay;
TimeSpan trimmedTimeNow = new TimeSpan(timeNow.Hours, timeNow.Minutes, timeNow.Seconds);

,我想在Skype中自动聊天.这是我的代码.

and i want to chat automatically in the skype. This is my code.

if (stime == trimmedTimeNow)
{
  await context.PostAsync($"Good day guys please what is the status of your work? :)");
}

该代码不起作用.如何修复该代码?请帮忙.我说错了吗?

that code is not working. How to fix that codes? please help. Did I make it wrong?

推荐答案

如果设置了时间检测,则自动发送消息

Auto send a message if the time detect is set

您似乎想设置一个计时器或提醒时间,以便通过机器人到达该时间时通知用户.您的漫游器不会每秒将当前时间与指定时间进行比较,因此它可能不满足条件stime == trimmedTimeNow.

You seem to want to set a timer or reminder to notify the user when the time arrives via your bot. Your bot would not compare current time with specified time every second, so it might not fulfill the condition stime == trimmedTimeNow.

要满足您的要求,您可以在bot应用程序中尝试从用户消息中提取数据,例如conversationIdchannelIdRecipient.IdServiceUrl等,并将数据保存在某些存储区中.然后,您可以使用并运行Azure函数或WebJob来发送带有附加收件人信息的消息.

To achieve your requirement, in your bot application, you can try to extract data from the user's message, such as conversationId, channelId, Recipient.Id, ServiceUrl etc, and save the data in some store. And then you can use and run an Azure Function or WebJob to send messages with attached recipient info.

这篇文章中,您可以找到有关主动型bot的更多详细信息,可以根据您的方案和要求参考它来实施主动型bot.

In this article, you can find more detailed information about proactive bot, you can refer to it to implement a proactive bot based on your scenarios and requirements.

这篇关于如果设置了时间检测,C#bot自动发送消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆