コード例 #1
0
ファイル: SlackBotFactory.cs プロジェクト: edrochenski/juvo
        /// <inheritdoc />
        public ISlackBot Create(SlackConfigConnection config, IServiceProvider services, IJuvoClient host)
        {
            var bot = new SlackBot(
                host,
                services.GetService <ISlackClient>(),
                config,
                services.GetService <ILogManager>());

            return(bot);
        }
コード例 #2
0
        /*/ Constructors /*/

        /// <summary>
        /// Initializes a new instance of the <see cref="SlackBot"/> class.
        /// </summary>
        /// <param name="host">Host.</param>
        /// <param name="slackClient">Slack client.</param>
        /// <param name="config">Configuration to use.</param>
        /// <param name="logManager">Log manager.</param>
        public SlackBot(IJuvoClient host, ISlackClient slackClient, SlackConfigConnection config, ILogManager?logManager = null)
        {
            this.host       = host;
            this.config     = config;
            this.logManager = logManager;
            this.log        = this.logManager?.GetLogger(typeof(SlackBot));
            this.random     = new Random(DateTime.Now.Millisecond * DateTime.Now.Second);

            this.slackClient = slackClient ?? throw new ArgumentNullException(nameof(slackClient));
            this.slackClient.Initialize(config.Token);
            this.slackClient.MessageReceived += this.SlackClient_MessageReceived;
        }