public ScheduledJob(SchedulePlugin schedulePlugin, INoobotCore noobotCore, ILog logger, StatsPlugin statsPlugin) { _schedulePlugin = schedulePlugin; _noobotCore = noobotCore; _log = logger; _statsPlugin = statsPlugin; }
public SchedulePlugin(StoragePlugin storagePlugin, INoobotCore noobotCore, StatsPlugin statsPlugin, ILog log) { _storagePlugin = storagePlugin; _noobotCore = noobotCore; _statsPlugin = statsPlugin; _log = log; }
public void Start() { IContainerFactory containerFactory = new ContainerFactory(_configuration, _configReader, LogManager.GetLogger(GetType())); INoobotContainer container = containerFactory.CreateContainer(); _noobotCore = container.GetNoobotCore(); Console.WriteLine("Connecting..."); _noobotCore .Connect() .ContinueWith(task => { if (!task.IsCompleted || task.IsFaulted) { Console.WriteLine($"Error connecting to Slack: {task.Exception}"); } Settings.ChannelList = _noobotCore.ListChannels(); var lastRun = DateTime.UtcNow; while (true) { if (lastRun.AddSeconds(1) <= DateTime.UtcNow) { var check = new MunkCheck(); check.CheckForEvents(_noobotCore); lastRun = DateTime.UtcNow; } } }) .Wait(); }
public void Setup() { var containerFactory = new ContainerFactory(new ToolboxConfiguration(), new ConfigReader(), NoobotWrapper.GetLogger()); _container = containerFactory.CreateContainer(); _noobotCore = _container.GetNoobotCore(); _noobotCore.Connect().Wait(TimeSpan.FromMinutes(1)); }
public void Setup() { var containerFactory = new ContainerFactory(new ToolboxConfiguration(), new JsonConfigReader(), NoobotWrapper.GetLogger()); _container = containerFactory.CreateContainer(); _noobotCore = _container.GetNoobotCore(); _noobotCore.Connect().Wait(TimeSpan.FromMinutes(1)); }
public void Setup() { File.Delete(Path.Combine(Environment.CurrentDirectory, "data/schedules.json")); var containerFactory = new ContainerFactory(new SchedulerConfig(), new ConfigReader(), NoobotWrapper.GetLogger()); _container = containerFactory.CreateContainer(); _noobotCore = _container.GetNoobotCore(); _noobotCore.Connect().Wait(TimeSpan.FromMinutes(1)); }
public async Task StartAsync(CancellationToken cancellationToken) { IContainerFactory containerFactory = new ContainerFactory(_botConfiguration, _configReader, LogManager.GetLogger(GetType())); INoobotContainer container = containerFactory.CreateContainer(); _noobotCore = container.GetNoobotCore(); _logger.LogInformation("Connecting.."); await _noobotCore.Connect(); }
private static async Task RunBot() { var environmentReader = new EnvironmentReader(); var botConfiguration = new BotConfiguration(environmentReader); var containerFactory = new ContainerFactory(botConfiguration, environmentReader, GetLogger()); var container = containerFactory.CreateContainer(); _noobotCore = container.GetNoobotCore(); await _noobotCore.Connect(); }
public async void CheckForEvents(INoobotCore _core) { var request = Slackbot.Client.GetAsync($"?p={Settings.SitePass}&u=bot&c=ping").Result; var response = request.Content.ReadAsStringAsync().Result.Clean(); var splitResponse = response.Split(new string[] { "\n" }, StringSplitOptions.RemoveEmptyEntries); foreach (var text in splitResponse) { var message = ConstructMessage(_core, text); await _core.SendMessage(message).ContinueWith(task => { }); } }
private static async Task RunNoobot() { var containerFactory = new ContainerFactory( new MiddlewareConfiguration(), new JsonConfigReader(_noobotConfigFilePath), GetLogger()); INoobotContainer container = containerFactory.CreateContainer(); _noobotCore = container.GetNoobotCore(); await _noobotCore.Connect(); }
private static async Task RunNoobot() { var containerFactory = new ContainerFactory( new ConfigurationBase(), JsonConfigReader.DefaultLocation(), GetLogger()); INoobotContainer container = containerFactory.CreateContainer(); _noobotCore = container.GetNoobotCore(); await _noobotCore.Connect(); }
public AdminMiddleware( IMiddleware next, AdminPlugin adminPlugin, SchedulePlugin schedulePlugin, INoobotCore noobotCore, ILogger log) : base(next) { _adminPlugin = adminPlugin; _schedulePlugin = schedulePlugin; _noobotCore = noobotCore; _log = log; HandlerMappings = new[] { new HandlerMapping { ValidHandles = ExactMatchHandle.For("admin pin"), EvaluatorFunc = PinHandler, Description = "This function is used to authenticate a user as admin", VisibleInHelp = false }, new HandlerMapping { ValidHandles = ExactMatchHandle.For("admin schedules list"), EvaluatorFunc = SchedulesListHandler, Description = "[Requires authentication] Will return a list of all schedules.", VisibleInHelp = false }, new HandlerMapping { ValidHandles = ExactMatchHandle.For("admin schedules delete"), EvaluatorFunc = DeleteSchedulesHandler, Description = "[Requires authentication] This will delete all schedules.", VisibleInHelp = false }, new HandlerMapping { ValidHandles = ExactMatchHandle.For("admin channels"), EvaluatorFunc = ChannelsHandler, Description = "[Requires authentication] Will return all channels connected.", VisibleInHelp = false }, new HandlerMapping { ValidHandles = ExactMatchHandle.For("admin help", "admin list"), EvaluatorFunc = AdminHelpHandler, Description = "[Requires authentication] Lists all available admin functions", VisibleInHelp = false } }; }
public HelpMiddleware(IMiddleware next, INoobotCore noobotCore) : base(next) { _noobotCore = noobotCore; HandlerMappings = new[] { new HandlerMapping { ValidHandles = new[] {"help", "yo tell me more"}, Description = "Returns supported commands and descriptions of how to use them", EvaluatorFunc = HelpHandler } }; }
public HelpMiddleware(IMiddleware next, INoobotCore noobotCore) : base(next) { _noobotCore = noobotCore; HandlerMappings = new[] { new HandlerMapping { ValidHandles = new[] { "help", "yo tell me more" }, Description = "Returns supported commands and descriptions of how to use them", EvaluatorFunc = HelpHandler } }; }
public void Start() { IContainerFactory containerFactory = new ContainerFactory(_configuration, _configReader, new ConsoleLog()); INoobotContainer container = containerFactory.CreateContainer(); _noobotCore = container.GetNoobotCore(); Console.WriteLine("Connecting..."); _noobotCore .Connect() .ContinueWith(task => { if (!task.IsCompleted || task.IsFaulted) { Console.WriteLine($"Error connecting to Slack: {task.Exception}"); } }); }
public MultipleCommandsMiddleware(IMiddleware next, INoobotCore noobotCore) : base(next) { _noobotCore = noobotCore; HandlerMappings = new[] { new HandlerMapping { ValidHandles = new IValidHandle[] { new StartsWithHandle("test") }, Description = "Returns supported commands and descriptions of how to use them", EvaluatorFunc = MultipleCommandsHandler } }; }
public AdminMiddleware(IMiddleware next, AdminPlugin adminPlugin, SchedulePlugin schedulePlugin, INoobotCore noobotCore, ILog log) : base(next) { _adminPlugin = adminPlugin; _schedulePlugin = schedulePlugin; _noobotCore = noobotCore; _log = log; HandlerMappings = new[] { new HandlerMapping { ValidHandles = new []{ "admin pin" }, EvaluatorFunc = PinHandler, Description = "This function is used to authenticate a user as admin", VisibleInHelp = false }, new HandlerMapping { ValidHandles = new []{ "admin schedules list" }, EvaluatorFunc = SchedulesListHandler, Description = "[Requires authentication] Will return a list of all schedules.", VisibleInHelp = false }, new HandlerMapping { ValidHandles = new []{ "admin schedules delete" }, EvaluatorFunc = DeleteSchedulesHandler, Description = "[Requires authentication] This will delete all schedules.", VisibleInHelp = false }, new HandlerMapping { ValidHandles = new []{ "admin channels" }, EvaluatorFunc = ChannelsHandler, Description = "[Requires authentication] Will return all channels connected.", VisibleInHelp = false }, new HandlerMapping { ValidHandles = new []{"admin help", "admin list"}, EvaluatorFunc = AdminHelpHandler, Description = "[Requires authentication] Lists all available admin functions", VisibleInHelp = false } }; }
public INoobotHost Start() { INoobotContainer container = _containerFactory.CreateContainer(); _noobotCore = container.GetNoobotCore(); Console.WriteLine("Connecting..."); _noobotCore .Connect() .ContinueWith(task => { if (!task.IsCompleted || task.IsFaulted) { Console.WriteLine($"Error connecting to Slack: {task.Exception}"); } }); return this; }
public void Start(ILog log) { IContainerFactory containerFactory = new ContainerFactory(_configuration, _configReader, log); INoobotContainer container = containerFactory.CreateContainer(); _noobotCore = container.GetNoobotCore(); _noobotCore .Connect() .ContinueWith(task => { if (!task.IsCompleted || task.IsFaulted) { Debug.WriteLine($"Error connecting to Slack: {task.Exception}"); } }) .GetAwaiter() .GetResult(); }
public INoobotHost Start() { INoobotContainer container = _containerFactory.CreateContainer(); _noobotCore = container.GetNoobotCore(); Console.WriteLine("Connecting..."); _noobotCore .Connect() .ContinueWith(task => { if (!task.IsCompleted || task.IsFaulted) { Console.WriteLine($"Error connecting to Slack: {task.Exception}"); } }); return(this); }
public ResponseMessage ConstructMessage(INoobotCore _core, string textToSend) { var toCustomChannel = textToSend.Contains("#PM#"); if (!toCustomChannel) { return(new ResponseMessage() { ResponseType = ResponseType.Channel, Text = textToSend, Channel = Settings.ChannelList.FirstOrDefault(e => e.Value == Settings.DefaultChannel).Key, }); } textToSend = textToSend.Replace("#PM#", ""); var index = textToSend.IndexOf("%&%"); var target = textToSend.Substring(0, index); textToSend = textToSend.Replace("%&%", "").Replace(target, ""); var message = new ResponseMessage() { ResponseType = ResponseType.Channel, Text = textToSend }; var channelId = Settings.ChannelList.FirstOrDefault(e => e.Value == target).Key; if (channelId == null) { var userId = _core.GetUserIdForUsername(target); message.UserId = userId; message.ResponseType = ResponseType.DirectMessage; } else { message.Channel = channelId; } return(message); }
public LearnPlugin(INoobotCore noobotCore, StoragePlugin storagePlugin) { _noobotCore = noobotCore; _storagePlugin = storagePlugin; }
public PingPlugin(INoobotCore noobotCore, JsonStoragePlugin storagePlugin) { _noobotCore = noobotCore; _storagePlugin = storagePlugin; }
public NoobotHealthCheck(INoobotCore noobot) : base("Noobot Health") { _noobot = noobot ?? throw new ArgumentNullException(nameof(noobot)); }
public NoobotHost(INoobotCore noobotCore) { _noobotCore = noobotCore; }
public OldbotHostedService(INoobotCore noobotCore) { _noobotCore = noobotCore; }