/// <summary> /// The function that runs at the start of the program /// </summary> /// <param name="args">arguments passed</param> public void Start(string[] args) { ulong startID = 0; ulong endID = 0; ulong channelID = 0; OptionSet options = new OptionSet { { "b|bot", "starts running the bot", b => { this._discordControler = new DiscordController(); } }, { "s|startid=", "sets the startID for getting a list of messages", s => startID = ulong.Parse(s) }, { "e|endid=", "sets the endID for getting a list of messages", s => endID = ulong.Parse(s) }, { "c|channelid=", "sets the channelID for getting a list of messages", s => channelID = ulong.Parse(s) }, { "m|messages", "gets the messages for the specified channel between two MessageIDs", m => { _sqliteControler = new SQLiteController(); _sqliteControler.OpenDB(@"./Chatlog"); _sqliteControler.PrintMessages(startID, endID, channelID); } }, }; options.Parse(args); Console.ReadLine(); }
/// <summary> /// Initializes a new instance of the <see cref="DiscordController" /> class. /// </summary> /// <param name="logging">Set to false to disable logging. True by default</param> /// <param name="linking">Set to false to disable linking to Github. True by default</param> public DiscordController(bool logging = true, bool linking = true) { this._dbcontroler = new SQLiteController(); this._dbcontroler.OpenDB(@"./Chatlog"); this._client = new DiscordClient(); this.Logging = logging; this.Linking = linking; this._client.MessageReceived += this._client_MessageReceived; this._client.MessageDeleted += this._client_MessageDeleted; this._client.MessageUpdated += this._client_MessageUpdated; string token = Environment.GetEnvironmentVariable("DISCORD_TOKEN"); if (token != null) { this._client.ExecuteAndWait(async() => { await _client.Connect(token); }); } else { this._client.ExecuteAndWait(async() => { await _client.Connect(System.IO.File.ReadAllText(@"./token")); }); } }