forked from MCCTeam/Minecraft-Console-Client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsample-script-pm-forwarder.cs
39 lines (34 loc) · 1.29 KB
/
sample-script-pm-forwarder.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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);
}
}
}
}