TheRaven/RavenConfigure.csharp

67 lines
2.1 KiB
Plaintext
Raw Normal View History

Converting to Git. Bazaar log was: ------------------------------------------------------------ revno: 6 committer: dev <dev@aninix.net> branch nick: TheRaven timestamp: Thu 2016-06-02 23:21:56 -0500 message: Updating to include dedicated raven user. Adding RavenExecute.Command() static function to handle OS integration. Updating RavenCommand to use Djinni package for mailing. ------------------------------------------------------------ revno: 5 committer: dev <dev@aninix.net> branch nick: TheRaven timestamp: Wed 2016-04-20 16:59:51 -0500 message: Updated Makefile to include OS dependencies Updated ircservermessage to fix dropped sections of searches from things like "r.image :blar:" Added new tinyURL feature -- WARNING: this requires that the OS has a script api-keys in the path that will return an API key for the TinyURL service ------------------------------------------------------------ revno: 4 committer: dev <dev@aninix.net> branch nick: TheRaven timestamp: Mon 2016-03-28 14:40:00 -0500 message: MailerCount is now added to limit the number of pages sent to admins. ------------------------------------------------------------ revno: 3 committer: ircd <ircd@aninix.net> branch nick: TheRaven timestamp: Fri 2016-01-15 14:36:54 -0600 message: Removing an unneeded file -- requests are tracked in keep.google.com now Makefile had a run rule added to run the bot in the foreground with the verbose flag. This prevents the user from accidentally compiling and installing TheRaven with higher verbosity and filling system logs. Ravencommand was modified to check for user modes r (registerd on UnrealIRCd) or G (registered on InspIRCd) before running whitelist commands. connection.csharp had functions added to check for users being authenticated (IRC response code 330 in a WHOIS request) and do get modes ------------------------------------------------------------ revno: 2 committer: root <root@aninix.net> branch nick: TheRaven timestamp: Mon 2015-12-14 14:58:02 -0600 message: Updated commenting Removed requests file in favor of keep.google.com Updated ircservermessage.csharp et. al. for better verbosity options Edited connection.csharp to not need a Raven instance and instead take host and port Updated private globals to standard Moved Verbosity enum to not be inside ReportMessage class ------------------------------------------------------------ revno: 1 committer: ircd <ircd@aninix.net> branch nick: TheRaven timestamp: Thu 2015-12-10 21:58:41 -0600 message: Adding all my files.
2016-08-04 11:08:14 -05:00
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using AniNIX.Shared;
Converting to Git. Bazaar log was: ------------------------------------------------------------ revno: 6 committer: dev <dev@aninix.net> branch nick: TheRaven timestamp: Thu 2016-06-02 23:21:56 -0500 message: Updating to include dedicated raven user. Adding RavenExecute.Command() static function to handle OS integration. Updating RavenCommand to use Djinni package for mailing. ------------------------------------------------------------ revno: 5 committer: dev <dev@aninix.net> branch nick: TheRaven timestamp: Wed 2016-04-20 16:59:51 -0500 message: Updated Makefile to include OS dependencies Updated ircservermessage to fix dropped sections of searches from things like "r.image :blar:" Added new tinyURL feature -- WARNING: this requires that the OS has a script api-keys in the path that will return an API key for the TinyURL service ------------------------------------------------------------ revno: 4 committer: dev <dev@aninix.net> branch nick: TheRaven timestamp: Mon 2016-03-28 14:40:00 -0500 message: MailerCount is now added to limit the number of pages sent to admins. ------------------------------------------------------------ revno: 3 committer: ircd <ircd@aninix.net> branch nick: TheRaven timestamp: Fri 2016-01-15 14:36:54 -0600 message: Removing an unneeded file -- requests are tracked in keep.google.com now Makefile had a run rule added to run the bot in the foreground with the verbose flag. This prevents the user from accidentally compiling and installing TheRaven with higher verbosity and filling system logs. Ravencommand was modified to check for user modes r (registerd on UnrealIRCd) or G (registered on InspIRCd) before running whitelist commands. connection.csharp had functions added to check for users being authenticated (IRC response code 330 in a WHOIS request) and do get modes ------------------------------------------------------------ revno: 2 committer: root <root@aninix.net> branch nick: TheRaven timestamp: Mon 2015-12-14 14:58:02 -0600 message: Updated commenting Removed requests file in favor of keep.google.com Updated ircservermessage.csharp et. al. for better verbosity options Edited connection.csharp to not need a Raven instance and instead take host and port Updated private globals to standard Moved Verbosity enum to not be inside ReportMessage class ------------------------------------------------------------ revno: 1 committer: ircd <ircd@aninix.net> branch nick: TheRaven timestamp: Thu 2015-12-10 21:58:41 -0600 message: Adding all my files.
2016-08-04 11:08:14 -05:00
namespace AniNIX.TheRaven {
public static class RavenConfigure {
/// <summary>
/// Create a new list from the line-delimited entries in a file
/// </summary>
/// <param name=filename> the file to read </param>
/// <returns> A List of Strings containing the lines.</returns>
public static List<String> ReadLineDelimitedFile(String filename) {
String line = null;
int count = 0;
//Read all the file to join.
ReportMessage.Log(Verbosity.Verbose,String.Format("Reading {0}",filename)); //Path.GetFileName(filename)));
List<String> newEntries = new List<String>();
StreamReader fileReader = new StreamReader(filename);
line = fileReader.ReadLine();
while (line != null) {
if (line.Length < 1) {
line = fileReader.ReadLine();
continue;
}
line = line.Trim();
if (line[0] == '#') {
line = fileReader.ReadLine();
continue;
} //Skip lines starting with a #
String[] byHash = line.Split('#'); //Ignore everything after a #
newEntries.Add(byHash[0]);
count++;
ReportMessage.Log(Verbosity.VeryVerbose,String.Format("Added entry {0} from {1}",line,Path.GetFileName(filename)));
line = fileReader.ReadLine();
}
fileReader.Close();
ReportMessage.Log(Verbosity.VeryVerbose,String.Format("Found {0} newEntries.",newEntries.Count));
return newEntries;
}
/// <summary>
/// Get the String[] of lines in a file -- use this for random performance
/// </summary>
/// <param name=filename> the file to read </param>
/// <returns> A String[] </returns>
public static String[] ReadLineDelimitedFileToArr(String filename) {
return RavenConfigure.ReadLineDelimitedFile(filename).ToArray();
}
/// <summary>
/// Read the first line from a file -- this is useful for allowing configuration of single strings.
/// </summary>
/// <param name=filename> the file to read </param>
/// <returns>The first line as a String</returns>
public static String ReadFirstLineFromFile(String filename) {
StreamReader fileReader = new StreamReader(filename);
String readString = fileReader.ReadLine();
fileReader.Close();
return readString;
}
}
}