public void ParseMsg(string msg) { try { if (!CommonUtil.IsValidCMD(ref msg)) { return; } Cmd cmd = CommonUtil.GetCmd(msg); bool isInternalCmd = CommonUtil.IsInternalCmd(cmd.Name); this.taskInfo = msg; if (isInternalCmd) {//内部命令 InternalCmdExecutor intercmder = new InternalCmdExecutor(this, new InterCmd(cmd.Name, cmd.Para)); intercmder.Execute(); } else { if (PluginMgr.IsContainsCmd(cmd.Name)) { Iplugin p = PluginMgr.GetPlugin(cmd.Name); this.needParseResult = p.NeedParseResult; Executor executor = new TaskExecutor(this, cmd.Para, p); executor.Execute(); } } } catch (Exception ex) { RobotCore.Log.Error(ex.ToString()); } }
private void SendSuggest() { string suggestStr = "目前支持的命令:" + Environment.NewLine; suggestStr += PluginMgr.GetPluginListDescription(); Send(suggestStr); }
private static void AsyncSendEmail(object obj) { string[] arr = (string[])obj; if (arr == null || arr.Length < 2) { RobotCore.Log.Warn("AsyncSendEmail by Invid arg"); } else { string title = arr[0]; string msg = arr[1]; string to = arr[2]; Iplugin p = PluginMgr.GetPlugin("mail"); if (string.IsNullOrEmpty(to)) { to = p.Remark; } if (p != null) { p.Execute(to, title, msg); } else { Log.Warn("Can not find mail plugin dll,send to:" + to + ",title:" + title + Environment.NewLine + msg + " failed!"); } } }
public void ParseMsg(string msg) { try { RobotCore.Log.Info(string.Format("{0}对你的Fetion机器人说:{1}", contact.DisplayName, msg)); bool isPermitUser = RobotCore.PermissionMgr.IsPermitUser(conversation.From.ToString()); bool isValidCmd = CommonUtil.IsValidCMD(ref msg); if (!isValidCmd) { SendCmdInvalid(); return; } Cmd cmd = CommonUtil.GetCmd(msg); bool isInternalCmd = CommonUtil.IsInternalCmd(cmd.Name); if (isInternalCmd) {//内部命令 if (!isPermitUser && !CommonUtil.IsOpenInternalCmd(cmd.Name)) { SendSuggest(); } else { InternalCmdExecutor intercmder = new InternalCmdExecutor(this, new InterCmd(cmd.Name, cmd.Para)); intercmder.Execute(); } } else {//插件命令 bool hasPlugin = PluginMgr.IsContainsCmd(cmd.Name); if (hasPlugin) { Iplugin p = PluginMgr.GetPlugin(cmd.Name); if (!isPermitUser && p.IsHostOnly) {//未授权用户执行特定需授权插件中的命令 this.Send(string.Format("这个命令只有主人才能执行哦(w)")); return; } Executor executor = new ConvExecutor(this, cmd.Para, p); executor.Execute(); } else { SendSuggest(); } } } catch (Exception ex) { WriteLog("RobotConvAnalyzer ParseMsg occur error:" + ex.ToString());; } }