public AdminServiceProvider(ChatContext context, ChatServiceContext serviceDb,
                             ICryptoProvider cryptoProvider, IJoinService joinService)
 {
     _db             = context;
     _serviceDb      = serviceDb;
     _cryptoProvider = cryptoProvider;
     _joinService    = joinService;
 }
 public AdminController(
     ChatContext context, IJoinService joinService,
     IAdminServiceProvider adminService, IHubContext <MessageHub> hubContext)
 {
     _db           = context;
     _joinService  = joinService;
     _adminService = adminService;
     _hubContext   = hubContext;
 }
Esempio n. 3
0
        public static async Task Main(string[] args)
        {
            GlobalEvents.PrintStartupMessage();
            GlobalConfiguration.LoadConfiguration();
            _services    = ConfigureServices(new ServiceCollection());
            _logger      = _services.GetRequiredService <ILogger <Program> >();
            _joinService = _services.GetRequiredService <IJoinService>();

            _discordConfig = new DiscordSocketConfig()
            {
                LargeThreshold      = 250,
                AlwaysDownloadUsers = true, // RIP memory 2018
                DefaultRetryMode    = RetryMode.AlwaysRetry
            };

            _commandServiceConfig = new CommandServiceConfig()
            {
                ThrowOnError          = true, // haha who cares about debugging just let it fly
                CaseSensitiveCommands = false
            };

            _client         = new DiscordSocketClient(_discordConfig);
            _commandService = new CommandService(_commandServiceConfig);

            _client.UserJoined      += HandleUserJoinAsync;
            _client.MessageReceived += HandleCommandAsync;
            await _commandService.AddModulesAsync(Assembly.GetEntryAssembly());

            _logger.LogDebug("Haruna has been loaded with all modules and commands.");
            await _client.LoginAsync(TokenType.Bot, GlobalConfiguration.BotToken, validateToken : true);

            await _client.StartAsync();

            await HandlePlayingTagsAsync();

            _logger.LogInformation("Haruna has started and is running.");
            await Task.Delay(-1);
        }
Esempio n. 4
0
        public static async Task HandleUserJoinAsync(SocketGuildUser user, IJoinService joinService)
        {
            if (!GlobalConfiguration.JoinImageEnabled)
            {
                return;
            }

            try
            {
                Stream avatarStream = await joinService.GetStreamFromAvatarUrlAsync(user.GetAvatarUrl(Discord.ImageFormat.Auto, 256));

                Stream templateStream = await joinService.GenerateWelcomeImageAsync(user.Username, user.Discriminator, avatarStream);

                avatarStream.Dispose();

                // TODO: Allow configuration of this channel and message to go with the file.
                ITextChannel textChannel = (ITextChannel)user.Guild.GetChannel(ulong.Parse(GlobalConfiguration.JoinImageChannel));
                await textChannel.SendFileAsync(templateStream, "the-salmon-king-welcomes-you.png", null);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Esempio n. 5
0
 public LeaveController(IServiceProvider serviceProvider)
 {
     _joinService  = serviceProvider.GetRequiredService <IJoinService>();
     _leaveService = serviceProvider.GetRequiredService <ILeaveService>();
 }
Esempio n. 6
0
 public JoinTestModule(IJoinService joinService) // Add logging
 {
     _joinService = joinService;
 }
 public AccountController(ChatContext db, IAuthService authService, IJoinService joinService)
 {
     _db          = db;
     _authService = authService;
     _joinService = joinService;
 }
 public RegistrationController(IJoinService joinService, ICryptoService cryptoService)
 {
     _joinService   = joinService;
     _cryptoService = cryptoService;
 }
Esempio n. 9
0
 public JoinController(IServiceProvider serviceProvider)
 {
     _joinService          = serviceProvider.GetRequiredService <IJoinService>();
     _storageRegionService = serviceProvider.GetRequiredService <IStorageRegionService>();
 }