Skip to content

Commit

Permalink
ignore for channel and pilots
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefan Ruepp committed Jun 10, 2018
1 parent 2ecadd3 commit 17a135f
Show file tree
Hide file tree
Showing 7 changed files with 191 additions and 22 deletions.
45 changes: 45 additions & 0 deletions EveChatNotifier/FormMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,13 @@ private void ToAdd_RemovedLog(object sender, LogFile.EveChatEventArgs e)
private void NewChatLines(object sender, LogFile.EveChatEventArgs e)
{
LogFile curLog = (LogFile)sender;

// check for channel ignore list
if(IsIgnoredChannel(curLog))
{
return;
}

string logLines = e.NewLogLines;

// check log lines - line for line
Expand Down Expand Up @@ -263,6 +270,12 @@ private void NewChatLines(object sender, LogFile.EveChatEventArgs e)
continue;
}

// check if the sender is on the ignore list
if(IsIgnoredPilot(le))
{
continue;
}

// check if sender is "EVE-System" to prevent MOTD notifications
if(Properties.Settings.Default.IgnoreMotd && le.Sender.Equals(Properties.Settings.Default.MotdUsername.Trim(), StringComparison.OrdinalIgnoreCase))
{
Expand Down Expand Up @@ -297,6 +310,38 @@ private void NewChatLines(object sender, LogFile.EveChatEventArgs e)
}
}

/// <summary>
/// check if the current logfile is on the ignore list for channels
/// </summary>
/// <param name="lf"></param>
/// <returns></returns>
public bool IsIgnoredChannel(LogFile lf)
{
if(string.IsNullOrWhiteSpace(Properties.Settings.Default.IgnoreChannels))
{
return false;
}

string[] ignoreChannels = Properties.Settings.Default.IgnoreChannels.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
return ignoreChannels.Any(a => a.Trim().Equals(lf.LogInfo.ChannelName, StringComparison.OrdinalIgnoreCase));
}

/// <summary>
/// check if the sender is on the ignore list
/// </summary>
/// <param name="le"></param>
/// <returns></returns>
public bool IsIgnoredPilot(LogEntry le)
{
if(string.IsNullOrWhiteSpace(Properties.Settings.Default.IgnorePilots))
{
return false;
}

string[] ignorePilots = Properties.Settings.Default.IgnorePilots.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
return ignorePilots.Any(a => a.Trim().Equals(le.Sender.Trim(), StringComparison.OrdinalIgnoreCase));
}

private void notifyIcon_DoubleClick(object sender, EventArgs e)
{
if(_Settings == null)
Expand Down
4 changes: 2 additions & 2 deletions EveChatNotifier/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden,
// übernehmen, indem Sie "*" eingeben:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.9.0.0")]
[assembly: AssemblyFileVersion("2.9.0.0")]
[assembly: AssemblyVersion("2.10.0.0")]
[assembly: AssemblyFileVersion("2.10.0.0")]
26 changes: 25 additions & 1 deletion EveChatNotifier/Properties/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions EveChatNotifier/Properties/Settings.settings
Original file line number Diff line number Diff line change
Expand Up @@ -98,5 +98,11 @@
<Setting Name="MotdUsername" Type="System.String" Scope="User">
<Value Profile="(Default)">EVE-System</Value>
</Setting>
<Setting Name="IgnorePilots" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
<Setting Name="IgnoreChannels" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
</Settings>
</SettingsFile>
110 changes: 91 additions & 19 deletions EveChatNotifier/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions EveChatNotifier/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ public Settings()
// set motd username
tbMotdUsername.Text = Properties.Settings.Default.MotdUsername;

// set ignore pilot and channel
tbIgnoreChannels.Text = Properties.Settings.Default.IgnoreChannels;
tbIgnorePilots.Text = Properties.Settings.Default.IgnorePilots;

// set autostart object
try
{
Expand Down Expand Up @@ -236,6 +240,8 @@ private void SaveChanges()
Properties.Settings.Default.IgnoreMotd = cbIgnoreMotd.Checked;
Properties.Settings.Default.IgnoreOwnMessages = cbIgnoreOwn.Checked;
Properties.Settings.Default.MotdUsername = tbMotdUsername.Text;
Properties.Settings.Default.IgnoreChannels = tbIgnoreChannels.Text;
Properties.Settings.Default.IgnorePilots = tbIgnorePilots.Text;

NotifyOptions no = (NotifyOptions)cbNotify.SelectedItem;
switch (no)
Expand Down Expand Up @@ -268,5 +274,15 @@ private void SaveChanges()
}
}
}

private void lblIgnorePilots_MouseEnter(object sender, EventArgs e)
{
tbHelp.Text = string.Format("Here you can specify pilotnames (sender) which are ignored for notification. Please seperate them using ',' - not case sensitive.");
}

private void lblIgnoreChannels_MouseEnter(object sender, EventArgs e)
{
tbHelp.Text = string.Format("Here you can specify channelname which are ignored for notification. Please seperate them using ',' - not case sensitive.");
}
}
}
6 changes: 6 additions & 0 deletions EveChatNotifier/app.config
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@
<setting name="MotdUsername" serializeAs="String">
<value>EVE-System</value>
</setting>
<setting name="IgnorePilots" serializeAs="String">
<value />
</setting>
<setting name="IgnoreChannels" serializeAs="String">
<value />
</setting>
</EveChatNotifier.Properties.Settings>
</userSettings>
<applicationSettings>
Expand Down

0 comments on commit 17a135f

Please sign in to comment.