Add support for unusual channel prefixes

This commit is contained in:
Drew DeVault 2015-05-09 14:39:51 -06:00
parent f6a0918f39
commit 6aa43295c5
5 changed files with 10 additions and 20 deletions

3
.gitignore vendored
View File

@ -1,4 +1,5 @@
_ReSharper*
bin/
obj/
*.suo
*.suo
*.userprefs

View File

@ -1,13 +0,0 @@
<Properties StartupItem="TestChatSharp/TestChatSharp.csproj">
<MonoDevelop.Ide.Workspace ActiveConfiguration="Debug" />
<MonoDevelop.Ide.Workbench ActiveDocument="ChatSharp/IrcClient.Commands.cs">
<Files>
<File FileName="ChatSharp/IrcClient.cs" Line="32" Column="32" />
<File FileName="ChatSharp/IrcClient.Commands.cs" Line="10" Column="10" />
</Files>
</MonoDevelop.Ide.Workbench>
<MonoDevelop.Ide.DebuggingService.Breakpoints>
<BreakpointStore />
</MonoDevelop.Ide.DebuggingService.Breakpoints>
<MonoDevelop.Ide.DebuggingService.PinnedWatches />
</Properties>

View File

@ -7,10 +7,10 @@ namespace ChatSharp.Events
public IrcMessage IrcMessage { get; set; }
public PrivateMessage PrivateMessage { get; set; }
public PrivateMessageEventArgs(IrcMessage ircMessage)
public PrivateMessageEventArgs(IrcMessage ircMessage, ServerInfo serverInfo)
{
IrcMessage = ircMessage;
PrivateMessage = new PrivateMessage(IrcMessage);
PrivateMessage = new PrivateMessage(IrcMessage, serverInfo);
}
}
}

View File

@ -107,7 +107,7 @@ namespace ChatSharp.Handlers
public static void HandlePrivmsg(IrcClient client, IrcMessage message)
{
var eventArgs = new PrivateMessageEventArgs(message);
var eventArgs = new PrivateMessageEventArgs(message, client.ServerInfo);
client.OnPrivateMessageRecieved(eventArgs);
if (eventArgs.PrivateMessage.IsChannelMessage)
{

View File

@ -1,14 +1,16 @@
namespace ChatSharp
using System.Linq;
namespace ChatSharp
{
public class PrivateMessage
{
public PrivateMessage(IrcMessage message)
public PrivateMessage(IrcMessage message, ServerInfo serverInfo)
{
Source = message.Parameters[0];
Message = message.Parameters[1];
User = new IrcUser(message.Prefix);
if (Source.StartsWith("#"))
if (serverInfo.ChannelTypes.Any(c => Source.StartsWith(c.ToString())))
IsChannelMessage = true;
else
Source = User.Nick;