This repository has been archived by the owner on May 2, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
BaseModule.cs
61 lines (49 loc) · 2.02 KB
/
BaseModule.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using Newtonsoft.Json;
namespace SteamBotLite
{
abstract class BaseModule
{
public List<BaseCommand> commands {get; private set;}
public List<BaseCommand> adminCommands {get; private set;}
public List<BaseTask> tasks { get; private set;}
public string ModuleSavedDataFilePath()
{
// Console.WriteLine("Path: {0}", Path.Combine(userhandler.GetType().Name, this.GetType().Name + ".json"));
return Path.Combine(userhandler.GetType().Name, this.GetType().Name + ".json");
}
protected VBot userhandler;
public bool DeletableModule = true;
private Dictionary<string, object> ConfigFilePath = JsonConvert.DeserializeObject<Dictionary<string, object>>(System.IO.File.ReadAllText(@"config.json"));
public Dictionary<string, object> config;
public BaseModule(VBot bot, Dictionary<string, object> Jsconfig)
{
this.config = JsonConvert.DeserializeObject<Dictionary<string, object>>(Jsconfig[this.GetType().Name].ToString());
this.userhandler = bot;
commands = new List<BaseCommand>();
adminCommands = new List<BaseCommand>();
tasks = new List<BaseTask>();
}
public void savePersistentData()
{
string jsonData = getPersistentData();
if (Directory.Exists(ModuleSavedDataFilePath()))
{
System.IO.File.WriteAllText(ModuleSavedDataFilePath(), jsonData);
}
else
{
Directory.CreateDirectory(userhandler.GetType().Name);
System.IO.File.WriteAllText(ModuleSavedDataFilePath(), jsonData);
};
}
public abstract void OnAllModulesLoaded();
abstract public string getPersistentData();
abstract public void loadPersistentData();
}
}