protected override void Initialize(HttpControllerContext controllerContext) { base.Initialize(controllerContext); /***Credentials are fetched from web.config ApplicationSettings when the CreateInstance * ----method is called without a credentials parameter or if the parameterless constructor * ----is used to initialize the MessengerPlatform class. This holds true for all types that inherit from * ----Bot.Messenger.ApiBase * * _Bot = MessengerPlatform.CreateInstance(); * _Bot = new MessengerPlatform(); ***/ _Bot = MessengerPlatform.CreateInstance( MessengerPlatform.CreateCredentials(_appSecret, _pageToken, _verifyToken)); }
private INucleusCommand SearchCommand(string commandString, MessengerPlatform platform) { _logger.Trace("Поиск команды..."); var command = _bot.Commands.Find(c => c.Command.ToLower() == commandString.ToLower()); if (command == null) { var commandStr = string.Empty; foreach (var alias in _bot.AliasesCommand) { if (alias.Key.ToLower() == commandString.ToLower()) { commandStr = alias.Value.Command.ToLower(); } } if (commandStr != string.Empty) { command = _bot.Commands.Find(c => c.Command.ToLower() == commandStr.ToLower()); } } if (command == null) { if (platform == MessengerPlatform.Telegam) { command = _bot.Commands.Find(c => c.Command.ToLower() == commandString.Split(' ')[0].ToLower()); if (command == null) { return(_bot.UnknownCommand); } } else { return(_bot.UnknownCommand); } } return(command); }