if (theRaven.crowFactsSubscribers.Contains(bySpace[1])) {
theRaven.crowFactsSubscribers.Remove(bySpace[1]);
send.PrivMsg(String.Format("{0} has been unsubscribed.",bySpace[1]),incoming.target);
} else {
send.PrivMsg("No such subscriber",incoming.target);
}
}
connection.Write(send);
return;
case "r.join":
if (bySpace.Length < 2) {
send.PrivMsg(theRaven.helpText,incoming.target);
} else {
if (!theRaven.channels.Contains(bySpace[1])) {
theRaven.channels.Add(bySpace[1]);
send.CreateJoinMessage(bySpace[1]);
} else {
send.PrivMsg("Already joined channel",incoming.target);
}
}
connection.Write(send);
return;
case "r.part":
if (bySpace.Length < 2) {
send.PrivMsg(theRaven.helpText,incoming.target);
} else {
if (theRaven.channels.Contains(bySpace[1])) {
theRaven.channels.Remove(bySpace[1]);
send.CreatePartMessage(bySpace[1]);
} else {
send.PrivMsg("No such channel",incoming.target);
}
}
connection.Write(send);
return;
case "r.say":
if (bySpace.Length < 3 || !bySpace[1].StartsWith("#")) {
send.PrivMsg(theRaven.helpText,incoming.target);
} else {
StringBuilder newMsg = new StringBuilder(bySpace[2]);
for (int i = 3; i < bySpace.Length; i++) {
newMsg.Append(" ");
newMsg.Append(bySpace[i]);
}
send.PrivMsg(newMsg.ToString(),bySpace[1]);
}
connection.Write(send);
return;
case "r.act":
if (bySpace.Length < 3 || !bySpace[1].StartsWith("#")) {
send.PrivMsg(theRaven.helpText,incoming.target);
} else {
StringBuilder newAction = new StringBuilder(bySpace[2]);
for (int i = 3; i < bySpace.Length; i++) {
newAction.Append(" ");
newAction.Append(bySpace[i]);
}
send.ActionMsg(newAction.ToString(),bySpace[1]);
}
connection.Write(send);
return;
case "r.whitelist":
if (bySpace.Length < 2) {
send.PrivMsg("This is the whitelist:",incoming.user);
connection.Write(send);
foreach (String user in theRaven.whitelist) {
send.PrivMsg(user,incoming.user);
connection.Write(send);
}
send.PrivMsg("End whitelist",incoming.user);
} else {
if (!theRaven.whitelist.Contains(bySpace[1]) && !theRaven.blacklist.Contains(bySpace[1])) {
theRaven.whitelist.Add(bySpace[1]);
send.PrivMsg(String.Format("{0} has been whitelisted.",bySpace[1]),incoming.user);
} else {
send.PrivMsg("Already whitelisted or is a blacklisted user",incoming.user);
}
}
connection.Write(send);
return;
case "r.blacklist":
if (bySpace.Length < 2) {
send.PrivMsg("This is the blacklist:",incoming.user);
connection.Write(send);
foreach (String user in theRaven.blacklist) {
send.PrivMsg(user,incoming.user);
connection.Write(send);
}
send.PrivMsg("End blacklist",incoming.user);
} else {
if (!theRaven.blacklist.Contains(bySpace[1]) && !theRaven.whitelist.Contains(bySpace[1])) {
theRaven.blacklist.Add(bySpace[1]);
send.PrivMsg(String.Format("{0} has been blacklisted.",bySpace[1]),incoming.user);
} else {
send.PrivMsg("Already blacklisted or is an admin user",incoming.user);
}
}
connection.Write(send);
return;
case "r.greylist":
if (bySpace.Length < 2) {
send.PrivMsg(theRaven.helpText,incoming.target);
} else {
if (theRaven.whitelist.Contains(bySpace[1])) {
theRaven.whitelist.Remove(bySpace[1]);
send.PrivMsg("User cleared from whitelist",incoming.user);
} else if (theRaven.blacklist.Contains(bySpace[1])) {
theRaven.blacklist.Remove(bySpace[1]);
send.PrivMsg("User cleared from blacklist",incoming.user);
} else {
send.PrivMsg("No action needed",incoming.user);
}
}
connection.Write(send);
return;
case "r.adminhelp":
send.PrivMsg("r.adminhelp, r.cf to crowfacts, r.us to unsubscribe, r.whitelist to make user bot admin, r.blacklist to block user, r.greylist to pull user off *list, r.say [channel] [message], r.join a channel, r.part a channel, r.quit to quit",incoming.user);
connection.Write(send);
return;
// Commenting because I believe this to be unneeded
// TODO Reevaluate
/* case "r.ident":
theRaven.IdentifySelfToServer();
return;*/
case "r.mailerreset":
theRaven.MailerCount = new Dictionary<String,int>();
send.PrivMsg("Mailer counts have been reset",incoming.user);
connection.Write(send);
return;
}
return;
}
/// <summary>
/// This function returns a search string for the user to browse.
/// </summary>
/// <param name=searchBase> this is the base of the search URL</param>
/// <param name=request> This is the string requested to be recombined.</param>
/// <param name=junction>This is the character to use to combine the search arguments</param>
public static String FormatSearch(String searchBase,String request,String junction) {
StringBuilder formattedString = new StringBuilder(searchBase);
String[] elements = request.Split(' ');
if (elements.Length < 2) return helpString;
formattedString.Append(elements[1]); //First element is the command