-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathProgram.cs
168 lines (152 loc) · 6.38 KB
/
Program.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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
using System;
using CommandLine;
using Newtonsoft.Json;
using kk33.RbxStreamSniper.Json;
namespace kk33.RbxStreamSniper
{
class Program
{
class Options
{
[Option('c', "cookie", Required = false, HelpText = "Set your .ROBLOSECURITY cookie.")]
public string Cookie { get; set; }
[Option('u', "user", Required = false, HelpText = "Set target user ID.")]
public string UserId { get; set; }
[Option('n', "username", Required = false, HelpText = "Set target user name.")]
public string UserName { get; set; }
[Option('p', "place", Required = false, HelpText = "Set place ID target is in.")]
public string PlaceId { get; set; }
[Option('s', "search", Required = false, HelpText = "Search for game by name and use start place of first result.")]
public string GameName { get; set; }
}
static void Main(string[] args)
{
Parser.Default.ParseArguments<Options>(args).WithParsed<Options>(o =>
{
string cookie = null;
string placeid = null;
string userid = null;
string avatar = null;
string ownid = null;
int totalPages = 0;
Console.WriteLine();
if (o.Cookie != null)
{
cookie = ".ROBLOSECURITY=" + o.Cookie.Trim();
}
else
{
Console.WriteLine("No .ROBLOSECURITY cookie specified. You may also use \"rbxcookie\" environment variable.");
Environment.Exit(1);
}
Console.Write("Getting your ID to check if cookie is valid... ");
try
{
ownid = Roblox.GetOwnId(cookie);
}
catch (Exception e) { CatchException(e); }
Console.WriteLine(ownid);
Console.Write("Getting target user ID... ");
if (o.UserId != null)
{
userid = o.UserId;
}
else
{
if (o.UserName != null)
{
try
{
userid = JsonConvert.DeserializeObject<GetByUsername>(HttpHelpers.Get($"https://api.roblox.com/users/get-by-username?username={o.UserName.Trim()}")).Id.ToString();
}
catch (Exception e) { CatchException(e); }
}
else
{
Console.WriteLine("No user specified.");
Console.WriteLine();
Environment.Exit(1);
}
}
Console.WriteLine(userid);
Console.Write("Getting target user avatar url... ");
try
{
avatar = Roblox.GetAvatarHeadshotUrl(userid);
}
catch (Exception e) { CatchException(e); }
Console.WriteLine(avatar);
Console.Write("Getting place ID... ");
if (o.PlaceId != null)
{
placeid = o.PlaceId;
}
else
{
if (o.GameName != null)
{
try
{
placeid = Roblox.FindFirstPlace(o.GameName).PlaceID.ToString();
}
catch (Exception e) { CatchException(e); }
}
else
{
Console.WriteLine("No game specified.");
Console.WriteLine();
Environment.Exit(1);
}
}
Console.WriteLine(placeid);
Console.Write("Getting total pages... ");
try
{
totalPages = (int)Math.Ceiling((decimal)Roblox.GetPlaceInstances(placeid, 0, cookie).TotalCollectionSize / 10);
}
catch (Exception e) { CatchException(e); }
Console.WriteLine(totalPages);
Console.WriteLine();
for (int page = 0; page <= totalPages; page++)
{
try
{
PlaceInstances placeInstances = Roblox.GetPlaceInstances(placeid, page, cookie);
foreach (var server in placeInstances.Collection)
foreach (var player in server.CurrentPlayers)
if (player.Thumbnail.Url == avatar)
{
Console.WriteLine();
Console.WriteLine();
Console.WriteLine(" Result: " + server.JoinScript);
Console.WriteLine();
Environment.Exit(0);
}
string text = $" {page + 1}/{totalPages} [";
int textLen = CountCharacters(text);
Console.SetCursorPosition(0, Console.CursorTop);
Console.Write($"{text}{ProgressBar.Generate(page * 100 / 500, Console.WindowWidth - textLen - 2)}] ");
}
catch (Exception e) { CatchException(e); }
}
Console.WriteLine();
Console.WriteLine();
Console.WriteLine("Cant find player...");
Console.WriteLine();
});
}
public static int CountCharacters(string source)
{
int count = 0;
foreach (char c in source)
count++;
return count;
}
public static void CatchException(Exception e)
{
Console.WriteLine("\r\n===========\r\nException: " + e.ToString() + " | " + e.InnerException?.ToString());
Console.WriteLine();
Environment.Exit(2);
}
}
}