Add !AUTOREPLY

This commit is contained in:
SilicaAndPina 2021-07-03 19:26:52 +12:00
parent c17dc3e8bd
commit 699353f2d1
7 changed files with 123 additions and 35 deletions

View file

@ -166,6 +166,9 @@ namespace HISP.Game.Chat
else if (message.ToUpper().StartsWith("!HEAR"))
return Command.UnMute(message, args, user);
else if (message.ToUpper().StartsWith("!AUTOREPLY"))
return Command.AutoReply(message, args, user);
else if (message.ToUpper().StartsWith("!QUIZ"))
return Command.Quiz(message, args, user);
@ -433,7 +436,7 @@ namespace HISP.Game.Chat
return message.Replace("<", "&lt;");
}
public static string FormatChatForOthers(User user, ChatChannel channel, string message)
public static string FormatChatForOthers(User user, ChatChannel channel, string message, bool autoReply=false)
{
switch (channel)
@ -448,10 +451,12 @@ namespace HISP.Game.Chat
case ChatChannel.Buddies:
return Messages.FormatBuddyChatMessage(user.Username, message);
case ChatChannel.Dm:
string badge = "";
if (user.Moderator || user.Administrator)
return Messages.FormatDirectMessageForMod(user.Username, message);
else
return Messages.FormatDirectMessage(user.Username, message);
badge += Messages.DmModBadge;
if (autoReply)
badge += Messages.DmAutoResponse;
return Messages.FormatDirectMessage(user.Username, message, badge);
case ChatChannel.Near:
return Messages.FormatNearbyChatMessage(user.Username, message);
case ChatChannel.Isle:
@ -464,7 +469,7 @@ namespace HISP.Game.Chat
else
{
Logger.HackerPrint(user.Username + " Tried to send in mod chat without being a moderator. (Hack/Code Attempt)");
return user.Username + " is a hacker! (Sent in mod channel without being a mod) Maybe ban?";
return "";
}
case ChatChannel.Admin:
if (user.Administrator)
@ -472,14 +477,14 @@ namespace HISP.Game.Chat
else
{
Logger.HackerPrint(user.Username + " Tried to send in mod chat without being a moderator. (Hack/Code Attempt)");
return user.Username + " is a hacker! (Sent in admin channel without being a admin) Maybe ban?";
return "";
}
default:
Logger.ErrorPrint(user.Username + " is trying to end a message in unknown channel " + channel.ToString("X"));
return "not implemented yet :(";
}
}
public static string FormatChatForSender(User user, ChatChannel channel, string message, string dmRecipiant=null)
public static string FormatChatForSender(User user, ChatChannel channel, string message, string dmRecipiant=null, bool autoReply=false)
{
switch (channel)
{
@ -511,7 +516,12 @@ namespace HISP.Game.Chat
int adminsOnline = GameServer.GetNumberOfAdminsOnline() - 1;
return Messages.FormatAdminChatForSender(adminsOnline, user.Username, message);
case ChatChannel.Dm:
return Messages.FormatDirectChatMessageForSender(user.Username, dmRecipiant, message);
string badge = "";
if (user.Moderator || user.Administrator)
badge += Messages.DmModBadge;
if (autoReply)
badge += Messages.DmAutoResponse;
return Messages.FormatDirectChatMessageForSender(user.Username, dmRecipiant, message, badge);
default:
Logger.ErrorPrint(user.Username + " is trying to end a message in unknown channel " + channel.ToString("X"));
return "not implemented yet :(";

View file

@ -499,6 +499,35 @@ namespace HISP.Game.Chat
}
public static bool AutoReply(string message, string[] args, User user)
{
string replyMessage = string.Join(" ", args);
string formattedmessage = Messages.FormatPlayerCommandCompleteMessage(message.Substring(1));
replyMessage = replyMessage.Trim();
if (replyMessage.Length > 1024)
{
byte[] tooLong = PacketBuilder.CreateChat(Messages.AutoReplyTooLong, PacketBuilder.CHAT_BOTTOM_RIGHT);
user.LoggedinClient.SendPacket(tooLong);
return false;
}
Object violationReason = Chat.FilterMessage(replyMessage);
if (violationReason != null)
{
byte[] hasVios = PacketBuilder.CreateChat(Messages.AutoReplyHasViolations, PacketBuilder.CHAT_BOTTOM_RIGHT);
user.LoggedinClient.SendPacket(hasVios);
return false;
}
user.AutoReplyText = replyMessage;
byte[] chatPacket = PacketBuilder.CreateChat(formattedmessage, PacketBuilder.CHAT_BOTTOM_LEFT);
user.LoggedinClient.SendPacket(chatPacket);
return true;
}
public static bool Dance(string message, string[] args, User user)
{
string moves = string.Join(" ", args).ToLower();

View file

@ -551,6 +551,10 @@ namespace HISP.Game
public static string[] StatPlayerFormats;
public static string StatThirstDizzy;
public static string StatHungerStumble;
// Misc Stats
public static string StatMiscHeader;
@ -644,11 +648,18 @@ namespace HISP.Game
public static string AdminChatFormatForSender;
public static string ModChatFormatForSender;
public static string DmModBadge;
public static string DmAutoResponse;
public static string ChatViolationMessageFormat;
public static string PasswordNotice;
public static string CapsNotice;
public static string RandomMovement;
// AutoReply
public static string AutoReplyTooLong;
public static string AutoReplyHasViolations;
// Transport
public static string CantAffordTransport;
@ -2545,9 +2556,9 @@ namespace HISP.Game
{
return PrivateNotesMetaFormat.Replace("%PRIVATENOTES%", privateNotes);
}
public static string FormatRandomMovementMessage(string statName)
public static string FormatRandomMovementMessage(string statName, string message)
{
return RandomMovement.Replace("%STAT%", statName);
return RandomMovement.Replace("%STAT%", statName).Replace("%MSG%", message);
}
public static string FormatJewerlyEquipMessage(string itemName)
@ -2889,15 +2900,11 @@ namespace HISP.Game
return HereChatFormat.Replace("%USERNAME%", username).Replace("%MESSAGE%", message);
}
public static string FormatDirectMessage(string username, string message)
public static string FormatDirectMessage(string username, string message, string formatPart)
{
return DirectChatFormat.Replace("%USERNAME%", username).Replace("%MESSAGE%", message);
return DirectChatFormat.Replace("%USERNAME%", username).Replace("%MESSAGE%", message).Replace("%FORMATPART%", formatPart);
}
public static string FormatDirectMessageForMod(string username, string message)
{
return DirectChatFormatForModerators.Replace("%USERNAME%", username).Replace("%MESSAGE%", message);
}
public static string FormatGlobalChatMessageForMod(string username, string message)
{
return GlobalChatFormatForModerators.Replace("%USERNAME%", username).Replace("%MESSAGE%", message);
@ -2951,9 +2958,9 @@ namespace HISP.Game
{
return ModChatFormatForSender.Replace("%USERNAME%", username).Replace("%MESSAGE%", message).Replace("%AMOUNT%", numbMods.ToString("N0", CultureInfo.InvariantCulture));
}
public static string FormatDirectChatMessageForSender(string username,string toUsername, string message)
public static string FormatDirectChatMessageForSender(string username,string toUsername, string message, string formatPart)
{
return DirectChatFormatForSender.Replace("%FROMUSER%", username).Replace("%TOUSER%", toUsername).Replace("%MESSAGE%", message);
return DirectChatFormatForSender.Replace("%FROMUSER%", username).Replace("%TOUSER%", toUsername).Replace("%MESSAGE%", message).Replace("%FORMATPART%", formatPart);
}
public static string FormatIdleWarningMessage()
{