public TipBot(
            IOptionsMonitor <TipBotSettings> options,
            IServiceProvider services,
            DiscordSocketClient client,
            INodeIntegration nodeIntegration,
            QuizExpiryChecker quizExpiryChecker,
            CommandService commandService,
            DiscordConnectionKeepAlive discordConnectionKeepAlive,
            CommandHandlingService commandHandlingService,
            FatalErrorNotifier fatalErrorNotifier
            )
        {
            this.settings                   = options.CurrentValue;
            this.services                   = services;
            this.client                     = client;
            this.nodeIntegration            = nodeIntegration;
            this.quizExpiryChecker          = quizExpiryChecker;
            this.commandService             = commandService;
            this.discordConnectionKeepAlive = discordConnectionKeepAlive;
            this.commandHandlingService     = commandHandlingService;
            this.fatalErrorNotifier         = fatalErrorNotifier;

            options.OnChange(config =>
            {
                this.settings = config;
            });
        }
Exemple #2
0
        public TwitchBot(IOptionsMonitor <TipBotSettings> options)
        {
            this.settings = options.CurrentValue;

            api = new TwitchAPI();
            api.Settings.ClientId    = settings.Twitch.ClientId;
            api.Settings.AccessToken = settings.Twitch.AccessToken; // App Secret is not an Accesstoken

            ConnectionCredentials credentials = new ConnectionCredentials(settings.Twitch.Username, settings.Twitch.OAuth);

            var clientOptions = new ClientOptions
            {
                MessagesAllowedInPeriod = 750,
                ThrottlingPeriod        = TimeSpan.FromSeconds(30)
            };

            WebSocketClient customClient = new WebSocketClient(clientOptions);

            client = new TwitchClient(customClient);

            // TODO: Spawn multiple instances pr. channel definition in array. For now only grab the first one.
            var channel = settings.Twitch.Channels[0];

            client.Initialize(credentials, channel);

            client.OnLog             += Client_OnLog;
            client.OnJoinedChannel   += Client_OnJoinedChannel;
            client.OnMessageReceived += Client_OnMessageReceived;
            client.OnWhisperReceived += Client_OnWhisperReceived;
            client.OnNewSubscriber   += Client_OnNewSubscriber;
            client.OnConnected       += Client_OnConnected;

            client.Connect();
        }
        public CommandsManager(IContextFactory contextFactory, INodeIntegration nodeIntegration, IOptionsMonitor <TipBotSettings> options, FatalErrorNotifier fatalNotifier)
        {
            this.contextFactory  = contextFactory;
            this.nodeIntegration = nodeIntegration;
            this.settings        = options.CurrentValue;
            this.fatalNotifier   = fatalNotifier;
            this.random          = new Random();

            this.logger = LogManager.GetCurrentClassLogger();
        }
Exemple #4
0
        public BlockCoreNodeAPI(TipBotSettings settings, string accountName)
        {
            this.settings = settings;

            ApiUrl         = settings.ApiUrl;
            WalletName     = settings.WalletName;
            WalletPassword = settings.WalletPassword;
            AccountName    = accountName;
            MinFee         = settings.NetworkFee;
            UseSegwit      = settings.UseSegwit;
        }
        public BlockCoreNodeIntegration(IOptionsMonitor <TipBotSettings> options, IContextFactory contextFactory, FatalErrorNotifier fatalNotifier)
        {
            this.settings = options.CurrentValue;

            //var apiUrl = settings.ApiUrl; // settings.ConfigReader.GetOrDefault<string>("apiUrl", "http://127.0.0.1:48334/");
            //var walletName = settings.WalletName; // .ConfigReader.GetOrDefault<string>("walletName", "walletName");
            //var walletPassword = settings.WalletPassword; // .ConfigReader.GetOrDefault<string>("walletPassword", "walletPassword");
            //var useSegwit = settings.UseSegwit; // .ConfigReader.GetOrDefault<bool>("useSegwit", true);

            this.contextFactory   = contextFactory;
            this.cancellation     = new CancellationTokenSource();
            this.logger           = LogManager.GetCurrentClassLogger();
            this.fatalNotifier    = fatalNotifier;
            this.blockCoreNodeAPI = new BlockCoreNodeAPI(this.settings, AccountName);
        }
Exemple #6
0
        public async Task InitializeAsync(DiscordSocketClient client, TipBotSettings settings)
        {
            this.logger.Trace("()");

            while (this.SupportUser == null)
            {
                await Task.Delay(20000).ConfigureAwait(false);

                if (settings.Discord.SupportUserId > 0)
                {
                    this.SupportUser = client.GetUser(settings.Discord.SupportUserId);
                }
                else
                {
                    this.SupportUser = client.GetUser(settings.Discord.SupportUsername, settings.Discord.SupportDiscriminator);
                }

                if (this.SupportUser == null)
                {
                    this.logger.Warn("Support user is null!");
                }
            }
            this.logger.Trace("(-)");
        }
Exemple #7
0
 public ContextFactory(IOptionsMonitor <TipBotSettings> options)
 {
     this.settings = options.CurrentValue;
 }
 public BotPrefixes(IOptionsMonitor <TipBotSettings> options)
 {
     this.settings = options.CurrentValue;
 }
Exemple #9
0
        public MessagesHelper(IOptionsMonitor <TipBotSettings> options)
        {
            this.settings = options.CurrentValue;

            this.logger = LogManager.GetCurrentClassLogger();
        }