public LocalCommandDispatcher(OfflineCommandDispatcher inner, ICommandHandlerCollection handlers) { Ensure.NotNull(inner, "inner"); Ensure.NotNull(handlers, "handlers"); this.inner = inner; this.handlers = handlers; }
// TODO PreProcessor in Parameters. public string Process <T>(MethodInfo method, string msg, ICommandHandlerCollection <T> handlers) where T : ICommandHandlerCollection <T> { if (msg.Contains(Config.Instance.Code)) { return(msg); } throw new CommandException("口令无效"); }
public string Process <T>(MethodInfo method, string msg, ICommandHandlerCollection <T> handlers) where T : ICommandHandlerCollection <T> { if (handlers is ISender s && s.Sender != Config.Instance.QQ) { throw new CommandException("你不是管理. (嫌弃脸)"); } return(msg); }
public string Process <T>(MethodInfo method, string msg, ICommandHandlerCollection <T> handlers) where T : ICommandHandlerCollection <T> { if (handlers is GroupMessageProcessor s && Config.Instance.GetServerInfo(s.Group, msg.Split(' ')[1]) == null) { throw new CommandException($"该服务器不存在配置, 请使用 [添加服务器配置] 添加. \r\n" + $"当前存在的服务器配置有 [{Config.Instance.ServerInfos.GetMixed(s.Group).Select(info => info.ServerName).Connect()}] (嫌弃脸)"); } return(msg); }
public PwaInstallInterop(IJSRuntime js, ICommandHandlerCollection commandHandlers, IEventDispatcher events) { Ensure.NotNull(js, "js"); Ensure.NotNull(commandHandlers, "commandHandlers"); Ensure.NotNull(events, "events"); this.js = js; PwaInstallInterop.events = events; commandHandlers .Add <InstallPwa>(this) .Add <UpdatePwa>(this); }
public BootstrapTask(ICommandHandlerCollection commandHandlers, IFactory <IRepository <Outcome, IKey> > outcomeRepository, IFactory <IRepository <Category, IKey> > categoryRepository, IFactory <IRepository <CurrencyList, IKey> > currencyListRepository) { Ensure.NotNull(commandHandlers, "commandHandlers"); Ensure.NotNull(outcomeRepository, "outcomeRepository"); Ensure.NotNull(categoryRepository, "categoryRepository"); Ensure.NotNull(currencyListRepository, "currencyListRepository"); this.commandHandlers = commandHandlers; this.outcomeRepository = outcomeRepository; this.categoryRepository = categoryRepository; this.currencyListRepository = currencyListRepository; }
/// <summary> /// Registers <paramref name="handler"/> to handle commands for all implemented interfaces <see cref="ICommandHandler{T}"/>. /// </summary> /// <param name="collection">The collection of command handlers.</param> /// <param name="handler">The commmand handler.</param> /// <returns><paramref name="collection"/>.</returns> public static ICommandHandlerCollection AddAll(this ICommandHandlerCollection collection, object handler) { Ensure.NotNull(collection, "collection"); Ensure.NotNull(handler, "handler"); foreach (Type interfaceType in handler.GetType().GetInterfaces()) { if (interfaceType.IsGenericType && typeof(ICommandHandler <>) == interfaceType.GetGenericTypeDefinition()) { MethodInfo addMethod = collection.GetType().GetMethod(Constant.CommandHandlerCollectionAddMethodName).MakeGenericMethod(interfaceType.GetGenericArguments()); addMethod.Invoke(collection, new object[] { handler }); } } return(collection); }
public string Process <T>(MethodInfo method, string msg, ICommandHandlerCollection <T> handlers) where T : ICommandHandlerCollection <T> { var split = msg.Split(' '); if (split.Length != 2) { throw new CommandException("无效参数."); } if (split.Last() == Config.Instance.Code) { return(split.First()); } throw new CommandException("口令无效"); }
public string Process <T>(MethodInfo method, string msg, ICommandHandlerCollection <T> handlers) where T : ICommandHandlerCollection <T> { using (var session = MahuaRobotManager.Instance.CreateSession()) { var api = session.MahuaApi; if (handlers is GroupMessageProcessor s && api.GetGroupMemebersWithModel(s.Group).Model .First(info => info.Qq == s.Sender).Authority == GroupMemberAuthority.Normal && s.Sender != "775942303") { throw new CommandException("你不是管理. (嫌弃脸)"); } return(msg); } }
public void Process <T>(MethodInfo method, string msg, ICommandHandlerCollection <T> handlers) where T : ICommandHandlerCollection <T> { Config.Save(); }