public MsgController() { msgService = new MessageService(); blacklistService = new BlacklistService(); userService = new UserService(); attachmentService = new MessageAttachmentService(); }
public async Task Test_Blacklist_CharacterAsync() { var targetSession = await TestHelpers.Instance.GenerateSessionAsync().ConfigureAwait(false); TestHelpers.Instance.ConnectedAccountHttpClient .Setup(s => s.GetCharacterAsync(targetSession.Character.CharacterId, null)) .ReturnsAsync(new Tuple <ServerConfiguration?, ConnectedAccount?>(new ServerConfiguration(), new ConnectedAccount { ChannelId = 1, ConnectedCharacter = new Character { Id = targetSession.Character.CharacterId } })); var blacklist = new BlacklistService(TestHelpers.Instance.ConnectedAccountHttpClient.Object, TestHelpers.Instance.CharacterRelationDao, TestHelpers.Instance.CharacterDao); TestHelpers.Instance.BlacklistHttpClient.Setup(s => s.AddToBlacklistAsync(It.IsAny <BlacklistRequest>())) .Returns(blacklist.BlacklistPlayerAsync(_session !.Character.CharacterId, targetSession.Character.VisualId)); var blinsPacket = new BlInsPacket { CharacterId = targetSession.Character.CharacterId }; await _blInsPacketHandler !.ExecuteAsync(blinsPacket, _session).ConfigureAwait(false); Assert.IsNotNull( TestHelpers.Instance.CharacterRelationDao.FirstOrDefaultAsync(s => (_session.Character.CharacterId == s.CharacterId) && (targetSession.Character.CharacterId == s.RelatedCharacterId) && (s.RelationType == CharacterRelationType.Blocked))); }
public CoreModule(DiscordSocketClient c, CommandService s, BlacklistService b, CoreConfig config) { _client = c; _commands = s; _blacklist = b; _config = config; }
public ModerationModule(RecordService r, UnpunishService u, BlacklistService b, LogService l, CoreConfig config, ModerationService m) { _service = m; _unpunish = u; _records = r; _blacklist = b; _log = l; _config = config; }
public UserPunishService(MuteService mute, DbService db, BlacklistService blacklistService) { _mute = mute; _db = db; _blacklistService = blacklistService; _warnExpiryTimer = new Timer(async _ => { await CheckAllWarnExpiresAsync(); }, null, TimeSpan.FromSeconds(0), TimeSpan.FromHours(12)); }
public SendPage(UserSearchResult userSearchResult) { _messageServise = new MessageServise(); _blacklistService = new BlacklistService(new PathService()); _sendService = new SendService(_messageServise, new UserService(), _blacklistService); InitializeComponent(); InitTimer(); _userSearchResult = userSearchResult; _sendModel = new SendModel(); }
public static BlacklistConfig FromService(BlacklistService s) { var result = new BlacklistConfig(); foreach (var b in s.ChannelBlacklists) { result.ChannelBlacklists.Add(new ChannelBlacklistConfig { ChannelId = b.Channel.Id, List = b.List.Select(x => x.ToString()), MuteTime = b.MuteTime, Enabled = b.Enabled }); } result.GlobalList = s.GlobalBlacklist.List.Select(x => x.ToString()); result.GlobalMuteTime = s.GlobalBlacklist.MuteTime; result.GlobalEnabled = s.GlobalBlacklist.Enabled; return(result); }
public BlacklistModule(BlacklistService blacklistService) { _blacklistService = blacklistService; }
public BlacklistCommands(BlacklistService bs, DbService db, IBotCredentials creds) { _bs = bs; _db = db; _creds = creds; }
internal BlacklistChecker(DiscordClient client) { _service = client.Services.Get <BlacklistService>(true); }
public BlacklistModule(BlacklistService bm) { _service = bm; }
internal BlacklistChecker(DiscordClient client) { _service = client.Services.Get<BlacklistService>(true); }
public BlacklistModule(BlacklistService service) { _service = service; _service.SetParentModule(this); }
public SendService(MessageServise messageServise, UserService userService, BlacklistService blacklistService) { _messageServise = messageServise; _userService = userService; _blacklistService = blacklistService; }
public UserPunishCommands(MuteService mute, BlacklistService blacklistService) { _mute = mute; _blacklistService = blacklistService; }
public async Task Start() { Console.Title = "Kratos"; // Set up our Discord client _client = new DiscordSocketClient(new DiscordSocketConfig() { LogLevel = LogSeverity.Verbose, MessageCacheSize = 100 }); _client.Log += Log; // Set up the config directory and core config if (!Directory.Exists(Path.Combine(Directory.GetCurrentDirectory(), "config"))) { Directory.CreateDirectory(Path.Combine(Directory.GetCurrentDirectory(), "config")); } if (File.Exists(Path.Combine(Directory.GetCurrentDirectory(), "config", "core.json"))) { _config = await CoreConfig.UseCurrentAsync(); } else { _config = await CoreConfig.CreateNewAsync(); } // Set up services _mod = new ModerationService(); await _mod.LoadConfigurationAsync(); _usernotes = new UsernoteService(); _records = new RecordService(); _tags = new TagService(); _log = new LogService(_client); await _log.LoadConfigurationAsync(); _unpunish = new UnpunishService(_client, _blacklist, _log, _records, _config); await _unpunish.GetRecordsAsync(); _slowmode = new SlowmodeService(_client, _log, _unpunish, _records, _config); _ratelimit = new RatelimitService(_client, _config, _records, _unpunish, _log); await _ratelimit.LoadConfigurationAsync(); if (_ratelimit.IsEnabled) { _ratelimit.Enable(_ratelimit.Limit); } _blacklist = new BlacklistService(_client, _unpunish, _records, _log, _config); _aliases = new AliasTrackingService(_client); await _aliases.LoadConfigurationAsync(); _permissions = new PermissionsService(); _permissions.LoadPermissions(Assembly.GetEntryAssembly()); await _permissions.LoadConfigurationAsync(); // Instantiate the dependency map and add our services and client to it. var serviceProvider = ConfigureServices(); // Set up command handler _commands = new CommandHandler(serviceProvider); await _commands.InstallAsync(); // Set up an event handler to execute some state-reliant startup tasks _client.Ready += async() => { await _blacklist.LoadConfigurationAsync(); }; // Connect to Discord await _client.LoginAsync(TokenType.Bot, _config.Token); await _client.StartAsync(); // Start unpunisher loop await _unpunish.StartAsync(); // Hang indefinitely await Task.Delay(-1); }
public BlacklistModule(BlacklistService service) => _service = service;