Use virtual channel name for DMs.
This commit is contained in:
parent
a5089f14b8
commit
1466562c54
3 changed files with 13 additions and 8 deletions
|
@ -139,5 +139,11 @@ namespace SharpChat {
|
||||||
|| string.Equals(name, Nickname, StringComparison.InvariantCultureIgnoreCase)
|
|| string.Equals(name, Nickname, StringComparison.InvariantCultureIgnoreCase)
|
||||||
|| string.Equals(name, DisplayName, StringComparison.InvariantCultureIgnoreCase);
|
|| string.Equals(name, DisplayName, StringComparison.InvariantCultureIgnoreCase);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static string GetDMChannelName(ChatUser user1, ChatUser user2) {
|
||||||
|
return user1.UserId < user2.UserId
|
||||||
|
? $"@{user1.UserId}-{user2.UserId}"
|
||||||
|
: $"@{user2.UserId}-{user1.UserId}";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,17 +29,19 @@ namespace SharpChat.Commands {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
string whisperStr = string.Join(' ', ctx.Args.Skip(1));
|
string whisperStr = string.Join(' ', ctx.Args.Skip(1));
|
||||||
|
string whisperChan = ChatUser.GetDMChannelName(ctx.User, whisperUser);
|
||||||
|
DateTimeOffset dateTime = DateTimeOffset.Now;
|
||||||
|
|
||||||
ctx.Chat.SendTo(whisperUser, new ChatMessageAddPacket(new ChatMessage {
|
ctx.Chat.SendTo(whisperUser, new ChatMessageAddPacket(new ChatMessage {
|
||||||
DateTime = DateTimeOffset.Now,
|
DateTime = dateTime,
|
||||||
ChannelName = string.Empty,
|
ChannelName = whisperChan,
|
||||||
Sender = ctx.User,
|
Sender = ctx.User,
|
||||||
Text = whisperStr,
|
Text = whisperStr,
|
||||||
Flags = ChatMessageFlags.Private,
|
Flags = ChatMessageFlags.Private,
|
||||||
}));
|
}));
|
||||||
ctx.Chat.SendTo(ctx.User, new ChatMessageAddPacket(new ChatMessage {
|
ctx.Chat.SendTo(ctx.User, new ChatMessageAddPacket(new ChatMessage {
|
||||||
DateTime = DateTimeOffset.Now,
|
DateTime = dateTime,
|
||||||
ChannelName = string.Empty,
|
ChannelName = whisperChan,
|
||||||
Sender = ctx.User,
|
Sender = ctx.User,
|
||||||
Text = $"{whisperUser.DisplayName} {whisperStr}",
|
Text = $"{whisperUser.DisplayName} {whisperStr}",
|
||||||
Flags = ChatMessageFlags.Private,
|
Flags = ChatMessageFlags.Private,
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Threading;
|
|
||||||
|
|
||||||
namespace SharpChat {
|
namespace SharpChat {
|
||||||
public interface IServerPacket {
|
public interface IServerPacket {
|
||||||
|
@ -8,13 +7,11 @@ namespace SharpChat {
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract class ServerPacket : IServerPacket {
|
public abstract class ServerPacket : IServerPacket {
|
||||||
private static long SequenceIdCounter = 0;
|
|
||||||
|
|
||||||
public long SequenceId { get; }
|
public long SequenceId { get; }
|
||||||
|
|
||||||
public ServerPacket(long sequenceId = 0) {
|
public ServerPacket(long sequenceId = 0) {
|
||||||
// Allow sequence id to be manually set for potential message repeats
|
// Allow sequence id to be manually set for potential message repeats
|
||||||
SequenceId = sequenceId > 0 ? sequenceId : Interlocked.Increment(ref SequenceIdCounter);
|
SequenceId = sequenceId > 0 ? sequenceId : SharpId.Next();
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract IEnumerable<string> Pack();
|
public abstract IEnumerable<string> Pack();
|
||||||
|
|
Loading…
Reference in a new issue