forked from nongnoobjung/Volibot-Garena
-
Notifications
You must be signed in to change notification settings - Fork 0
/
FileHandlers.cs
131 lines (120 loc) · 5.27 KB
/
FileHandlers.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
/*
* FileHandler.cs is part of the opensource VoliBot AutoQueuer project.
* Credits to: shalzuth, Maufeat, imsosharp
* Find assemblies for this AutoQueuer on LeagueSharp's official forum at:
* http://www.joduska.me/
* You are allowed to copy, edit and distribute this project,
* as long as you don't touch this notice and you release your project with source.
*/
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace RitoBot
{
public static class FileHandlers
{
static string theFolder = AppDomain.CurrentDomain.BaseDirectory + @"config\\";
static string accountsTxtLocation = AppDomain.CurrentDomain.BaseDirectory + @"config\\accounts.txt";
static string configTxtLocation = AppDomain.CurrentDomain.BaseDirectory + @"config\\settings.ini";
static string versionTxtLocation = AppDomain.CurrentDomain.BaseDirectory + @"config\\version.txt";
public static void SettingsIni(string LauncherPath, string MaxBots, string MaxLevel, string ChampionPick, string Spell1, string Spell2, string Region, string BuyBoost)
{
try
{
if (File.Exists(configTxtLocation))
{
File.Delete(configTxtLocation);
}
var newfile = File.Create(configTxtLocation);
newfile.Close();
var content = "[General]\nLauncherPath=" + LauncherPath + "\nLoadGUI=false\nMaxBots=" + MaxBots + "\nMaxLevel=" + MaxLevel + "\nChampionPick=" + ChampionPick + "\nSpell1=" + Spell1 + "\nSpell2=" + Spell2 + "\nRndSpell=false\nReplaceConfig=false\nAutoUpdate=false\n\n[Account]\nRegion=" + Region + "\nBuyBoost=" + BuyBoost;
var separator = new string[] { "\n" };
string[] contentlines = content.Split(separator, StringSplitOptions.None);
File.WriteAllLines(configTxtLocation, contentlines);
}
catch (Exception e)
{
MessageBox.Show(e.ToString());
}
}
public static void AccountsTxt(string Username, string Password)
{
var content = Username + "|" + Password;
try
{
string accs = File.ReadAllText(accountsTxtLocation);
if (accs.Contains("username"))
{
if (File.Exists(accountsTxtLocation))
{
File.Delete(accountsTxtLocation);
}
var newfile = File.Create(accountsTxtLocation);
newfile.Close();
var separator = new string[] { "\n" };
string[] contentlines = content.Split(separator, StringSplitOptions.None);
File.WriteAllLines(accountsTxtLocation, contentlines);
}
else File.AppendAllText(accountsTxtLocation, content + Environment.NewLine);
}
catch (Exception e)
{
MessageBox.Show(e.ToString());
}
}
public static void AccountsTxt(string Username, string Password, string QueueType)
{
var content = Username + "|" + Password + "|" + QueueType;
try
{
string accs = File.ReadAllText(accountsTxtLocation);
if (accs.Contains("username"))
{
if (File.Exists(accountsTxtLocation))
{
File.Delete(accountsTxtLocation);
}
var newfile = File.Create(accountsTxtLocation);
newfile.Close();
var separator = new string[] { "\n" };
string[] contentlines = content.Split(separator, StringSplitOptions.None);
File.WriteAllLines(accountsTxtLocation, contentlines);
}
else File.AppendAllText(accountsTxtLocation, content + Environment.NewLine);
}
catch (Exception e)
{
MessageBox.Show(e.ToString());
}
}
public static void AccountsTxt(string Username, string Password, string QueueType, string ChampionPick)
{
var content = Username + "|" + Password + "|" + QueueType + "|" + ChampionPick;
try
{
string accs = File.ReadAllText(accountsTxtLocation);
if (accs.Contains("username"))
{
if (File.Exists(accountsTxtLocation))
{
File.Delete(accountsTxtLocation);
}
var newfile = File.Create(accountsTxtLocation);
newfile.Close();
var separator = new string[] { "\n" };
string[] contentlines = content.Split(separator, StringSplitOptions.None);
File.WriteAllLines(accountsTxtLocation, contentlines);
}
else File.AppendAllText(accountsTxtLocation, content + Environment.NewLine);
}
catch (Exception e)
{
MessageBox.Show(e.ToString());
}
}
}
}