public LurkerModule(IIrcClient client, IGthxData data, IBotNick botNick, ILogger <LurkerModule> logger) { _client = client; _data = data; _botNick = botNick; _logger = logger; }
public RecentChangeHandler( IAppConfiguration appConfig, ILogger logger, IChannelConfiguration channelConfig, IBotUserConfiguration botUserConfiguration, IIrcClient freenodeClient, IEmailHelper emailHelper, INotificationTemplates templates, IEmailTemplateFormatter emailTemplateFormatter, ISubscriptionHelper subscriptionHelper) { this.appConfig = appConfig; this.logger = logger; this.channelConfig = channelConfig; this.botUserConfiguration = botUserConfiguration; this.freenodeClient = freenodeClient; this.emailHelper = emailHelper; this.templates = templates; this.emailTemplateFormatter = emailTemplateFormatter; this.subscriptionHelper = subscriptionHelper; if (this.appConfig.EmailConfiguration == null) { this.logger.Warn("Not sending email; email configuration is disabled"); } }
public BlockMonitoringService( ILogger logger, ILinkerService linkerService, IUrlShorteningService urlShorteningService, ISession globalSession, IMediaWikiApiHelper apiHelper, BotConfiguration botConfiguration, IWebServiceClient webServiceClient, IIrcClient client, ITrollMonitoringService trollMonitoringService) { this.logger = logger; this.linkerService = linkerService; this.urlShorteningService = urlShorteningService; this.globalSession = globalSession; this.apiHelper = apiHelper; this.botConfiguration = botConfiguration; this.webServiceClient = webServiceClient; this.client = client; this.trollMonitoringService = trollMonitoringService; this.trollMonitoringService.BlockMonitoringService = this; // initialise the store foreach (var blockMonitor in globalSession.CreateCriteria <BlockMonitor>().List <BlockMonitor>()) { if (!this.monitors.ContainsKey(blockMonitor.MonitorChannel)) { this.monitors[blockMonitor.MonitorChannel] = new HashSet <string>(); } this.monitors[blockMonitor.MonitorChannel].Add(blockMonitor.ReportChannel); } }
public AccountCommand(string commandSource, IUser user, IList <string> arguments, ILogger logger, IFlagService flagService, IConfigurationProvider configurationProvider, IIrcClient client, IBotUserConfiguration botUserConfiguration, IEmailHelper emailHelper, IAppConfiguration config, INotificationTemplates templates, IChannelConfiguration channelConfiguration) : base( commandSource, user, arguments, logger, flagService, configurationProvider, client) { this.appConfig = config; this.templates = templates; this.channelConfiguration = channelConfiguration; this.botUserConfiguration = botUserConfiguration; this.emailHelper = emailHelper; }
public MqService(RabbitMqConfiguration mqConfig, ILogger logger, BotConfiguration botConfiguration, IIrcClient client) { this.mqConfig = mqConfig; this.logger = logger; this.botConfiguration = botConfiguration; this.client = client; }
public DraftStatusCommand( string commandSource, IUser user, IList <string> arguments, ILogger logger, IFlagService flagService, IConfigurationProvider configurationProvider, IIrcClient client, AfcCategoryConfiguration categoryConfiguration, IMediaWikiApiHelper apiHelper, ISession databaseSession, IDraftStatusService draftStatusService, ILinkerService linkerService, IUrlShorteningService urlShorteningService) : base( commandSource, user, arguments, logger, flagService, configurationProvider, client) { this.categoryConfiguration = categoryConfiguration; this.apiHelper = apiHelper; this.databaseSession = databaseSession; this.draftStatusService = draftStatusService; this.linkerService = linkerService; this.urlShorteningService = urlShorteningService; }
public AccDeployCommand( string commandSource, IUser user, IList <string> arguments, ILogger logger, IFlagService flagService, IConfigurationProvider configurationProvider, IIrcClient client, IResponder responder, BotConfiguration botConfiguration, IWebServiceClient webServiceClient, ModuleConfiguration deploymentConfiguration) : base( commandSource, user, arguments, logger, flagService, configurationProvider, client) { this.responder = responder; this.botConfiguration = botConfiguration; this.webServiceClient = webServiceClient; this.deploymentPassword = deploymentConfiguration.DeploymentPassword; }
public void Invoke(ServerMessage message, IIrcClient ircClient, ILogger logger) { var channelName = message.Parameters[0]; var mode = message.Parameters[1]; var nickName = message.Parameters[2]; var userInfo = ircClient.Channels[channelName].GetUser(nickName); if (userInfo == null) { userInfo = ircClient.UserService.GetOrCreateUser(nickName, channelName); logger.Write($"Detected new user by MODE {nickName} on channel {channelName}"); } if (mode.Equals("+o") && !userInfo.IsModerator) { logger.Write($"Adding moderator status for {nickName} on {channelName}"); userInfo.IsModerator = true; ircClient.Channels[channelName].UpdateUser(userInfo); } else if (mode.Equals("-o") && userInfo.IsModerator) { logger.Write($"Removing moderator status for {nickName} on {channelName}"); userInfo.IsModerator = false; ircClient.Channels[channelName].UpdateUser(userInfo); } else { logger.Write($"Mode {mode} sat on user {nickName} on {channelName}"); } }
public YoutubeModule(IGthxData data, IIrcClient ircClient, IGthxUtil util, ILogger <YoutubeModule> logger) { _data = data; _client = ircClient; _util = util; _logger = logger; }
/// <summary> /// Initialises a new instance of the <see cref="JoinMessageService"/> class. /// </summary> /// <param name="ircClient"> /// The IRC network. /// </param> /// <param name="logger"> /// The logger. /// </param> /// <param name="repository"> /// The repository. /// </param> /// <param name="messageService"> /// The message Service. /// </param> public JoinMessageService(IIrcClient ircClient, ILogger logger, IWelcomeUserRepository repository, IMessageService messageService) { this.ircClient = ircClient; this.logger = logger; this.repository = repository; this.messageService = messageService; }
public void Invoke(ServerMessage message, IIrcClient ircClient, ILogger logger) { if (message.Command.Equals("376") && !_isInitialized) //We use this to initialize the plugin. This should only happen once. { _ircClient = ircClient; _logger = logger; //Subscribe to when the stream startes/ends events _ircClient.TwitchService.OnStreamOnline += TwitchService_OnStreamOnline; _ircClient.TwitchService.OnStreamOffline += TwitchService_OnStreamOffline; _timer.AutoReset = true; _timer.Interval = 60000; _timer.Elapsed += _timer_Elapsed; _timer.Enabled = true; _dataFolder = PluginHelper.GetPluginDataFolder(this); _database = new SQLiteConnection(new SQLitePlatformWin32(), Path.Combine(_dataFolder, "CurrencyPlugin.db")); _database.CreateTable<CurrencyUserModel>(); //This is for debugging //_watchedChannelsList.Add("#unseriouspid"); //_onlineChannelsList.Add("#unseriouspid"); _logger.Write($"{GetType().Name} Initialized."); _isInitialized = true; } else if (message.Command.Equals("PRIVMSG") && _isInitialized && _watchedChannelsList.Contains(message.GetChannelName())) { var userCommand = message.Trailing.Split(' ')[0].ToLower().TrimStart(); var nickName = message.GetSender(); var channelName = message.GetChannelName(); switch (userCommand) { case "!points": if (IsUserCommandOnCooldown(userCommand, nickName, channelName)) return; DisplayPoints(nickName, channelName); CooldownUserCommand(userCommand, nickName, channelName); break; case "!gamble": if (IsUserCommandOnCooldown(userCommand, nickName, channelName)) return; DoGamble(message); CooldownUserCommand(userCommand, nickName, channelName); break; case "!bonus": DoAddBonus(message); break; case "!bonusall": DoAddBonusAll(message); break; } } }
public UserInfoCommand( string commandSource, IUser user, IList <string> arguments, ILogger logger, IFlagService flagService, IConfigurationProvider configurationProvider, IIrcClient client, ISession databaseSession, ILinkerService linkerService, IUrlShorteningService urlShortener, IMediaWikiApiHelper apiHelper, IResponder responder) : base( commandSource, user, arguments, logger, flagService, configurationProvider, client) { this.databaseSession = databaseSession; this.linkerService = linkerService; this.urlShortener = urlShortener; this.apiHelper = apiHelper; this.responder = responder; }
internal IrcNetworkStream(IIrcClient client) { _streamReader = new StreamReader(client.GetClientStream()); _streamWriter = new StreamWriter(client.GetClientStream()); _cancellationRegistration = _cancellationToken.Register(TaskRequestErrorCallback); }
public List<string> Commands = > new List<string> { "376" }; //End of MOTD #endregion Fields #region Methods public void Invoke(ServerMessage message, IIrcClient ircClient, ILogger logger) { foreach (var channel in ircClient.AutoJoinChannels) { ircClient.JoinChannel(channel); } }
public AppShellViewModel(IIrcClient client, INavigationService navigationService) { _navigationService = navigationService ?? throw new ArgumentNullException(nameof(navigationService)); _client = client ?? throw new ArgumentNullException(nameof(client)); _client.Connected += ClientOnConnected; _client.Disconnected += ClientOnDisconnected; _client.JoinedChannel += ClientOnJoinedChannel; _client.LeftChannel += ClientOnLeftChannel; NavItems.Add(new NavigationGotoItemViewModel { Label = "Home", FontIcon = "Home", Command = new DelegateCommand(() => { _navigationService.Navigate(PageTokens.Home.ToString(), null); }) }); NavItems.Add(new NavigationGotoItemViewModel { Label = "Add Server", FontIcon = "Add", Command = new DelegateCommand(() => { _navigationService.Navigate(PageTokens.AddServer.ToString(), null); }) }); }
public InterwikiCommand( string commandSource, IUser user, IList <string> arguments, ILogger logger, IFlagService flagService, IConfigurationProvider configurationProvider, IIrcClient client, ISession session, IMediaWikiApiHelper apiHelper, IResponder responder, IInterwikiService interwikiService) : base( commandSource, user, arguments, logger, flagService, configurationProvider, client) { this.session = session; this.apiHelper = apiHelper; this.responder = responder; this.interwikiService = interwikiService; }
public ThingiverseModule(IGthxData data, IIrcClient ircClient, IGthxUtil util, ILogger <ThingiverseModule> logger) { _data = data; _client = ircClient; _util = util; _logger = logger; }
public AfcCountCommand( string commandSource, IUser user, IList <string> arguments, ILogger logger, IFlagService flagService, IConfigurationProvider configurationProvider, IIrcClient client, ISession databaseSession, IMediaWikiApiHelper apiHelper, IDraftStatusService draftStatusService, IResponder responder ) : base( commandSource, user, arguments, logger, flagService, configurationProvider, client) { this.databaseSession = databaseSession; this.apiHelper = apiHelper; this.draftStatusService = draftStatusService; this.responder = responder; }
public ChannelModule( IAppConfiguration appConfiguration, IIrcClient freenodeClient, IChannelConfiguration channelConfiguration, IBotUserConfiguration botUserConfiguration, IStalkNodeFactory stalkNodeFactory, ISubscriptionHelper subscriptionHelper, IFlagService flagService ) : base(appConfiguration, freenodeClient) { this.channelConfiguration = channelConfiguration; this.botUserConfiguration = botUserConfiguration; this.stalkNodeFactory = stalkNodeFactory; this.subscriptionHelper = subscriptionHelper; this.flagService = flagService; this.Get["/channels"] = this.GetChannelList; this.Get["/channels/{channel}"] = this.GetChannelInfo; this.Get["/channels/{channel}/new"] = this.NewStalk; this.Post["/channels/{channel}/new"] = this.PostNewStalk; this.Post["/channels/{channel}/subscribe"] = this.ChannelSubscribe; this.Post["/channels/{channel}/unsubscribe"] = this.ChannelUnsubscribe; this.Get["/channels/{channel}/stalk/{stalk}"] = this.GetStalkInfo; this.Get["/channels/{channel}/stalk/{stalk}/edit"] = this.GetStalkInfoForEdit; this.Get["/channels/{channel}/stalk/{stalk}/delete"] = this.GetStalkInfoForDelete; this.Post["/channels/{channel}/stalk/{stalk}/delete"] = this.DeleteStalk; this.Post["/channels/{channel}/stalk/{stalk}/edit"] = this.PostStalkInfo; this.Post["/channels/{channel}/stalk/{stalk}/subscribe"] = this.StalkSubscribe; this.Post["/channels/{channel}/stalk/{stalk}/unsubscribe"] = this.StalkUnsubscribe; }
/*/ Constructors /*/ /// <summary> /// Initializes a new instance of the <see cref="IrcBot"/> class. /// </summary> /// <param name="juvoClient">Host.</param> /// <param name="ircClient">IRC client.</param> /// <param name="config">IRC configuration.</param> /// <param name="logManager">Log manager.</param> public IrcBot(IJuvoClient juvoClient, IIrcClient ircClient, IrcConfigConnection config, ILogManager?logManager = null) { this.config = config; this.host = juvoClient; this.logManager = logManager; this.client = ircClient; this.log = logManager?.GetLogger(typeof(IrcBot)); this.client.Network = IrcClient.LookupNetwork(this.config.Network ?? string.Empty); this.client.NickName = config.Nickname ?? throw new Exception("Nickname is missing from configuration"); this.client.NickNameAlt = config.NicknameAlt ?? $"{config.Nickname}-"; this.client.RealName = config.RealName ?? string.Empty; this.client.Username = config.Ident ?? config.Nickname.ToLowerInvariant(); this.client.ChannelJoined += this.Client_ChannelJoined; this.client.ChannelMessage += this.Client_ChannelMessage; this.client.ChannelModeChanged += this.Client_ChannelModeChanged; this.client.ChannelParted += this.Client_ChannelParted; this.client.Connected += this.Client_Connected; this.client.Disconnected += this.Client_Disconnected; this.client.HostHidden += this.Client_HostHidden; this.client.MessageReceived += this.Client_MessageReceived; this.client.PrivateMessage += this.Client_PrivateMessage; this.client.UserModeChanged += this.Client_UserModeChanged; this.client.UserQuit += this.Client_UserQuit; this.commandToken = config.CommandToken ?? DefaultCommandToken; }
public ConsoleTestBot(IIrcClient ircClient, ILogger <ConsoleTestBot> logger, IConfiguration configuration, IServiceProvider services) { _ircClient = ircClient; _logger = logger; _configuration = configuration; _services = services; _logger.LogInformation("ConsoleTestBot constructor: Logging enabled"); }
public EmailHelper(IAppConfiguration appConfig, IEmailSender emailSender, ILogger logger, INotificationTemplates templates, IIrcClient freenodeClient) { this.logger = logger; this.templates = templates; this.freenodeClient = freenodeClient; this.appConfig = appConfig; this.emailSender = emailSender; }
/// <summary> /// Initialises a new instance of the <see cref="Linker"/> class. /// </summary> protected Linker() { // FIXME: ServiceLocator - iircclient this.ircClient = ServiceLocator.Current.GetInstance<IIrcClient>(); this.ircClient.ReceivedMessage += this.IrcPrivateMessageEvent; this.lastLink = new Dictionary<string, string>(); }
public HelpeeManagementService(IIrcClient client, ILogger logger, ModuleConfiguration configuration) { this.client = client; this.logger = logger; this.TargetChannel = configuration.HelpeeManagement.TargetChannel; this.monitoringChannel = configuration.HelpeeManagement.MonitorChannel; this.ignoreList = configuration.HelpeeManagement.IgnoredNicknames; }
/// <summary> /// Initializes a new instance of the <see cref="IrbService" /> class. /// </summary> /// <param name="ircClient">The irc client.</param> /// <exception cref="System.ArgumentNullException">If the ircClient is null.</exception> public IrbService(IIrcClient ircClient) { if (ircClient == null) { throw new ArgumentNullException("ircClient"); } this.ircClient = ircClient; }
public ChangePasswordModule(IAppConfiguration appConfiguration, IIrcClient freenodeClient, IBotUserConfiguration botUserConfiguration) : base( appConfiguration, freenodeClient) { this.botUserConfiguration = botUserConfiguration; this.Get["/changepassword"] = this.ChangePassword; this.Post["/changepassword"] = this.ChangePasswordPost; }
public IrcConnection(IIrcClient ircClient, IMessageBus messageBus, UserManager <SpikeCoreUser> userManager, IrcConnectionConfig botConfig) { _ircClient = ircClient; _messageBus = messageBus; _userManager = userManager; _config = botConfig; Connect(); }
/// <summary> /// Initializes a new instance of the <see cref="BaseModule" /> class. /// </summary> /// <param name="ircClient">The irc client.</param> /// <exception cref="System.ArgumentNullException">ircClient</exception> protected BaseModule(IIrcClient ircClient) { if (ircClient == null) { throw new ArgumentNullException("ircClient"); } this.ircClient = ircClient; }
public StalkFactory( ILogger logger, IStalkNodeFactory stalkNodeFactory, IIrcClient freenodeClient, IAppConfiguration appConfig) : base(logger, stalkNodeFactory) { this.freenodeClient = freenodeClient; this.appConfig = appConfig; }
/// <summary> /// Initializes a new instance of the <see cref="UrbanDictionaryModule" /> class. /// </summary> /// <param name="ircClient">The irc client.</param> /// <param name="urbanService">The urban service.</param> /// <exception cref="System.ArgumentNullException">The urbanService is null.</exception> public UrbanDictionaryModule(IIrcClient ircClient, IUrbanService urbanService) : base(ircClient) { if (urbanService == null) { throw new ArgumentNullException("urbanService"); } this.urbanService = urbanService; }
public TwitchBotWorker(ILogger <TwitchBotWorker> logger, IIrcClient ircClient, IPinger pinger, IAzureFunctionClient azureFunctionClient) { _logger = logger; _ircClient = ircClient; _pinger = pinger; _azureFunctionClient = azureFunctionClient; }
public LoginModule(IBotUserConfiguration botUserConfiguration, IAppConfiguration appConfiguration, IIrcClient freenodeClient) { this.botUserConfiguration = botUserConfiguration; this.appConfiguration = appConfiguration; this.freenodeClient = freenodeClient; this.Get["/login"] = this.LogIn; this.Get["/logout"] = this.LogOut; this.Post["/login"] = this.LogInPost; }
public DateModule(IIrcClient client) : base(client) { AddHandler(new ModuleMessageHandler { Type = ReceiveType.ChannelMessage, CommandRegex = new Regex("^!date$"), Method = "DisplayDate" }); }
/// <summary> /// Initializes a new instance of the <see cref="UrlShortenerModule" /> class. /// </summary> /// <param name="ircClient">The irc client.</param> /// <param name="providers">The providers.</param> public UrlShortenerModule(IIrcClient ircClient, IEnumerable<IUrlShortenerProvider> providers) : base(ircClient) { if (providers == null) { throw new ArgumentNullException("providers"); } this.providers = providers; }
/// <summary> /// Initializes a new instance of the <see cref="AdminModule" /> class. /// </summary> /// <param name="ircClient">The irc client.</param> /// <param name="userService">The user service.</param> /// <exception cref="System.ArgumentNullException">userService</exception> public AdminModule(IIrcClient ircClient, IUserService userService) : base(ircClient) { if (userService == null) { throw new ArgumentNullException("userService"); } this.userService = userService; }
/// <summary> /// Initializes a new instance of the <see cref="BlackjackModule" /> class. /// </summary> /// <param name="ircClient">The irc client.</param> /// <param name="blackjackServiceFactory">The blackjack service factory.</param> /// <exception cref="System.ArgumentNullException"></exception> public BlackjackModule(IIrcClient ircClient, IBlackjackServiceFactory blackjackServiceFactory) : base(ircClient) { if (blackjackServiceFactory == null) { throw new ArgumentNullException("blackjackService"); } this.blackjackServiceFactory = blackjackServiceFactory; }
public GitHubSearchModule(IIrcClient client, IGitHubService gitHubService) : base(client) { _gitHubService = gitHubService; AddHandler(new ModuleMessageHandler { Type = ReceiveType.ChannelMessage, CommandRegex = new Regex("^!github search (?<term>.+)$"), Method = "SearchGitHub" }); }
public CategoryWatcherBackgroundService( ILogger logger, CategoryWatcherConfiguration configuration, IIrcClient ircClient, ICategoryWatcherHelperService helperService) : base(logger, configuration.UpdateFrequency * 1000, configuration.Enabled) { this.crossoverTimeout = configuration.CrossoverTimeout; this.ircClient = ircClient; this.helperService = helperService; }
public TinyUrlModule(IIrcClient client, ITinyUrlService tinyUrlService) : base(client) { _tinyUrlService = tinyUrlService; AddHandler(new ModuleMessageHandler { Type = ReceiveType.ChannelMessage, CommandRegex = new Regex("^!tinyurl (?<url>.+)"), Method = "ShortenUrl" }); }
public List<string> Commands = > new List<string> { "353" , "366" }; //353 = element in NAMES list, 366 = end of NAMES list #endregion Fields #region Methods public void Invoke(ServerMessage message, IIrcClient ircClient, ILogger logger) { if (message.Command.Equals("366")) return; //We are silently ignoring 366 just to lessen spam in the console var channelName = message.Parameters[2]; var nickName = message.Parameters[0]; ircClient.Channels.AddIfNotExist(channelName); var user = ircClient.UserService.GetOrCreateUser(nickName, channelName); ircClient.Channels[channelName].AddUser(user); }
public UsersModule( IAppConfiguration appConfiguration, IIrcClient freenodeClient, IBotUserConfiguration botUserConfiguration) : base( appConfiguration, freenodeClient) { // this.RequiresClaims(AccessFlags.GlobalAdmin); this.botUserConfiguration = botUserConfiguration; this.Get["/users"] = this.GetUserList; }
public BotPlugin(IIrcClient client) { _client = client; _name = "Unknown Plugin"; _status = "Loaded"; if (_client != null && _client.Client != null) { _client.Client.UserMessageRecieved += Client_UserMessageRecieved; _client.Client.ChannelMessageRecieved += Client_ChannelMessageRecieved; } }
public DefaultModule( IChannelConfiguration channelConfiguration, ISubscriptionHelper subscriptionHelper, IAppConfiguration appConfiguration, IIrcClient client) : base(appConfiguration, client) { this.channelConfiguration = channelConfiguration; this.subscriptionHelper = subscriptionHelper; this.Get["/"] = this.MainPage; this.Get["/about"] = this.AboutPage; }
public TwitchIrcClientAdapter( IIrcClient Client, ILogger <TwitchIrcClientAdapter> Logger, IOptions <TwitchIrcClientAdapterSettings> Config) { _client = Client; _logger = Logger; _config = Config.Value; _client.Attach(this); var init = Init(); }
public void Invoke(ServerMessage message, IIrcClient ircClient, ILogger logger) { var channelName = message.GetChannelName(); var nickName = message.GetSender(); ircClient.Channels.AddIfNotExist(channelName); if (ircClient.Channels[channelName].Users.Any(u => u.Nick.Equals(nickName))) return; logger.Write($"Detected new user by PRIVMSG {nickName} on channel {channelName}"); var user = ircClient.UserService.GetOrCreateUser(nickName, channelName); ircClient.Channels[channelName].AddUser(user); }
public void Invoke(ServerMessage message, IIrcClient ircClient, ILogger logger) { var channelName = message.GetChannelName(); var nickName = message.GetSender(); WPFChatter WPFChatter = new WPFChatter(); Brush NickColor = WPFChatter.getColor(nickName); DotDotBot.GUI.MainWindow._mainWindow.tbChatOutput.Inlines.Add(new Run(nickName) { Foreground = NickColor, FontStyle = FontStyles.Italic}); DotDotBot.GUI.MainWindow._mainWindow.tbChatOutput.Inlines.Add($": {message.Trailing}\n"); DotDotBot.GUI.MainWindow._mainWindow.tbChatOutput.Inlines.Add(new Run("1\n") { FontSize = 4, Foreground = Brushes.Transparent}); }
public UsersPanelViewModel(IrcChannel channel, IEventAggregator eventAggregator, IIrcClient ircClient) { _eventAggregator = eventAggregator ?? throw new ArgumentNullException(nameof(eventAggregator)); _ircClient = ircClient ?? throw new ArgumentNullException(nameof(ircClient));; _userMutedEvent = _eventAggregator.GetEvent <UserMutedEvent>(); _userUnmutedEvent = _eventAggregator.GetEvent <UserUnmutedEvent>(); Channel = channel ?? throw new ArgumentException(nameof(channel)); ConnectedUsers.CollectionChanged += ConnectedUsersOnCollectionChanged; channel.UserJoined += ChannelOnUserJoined; channel.UserLeft += ChannelOnUserLeft; channel.UsersListReceived += ChannelOnUsersListReceived; }
public HelpCommand( string commandSource, IUser user, IList <string> arguments, ILogger logger, IFlagService flagService, IConfigurationProvider configurationProvider, ICommandParser commandParser, IIrcClient client, IResponder responder) : base(commandSource, user, arguments, logger, flagService, configurationProvider, commandParser, client) { this.responder = responder; }
public List<string> Commands = > new List<string> { "376", "CAP" }; //376 = End of MOTD #endregion Fields #region Methods public void Invoke(ServerMessage message, IIrcClient ircClient, ILogger logger) { if (message.Command.Equals("376")) { logger.Write("Connected and registered with the server"); //Tell the twitch IRC server that we want to receive join and parts logger.Write("Attemting to register to receive JOIN/PART messages"); ircClient.SendRawMessage("CAP REQ :twitch.tv/membership"); } else if (message.Command.Equals("CAP") && message.Parameters.Contains("ACK")) { logger.Write("We are now registered to receive JOIN/PART messages"); } }
/// <summary> /// Initializes a new instance of the <see cref="BlackjackService" /> class. /// </summary> /// <param name="ircClient">The irc client.</param> /// <param name="channel">The channel.</param> /// <exception cref="System.ArgumentNullException"></exception> protected BlackjackService(IIrcClient ircClient, string channel) { if (channel == null) { throw new ArgumentNullException("channel"); } if (ircClient == null) { throw new ArgumentNullException("ircClient"); } this.ircClient = ircClient; this.channel = channel; }
public void Invoke(ServerMessage message, IIrcClient ircClient, ILogger logger) { var channelName = message.GetChannelName(); var nickName = message.GetSender(); if (MessageHelper.IsMessageFromMe(message, ircClient.Credentials)) { logger.Write($"We left channel {channelName}"); ircClient.Channels.RemoveIfExists(channelName); } else { logger.Write($"PART {nickName} from channel {channelName}"); var user = ircClient.UserService.GetOrCreateUser(nickName, channelName); ircClient.Channels[channelName].RemoveUser(user); } }
public void Invoke(ServerMessage message, IIrcClient ircClient, ILogger logger) { var channelName = message.GetChannelName(); var nickName = message.GetSender(); if (_activeCountdownChannels.Any(c => c.ChannelName.Equals(channelName))) return; //We are already doing a countdown on this channel if (!_config.EnabledForChannels.Contains(channelName.ToLower())) return; //Check if we have this plugin enabled for this channel if (!message.Trailing.ToLower().TrimStart().Equals("!cd")) return; //This is the text that will trigger this command if (!ircClient.Channels[channelName].Users.Any(u => u.Nick.Equals(nickName) && u.AccessLevel >= _config.MinimumAccessLevel)) { return; //User need an access level greater than 0 to access this command } _activeCountdownChannels.Add(new CountDownChannel(channelName, 5, ircClient)); }
public void Invoke(ServerMessage message, IIrcClient ircClient, ILogger logger) { _logger = logger; _ircClient = ircClient; var userCommand = message.Trailing.Split(' ')[0].ToLower().TrimStart(); var nickName = message.GetSender(); var channelName = message.GetChannelName(); if (CommandHelper.IsChannelCommandOnCooldown(userCommand, channelName)) return; switch (userCommand) { case "!insult": DoInsult(nickName, channelName); CommandHelper.CooldownChannelCommand(userCommand, channelName, 120); break; } }
public UrlAggregatorModule(IIrcClient client, IUrlRepository urlRepository) : base(client) { _urlRepository = urlRepository; AddHandler(new ModuleMessageHandler { Type = ReceiveType.ChannelMessage, CommandRegex = new Regex(@"(?<link>https?://([-\w\.]+)+(:\d+)?(/([\w/_\.]*(\?\S+)?)?)?)"), Method = "AddLink" }); AddHandler(new ModuleMessageHandler { Type = ReceiveType.ChannelMessage, CommandRegex = new Regex("^!links$"), Method = "ListLinks" }); }
public void Invoke(ServerMessage message, IIrcClient ircClient, ILogger logger) { var channelName = message.GetChannelName(); var nickName = message.GetSender(); ircClient.Channels.AddIfNotExist(channelName); if (MessageHelper.IsMessageFromMe(message, ircClient.Credentials)) { logger.Write($"We joined channel {channelName}"); ircClient.TwitchService.AddToStreamWatchList(channelName); var viewers = TwitchApiClient.GetChatters(channelName.Substring(1)); logger.Write($"Got {viewers.Count} viewers from API. Loading them now:"); foreach (var viewer in viewers) { logger.WriteIndented($"API: {viewer} on channel {channelName}"); var user = ircClient.UserService.GetOrCreateUser(viewer, channelName); ircClient.Channels[channelName].AddUser(user); } var moderators = TwitchApiClient.GetOnlieModerators(channelName.Substring(1)); logger.Write($"Got {moderators.Count} moderators from API. Loading them now:"); foreach (var moderator in moderators) { logger.WriteIndented($"API: {moderator} (mod) on channel {channelName}"); var user = ircClient.UserService.GetOrCreateUser(moderator, channelName); user.IsModerator = true; ircClient.Channels[channelName].AddUser(user); } logger.Write("Done loading users found through API."); } else { //Load any data we have on this client from the database, then add it to our internal list of users logger.Write($"JOIN {nickName} on channel {channelName}"); var user = ircClient.UserService.GetOrCreateUser(nickName, channelName); ircClient.Channels[channelName].AddUser(user); } }
private void DoSetAccess(ServerMessage message, IIrcClient ircClient, ILogger logger) { var nickName = message.GetSender(); var channelName = message.GetChannelName(); var userAccessLevel = ircClient.UserService.GetOrCreateUser(nickName, channelName).AccessLevel; if (userAccessLevel <= 0) return; try { var targetNickName = message.Trailing.Split(' ')[1]; var targetAccessLevel = int.Parse(message.Trailing.Split(' ')[2]); if (targetAccessLevel > (userAccessLevel)) { logger.Write( $"Not enough access for {nickName} to use !setaccess on {channelName} useraccesslevel={userAccessLevel} target={targetAccessLevel}"); ircClient.SendMessage( $"You cannot set another users access level to a number greater than your own ({userAccessLevel})", channelName); return; } var targetUser = ircClient.UserService.GetOrCreateUser(targetNickName, channelName); targetUser.AccessLevel = targetAccessLevel; ircClient.UserService.SaveUser(targetUser); ircClient.SendMessage($"New access level for @{targetNickName} is {targetAccessLevel}.", channelName); } catch (Exception e) { if (e is FormatException || e is IndexOutOfRangeException) { ircClient.SendMessage($"Usage: !setaccess <user> <accesslevel>", channelName); return; } throw; } }
public QuoteModule(IIrcClient client, IQuoteRepository quoteRepository) : base(client) { _quoteRepository = quoteRepository; AddHandler( new ModuleMessageHandler { Type = ReceiveType.ChannelMessage, CommandRegex = new Regex("^!quotes add (?<text>.+)$"), Method = "AddQuote" } ); AddHandler( new ModuleMessageHandler { Type = ReceiveType.ChannelMessage, CommandRegex = new Regex("^!quotes find (?<term>.+)$"), Method = "SearchQuotes" } ); }
public void Invoke(ServerMessage message, IIrcClient ircClient, ILogger logger) { try { var nickName = message.GetSender(); var channelName = message.GetChannelName(); var userCommand = message.Trailing.Split(' ')[0].ToLower().TrimStart(); if (IsUserCommandOnCooldown(userCommand, nickName, channelName)) return; switch (userCommand) { case "!setaccess": DoSetAccess(message, ircClient, logger); break; } } catch (Exception e) { //Todo: make this better. Should not catch everything logger.Write(e.Message); } }
/// <summary> /// The do event processing. /// </summary> /// <param name="channel"> /// The channel. /// </param> /// <param name="user"> /// The user. /// </param> /// <param name="client"> /// The client. /// </param> public void DoEventProcessing(string channel, IUser user, IIrcClient client) { try { // channel checks var alertChannel = this.GetAlertChannel(channel); if (alertChannel == null) { return; } var ip = this.GetIpAddress(user); if (ip == null) { return; } string baseWiki = LegacyConfig.Singleton()["baseWiki", channel]; MediaWikiSite mediaWikiSite = this.mediaWikiSiteRepository.GetById(int.Parse(baseWiki)); BlockInformation blockInformation = mediaWikiSite.GetBlockInformation(ip.ToString()).FirstOrDefault(); if (blockInformation.Id != null) { string orgname = null; var textResult = HttpRequest.Get(string.Format("http://ip-api.com/line/{0}?fields=org,as,status", ip)); var resultData = textResult.Split('\r', '\n'); if (resultData.FirstOrDefault() == "success") { orgname = string.Format(", org: {0}", resultData[1]); } var message = string.Format( "Joined user {0} ({4}{5}) in channel {1} is blocked ({2}) because: {3}", user.Nickname, channel, blockInformation.Target, blockInformation.BlockReason, ip, orgname); client.SendMessage(alertChannel, message); } } catch (Exception ex) { this.logger.Error("Unknown error occurred in BlockMonitoringService", ex); } }
/// <summary> /// Attempt to connect to our pre-configured network. Does nothing if you're already connected. /// </summary> /// /// <remarks> /// /// <para> /// This will need to be refactored to allow multi-network support. This will perform a no-op /// if you are already connected. /// </para> public void Connect() { if (!_isStarted) { _ircClient = (IIrcClient)Activator.CreateInstance(IrcClientType); _ircClient.SupportsIdentification = SupportsIdentification; _ircClient.PublicMessageReceived += _ircClient_PublicMessageReceived; _ircClient.PrivateMessageReceived += _ircClient_PrivateMessageReceived; _ircClient.Connect(NetworkList.First()); _isStarted = true; } }