Skip to content

Commit

Permalink
Optimization, Reddit Fixes
Browse files Browse the repository at this point in the history
Optimized beginning searches
Reddit fixes
Possible bug in ban list. Hold tight.
  • Loading branch information
imaboy321 committed Jan 25, 2017
1 parent b453806 commit e490503
Show file tree
Hide file tree
Showing 9 changed files with 162 additions and 53 deletions.
Binary file modified .vs/Ledybot/v14/.suo
Binary file not shown.
9 changes: 9 additions & 0 deletions Ledybot/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@
<setting name="Deposited" serializeAs="String">
<value>Ledyba</value>
</setting>
<setting name="Thread" serializeAs="String">
<value>5p3kgb</value>
</setting>
<setting name="Reddit" serializeAs="String">
<value>True</value>
</setting>
<setting name="Subreddit" serializeAs="String">
<value>PokemonPlaza</value>
</setting>
</Ledybot.Properties.Settings>
</userSettings>
</configuration>
63 changes: 54 additions & 9 deletions Ledybot/Form1.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 29 additions & 13 deletions Ledybot/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -177,14 +177,14 @@ private async void btn_Start_Click(object sender, EventArgs e)
botNumber = -1;
}

public void AppendListViewItem(string szTrainerName, string szNickname, string fc)
public void AppendListViewItem(string szTrainerName, string szNickname, string szSent, string fc)
{
if (InvokeRequired)
{
this.Invoke(new Action<string, string, string>(AppendListViewItem), new object[] { szTrainerName, szNickname, fc });
this.Invoke(new Action<string, string, string, string>(AppendListViewItem), new object[] { szTrainerName, szNickname, szSent, fc });
return;
}
string[] row = { DateTime.Now.ToString("h:mm:ss"), szTrainerName, szNickname, fc.Insert(4, "-").Insert(9, "-") };
string[] row = { DateTime.Now.ToString("h:mm:ss"), szTrainerName, szNickname, szSent, fc.Insert(4, "-").Insert(9, "-") };
var listViewItem = new ListViewItem(row);

lv_log.Items.Add(listViewItem);
Expand Down Expand Up @@ -240,6 +240,9 @@ private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
Properties.Settings.Default.IP = tb_IP.Text;
Properties.Settings.Default.Deposited = tb_PokemonToFind.Text;
Properties.Settings.Default.Blacklist = cb_Blacklist.Checked;
Properties.Settings.Default.Reddit = cb_Reddit.Checked;
Properties.Settings.Default.Thread = tb_thread.Text;
Properties.Settings.Default.Subreddit = tb_Subreddit.Text;
Properties.Settings.Default.Save();
}

Expand All @@ -248,6 +251,9 @@ private void MainForm_Load(object sender, EventArgs e)
tb_IP.Text = Properties.Settings.Default.IP;
tb_PokemonToFind.Text = Properties.Settings.Default.Deposited;
cb_Blacklist.Checked = Properties.Settings.Default.Blacklist;
cb_Reddit.Checked = Properties.Settings.Default.Reddit;
tb_thread.Text = Properties.Settings.Default.Thread;
tb_Subreddit.Text = Properties.Settings.Default.Subreddit;
}

private void btn_BrowseInject_Click(object sender, EventArgs e)
Expand Down Expand Up @@ -470,20 +476,30 @@ public void updateJSON()
{
return;
}
var json = "";
using (WebClient wc = new WebClient())
{
json = wc.DownloadString("https://www.reddit.com/r/PokemonPlaza/comments/" + tb_thread.Text + ".json?limt=1000&showmore=true");
}
List<DataJSON> data = JsonConvert.DeserializeObject<List<DataJSON>>(json);
foreach (ChildrenData cd in data[1].data.children)
try
{
string fc = cd.data.flair.Substring(cd.data.flair.IndexOf('-', 4) - 4, 14);
if (!commented.Contains(fc))
using (WebClient wc = new WebClient())
{
commented.Add(fc);
wc.DownloadStringCompleted += (sender, e) =>
{
List<DataJSON> data = JsonConvert.DeserializeObject<List<DataJSON>>(e.Result);
foreach (ChildrenData cd in data[1].data.children)
{
string fc = (cd.data.flair != null && cd.data.flair.Length >= 14 ? cd.data.flair.Substring(cd.data.flair.IndexOf('-', 4) - 4, 14) : "").Replace("-", "");
if (!commented.Contains(fc) && fc != "")
{
commented.Add(fc);
}
}
};

wc.DownloadStringAsync(new Uri("https://www.reddit.com/r/" + tb_Subreddit.Text + "/comments/" + tb_thread.Text + ".json?limt=1000&showmore=true"));
}
}
catch
{

}
}
}

Expand Down
50 changes: 23 additions & 27 deletions Ledybot/GTSBot7.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace Ledybot
class GTSBot7
{

public enum gtsbotstates { botstart, startsearch, openpokemonwanted, openwhatpokemon, typepokemon, presssearch, startfind, findfromend, findfromstart, trade, research, botexit, updatecomments };
public enum gtsbotstates { botstart, startsearch, openpokemonwanted, openwhatpokemon, typepokemon, presssearch, startfind, findfromend, findfromstart, trade, research, botexit, updatecomments, quicksearch };

private uint addr_PageSize = 0x32A6A1A4;
private uint addr_PageEndStartRecord = 0x32A6A68C;
Expand Down Expand Up @@ -211,7 +211,7 @@ public async Task<int> RunBot()
fc[4] = checksum;
long iFC = BitConverter.ToInt64(fc, 0);
szFC = iFC.ToString().PadLeft(12, '0');
if (Program.f1.commented.Contains(szFC) && !details.Item6.Contains(BitConverter.ToInt32(principal, 0)) && !Program.f1.banlist.Contains(szFC))
if ((!bReddit || Program.f1.commented.Contains(szFC)) && !details.Item6.Contains(BitConverter.ToInt32(principal, 0)) && !Program.f1.banlist.Contains(szFC))
{
int gender = block[0xE];
int level = block[0xF];
Expand Down Expand Up @@ -334,7 +334,7 @@ public async Task<int> RunBot()
fc[4] = checksum;
long iFC = BitConverter.ToInt64(fc, 0);
szFC = iFC.ToString().PadLeft(12, '0');
if (Program.f1.commented.Contains(szFC) && !details.Item6.Contains(BitConverter.ToInt32(principal, 0)) && !Program.f1.banlist.Contains(szFC))
if ((!bReddit || Program.f1.commented.Contains(szFC)) && !details.Item6.Contains(BitConverter.ToInt32(principal, 0)) && !Program.f1.banlist.Contains(szFC))
{
int gender = block[0xE];
int level = block[0xF];
Expand Down Expand Up @@ -371,7 +371,7 @@ public async Task<int> RunBot()
//}
if (tradeIndex == -1)
{
if (listlength < 100)
if (listlength < 100 && startIndex >= 200)
{
for (int i = 0; i < listlength; i++)
{
Expand Down Expand Up @@ -420,29 +420,9 @@ public async Task<int> RunBot()
botState = (int)gtsbotstates.research;
}
}
else
else if (startIndex < 200)
{
waitTaskbool = Program.helper.waitNTRwrite(addr_PageStartingIndex, 100000, iPID);
if (await waitTaskbool)
{
startIndex -= 100;
Program.helper.quickbuton(Program.PKTable.DpadLEFT, commandtime);
await Task.Delay(commandtime + delaytime);
Program.helper.quickbuton(Program.PKTable.DpadRIGHT, commandtime);
await Task.Delay(commandtime + delaytime);
Program.helper.quickbuton(Program.PKTable.DpadRIGHT, commandtime);
await Task.Delay(commandtime + delaytime);
await Task.Delay(3000);
Program.helper.quicktouch(10, 10, commandtime);
await Task.Delay(commandtime + delaytime + 250);
Program.helper.quicktouch(10, 10, commandtime);
await Task.Delay(commandtime + delaytime + 250);
Program.helper.quicktouch(10, 10, commandtime);
await Task.Delay(commandtime + delaytime + 250);
Program.helper.quicktouch(10, 10, commandtime);
await Task.Delay(commandtime + delaytime + 250);
botState = (int)gtsbotstates.findfromstart;
}
botState = (int)gtsbotstates.quicksearch;
}
}
}
Expand Down Expand Up @@ -472,7 +452,7 @@ public async Task<int> RunBot()
{
details.Item6.Add(BitConverter.ToInt32(principal, 0));
}
Program.f1.AppendListViewItem(szTrainerName, szNickname, szFC);
Program.f1.AppendListViewItem(szTrainerName, szNickname, dexnumber.ToString(), szFC);
//Inject the Pokemon to box1slot1
Program.scriptHelper.write(0x330d9838, cloneshort, iPID);
Program.helper.quickbuton(Program.PKTable.keyA, commandtime);
Expand All @@ -495,7 +475,16 @@ public async Task<int> RunBot()
break;
}
}
}

foreach (System.Data.DataRow row in Program.gd.details.Rows)
{
if (row[0].ToString() == dexnumber.ToString())
{
int amount = int.Parse(row[6].ToString()) + 1;
row[6] = amount;
break;
}
}

await Task.Delay(10250);
Expand Down Expand Up @@ -542,6 +531,13 @@ public async Task<int> RunBot()
}
}
break;
case (int)gtsbotstates.quicksearch:
Program.helper.quickbuton(Program.PKTable.keyB, commandtime);
await Task.Delay(commandtime + delaytime + 500);
await Program.helper.waittouch(160, 185);
await Task.Delay(2250);
botState = (int)gtsbotstates.findfromstart;
break;
case (int)gtsbotstates.research:
Program.helper.quicktouch(128, 64, commandtime);
await Task.Delay(commandtime + delaytime + 1000);
Expand Down
3 changes: 2 additions & 1 deletion Ledybot/GiveawayDetails.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ private void loadDetails()
details.Columns.Add("Gender Index", typeof(int));
details.Columns.Add("Level Index", typeof(int));
details.Columns.Add("Count", typeof(int));
details.Columns.Add("Traded", typeof(int));

if (File.Exists(Application.StartupPath + "\\giveawaydetails.xml"))
{
Expand Down Expand Up @@ -65,7 +66,7 @@ private void btn_Add_Click(object sender, EventArgs e)
}
}
}
details.Rows.Add(input.dex, input.def, input.specific, input.gender + 1, input.level + 1, input.count);
details.Rows.Add(input.dex, input.def, input.specific, input.gender + 1, input.level + 1, input.count, 0);
Program.f1.giveawayDetails.Add(input.dex, new Tuple<string, string, int, int, int, ArrayList>(input.def, input.specific, input.gender + 1, input.level + 1, input.count, new ArrayList()));
}
}
Expand Down
3 changes: 0 additions & 3 deletions Ledybot/Program.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Ledybot
Expand Down
Loading

0 comments on commit e490503

Please sign in to comment.