mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-10-14 21:22:49 +00:00
Add new sample script: PM forwarder
Suggestion by GetPots
This commit is contained in:
parent
b1d5d0b32e
commit
e72580bcb6
1 changed files with 39 additions and 0 deletions
39
MinecraftClient/config/sample-script-pm-forwarder.cs
Normal file
39
MinecraftClient/config/sample-script-pm-forwarder.cs
Normal file
|
|
@ -0,0 +1,39 @@
|
||||||
|
//MCCScript 1.0
|
||||||
|
|
||||||
|
MCC.LoadBot(new PMForwarder());
|
||||||
|
|
||||||
|
//MCCScript Extensions
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This bot can forward received PMs to other players
|
||||||
|
/// </summary>
|
||||||
|
public class PMForwarder : ChatBot
|
||||||
|
{
|
||||||
|
private const string PMRecipientsFile = "pm-forward-to.txt";
|
||||||
|
private string[] pmRecipients;
|
||||||
|
|
||||||
|
public PMForwarder()
|
||||||
|
{
|
||||||
|
pmRecipients = LoadDistinctEntriesFromFile(PMRecipientsFile);
|
||||||
|
if (Settings.Bots_Owners.Count == 0)
|
||||||
|
LogToConsole("No Bot owners in Settings INI file. Unloading.");
|
||||||
|
else if (pmRecipients.Length == 0)
|
||||||
|
LogToConsole("No PM Recipients in '" + PMRecipientsFile + "'. Unloading.");
|
||||||
|
else LogToConsole(String.Format(
|
||||||
|
"Forwarding PMs from owners {0} to recipients {1}",
|
||||||
|
String.Join(", ", Settings.Bots_Owners), String.Join(", ", pmRecipients)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void GetText(string text)
|
||||||
|
{
|
||||||
|
text = GetVerbatim(text);
|
||||||
|
string message = "", sender = "";
|
||||||
|
if (IsPrivateMessage(text, ref message, ref sender) && Settings.Bots_Owners.Contains(sender.ToLower().Trim()))
|
||||||
|
{
|
||||||
|
LogToConsole("Forwarding PM to " + String.Join(", ", pmRecipients));
|
||||||
|
foreach (string recipient in pmRecipients)
|
||||||
|
SendPrivateMessage(recipient, message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue