微信自动回复时最好能够提供帮助信息
一、 第一种帮助形式
/// <summary>
/// 响应文本消息
/// </summary>
/// <param name="xml"></param>
/// <returns></returns>
private string OnReceiveTextMsg(string xml)
{
WxTextMsg msg = XmlEntityExchange<WxTextMsg>.ConvertXml2Entity(xml);
//返回消息,互换收发用户
string toUser = msg.FromUserName;
msg.FromUserName = msg.ToUserName;
msg.ToUserName = toUser;
switch (msg.Content.Trim())
{
case "?":
msg.Content = HelpDocument();
break;
case "?":
msg.Content = HelpDocument();
break;
case "1":
msg.Content = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
break;
case "2":
msg.Content = Tools.HttpCrossDomain.Get("http://www.weather.com.cn/data/sk/101210301.html");
break;
case "3":
msg.Content = "来吧,想唠点什么呢? [偷笑]";
break;
case "你是男的女的":
msg.Content = "姑娘一枚 [偷笑]";
break;
default:
msg.Content = "抱歉哦,我不认识您输入的命令。/害羞 /:,@-D";
break;
}
return XmlEntityExchange<WxTextMsg>.ConvertEntity2Xml(msg);
}
/// <summary>
/// 获取帮助菜单文档
/// </summary>
/// <returns></returns>
private string HelpDocument()
{
StringBuilder sb = new StringBuilder();
sb.Append("HI,请回复数字,选择服务").Append("\n\n");
sb.Append("1. 当前时间").Append("\n");
sb.Append("2. 天气信息").Append("\n");
sb.Append("3. 聊天唠嗑").Append("\n");
sb.Append("n. 更多服务开发中...").Append("\n");
sb.Append("回复【?】显示此帮助菜单");
return sb.ToString();
}
二、第二种帮助形式
public static class ReadXml { //输出字符串并结束当前页面进程 MVC必须加return public static string Menu() { string Content = ""; Content += "欢迎使用XXXX/微笑\n\n"; Content += "输入以下序号开始获取最新信息:\n"; Content += "1,新闻30分\n"; Content += "2,电影预告\n"; Content += "3,今日说法\n"; Content += "4,焦点访谈\n"; Content += "5,新闻联播\n"; Content += "输入?或帮助 可以显示此菜单"; return Content; } }
if (text == "?" || text == "?" || text == "帮助") { mT.Content = ReadXml.Menu(); }