File tree Expand file tree Collapse file tree 4 files changed +55
-8
lines changed
Expand file tree Collapse file tree 4 files changed +55
-8
lines changed Original file line number Diff line number Diff line change 11using System ;
22using System . Collections . Generic ;
3+ using System . Linq ;
34using InstagramApiSharp . API . Builder ;
45using InstagramApiSharp . Classes ;
6+ using InstagramApiSharp . Classes . Android . DeviceInfo ;
57using InstagramApiSharp . Logger ;
8+ using Org . BouncyCastle . Asn1 . X500 ;
69
710namespace Instagram_Reels_Bot . Helpers . Instagram
811{
@@ -29,14 +32,29 @@ public void InitializeAPI()
2932 . Build ( ) ;
3033
3134 // Set the Android Device:
32- //instaApi.SetDevice(InstagramProcessor.device);
35+ if ( StaticDevice == null )
36+ {
37+ StaticDevice = AndroidDeviceGenerator . GetRandomAndroidDevice ( ) ;
38+ }
39+ else
40+ {
41+ Random rand = new Random ( ) ;
42+ StaticDevice . IGBandwidthSpeedKbps = $ "{ rand . Next ( 1233 , 1567 ) } .{ rand . Next ( 100 , 999 ) } ";
43+ StaticDevice . IGBandwidthTotalTimeMS = rand . Next ( 781 , 999 ) . ToString ( ) ;
44+ StaticDevice . DeviceId = ApiRequestMessage . GenerateDeviceIdFromGuid ( StaticDevice . DeviceGuid ) ;
45+ }
3346 }
3447
3548 /// <summary>
3649 /// The 2FA secret code for generating OTPs
3750 /// </summary>
3851 public string OTPSecret { get ; set ; }
3952
53+ /// <summary>
54+ /// List of times that this account should be used at
55+ /// </summary>
56+ public AndroidDevice StaticDevice { get ; set ; }
57+
4058 /// <summary>
4159 /// Set to true if the account has be blocked or failed to log in.
4260 /// Defaults to false.
Original file line number Diff line number Diff line change 99using Instagram_Reels_Bot . Helpers . Instagram ;
1010using InstagramApiSharp ;
1111using InstagramApiSharp . Classes ;
12+ using InstagramApiSharp . Classes . Android . DeviceInfo ;
1213using Microsoft . Extensions . Configuration ;
1314
1415namespace Instagram_Reels_Bot . Helpers
@@ -71,6 +72,10 @@ public void InstagramLogin(IGAccount account)
7172 //Set the user:
7273 instaApi . SetUser ( account ) ;
7374
75+ //Set the device
76+ instaApi . SetDevice ( account . StaticDevice ) ;
77+ Console . WriteLine ( instaApi . GetCurrentDevice ( ) . DeviceId ) ;
78+
7479 //Get the state file
7580 string stateFile ;
7681 if ( config [ "StateFile" ] != null && config [ "StateFile" ] != "" )
@@ -197,6 +202,7 @@ public static void LoadAccounts()
197202 for ( int i = 0 ; i < creds . Count ; i ++ )
198203 {
199204 creds [ i ] . UsageTimes = config . GetSection ( "IGAccounts:" + i + ":UsageTimes" ) . Get < List < IGAccount . OperatingTime > > ( ) ;
205+ creds [ i ] . StaticDevice = config . GetSection ( "IGAccounts:" + i + ":StaticDevice" ) . Get < AndroidDevice > ( ) ;
200206 }
201207 Accounts = creds ;
202208 }
Original file line number Diff line number Diff line change 77 </PropertyGroup >
88
99 <ItemGroup >
10- <PackageReference Include =" Discord.Net.Commands" Version =" 3.8.1 " />
11- <PackageReference Include =" Discord.Net.Core" Version =" 3.8.1 " />
12- <PackageReference Include =" Discord.Net.WebSocket" Version =" 3.8.1 " />
10+ <PackageReference Include =" Discord.Net.Commands" Version =" 3.9.0 " />
11+ <PackageReference Include =" Discord.Net.Core" Version =" 3.9.0 " />
12+ <PackageReference Include =" Discord.Net.WebSocket" Version =" 3.9.0 " />
1313 <PackageReference Include =" HtmlAgilityPack" Version =" 1.11.46" />
1414 <PackageReference Include =" Microsoft.Extensions.Configuration" Version =" 7.0.0" />
1515 <PackageReference Include =" Microsoft.Extensions.Configuration.Json" Version =" 7.0.0" />
1616 <PackageReference Include =" Microsoft.Extensions.DependencyInjection" Version =" 7.0.0" />
17- <PackageReference Include =" MongoDB.Driver" Version =" 2.18 .0" />
17+ <PackageReference Include =" MongoDB.Driver" Version =" 2.19 .0" />
1818 <PackageReference Include =" OpenGraph-Net" Version =" 4.0.1" />
19- <PackageReference Include =" Discord.Net.Interactions" Version =" 3.8.1 " />
20- <PackageReference Include =" Otp.NET" Version =" 1.2.2 " />
19+ <PackageReference Include =" Discord.Net.Interactions" Version =" 3.9.0 " />
20+ <PackageReference Include =" Otp.NET" Version =" 1.3.0 " />
2121 <PackageReference Include =" Bman46InstagramApiSharpLabs" Version =" 1.7.6" />
22- <PackageReference Include =" Microsoft.Extensions.Configuration.Binder" Version =" 7.0.1 " />
22+ <PackageReference Include =" Microsoft.Extensions.Configuration.Binder" Version =" 7.0.3 " />
2323 </ItemGroup >
2424
2525 <ItemGroup >
Original file line number Diff line number Diff line change 1313using Instagram_Reels_Bot . Helpers . Instagram ;
1414using System . IO ;
1515using System . Collections . Generic ;
16+ using InstagramApiSharp . Classes . Android . DeviceInfo ;
17+ using System . Text . Json ;
1618
1719namespace Instagram_Reels_Bot . Services
1820{
@@ -257,6 +259,27 @@ public async Task MessageReceivedAsync(SocketMessage rawMessage)
257259 await message . ReplyAsync ( "State files removed." ) ;
258260 }
259261 }
262+ else if ( message . Content . ToLower ( ) . StartsWith ( "generatedevice" ) )
263+ {
264+ if ( ! string . IsNullOrEmpty ( _config [ "OwnerID" ] ) && message . Author . Id == ulong . Parse ( _config [ "OwnerID" ] ) )
265+ {
266+ AndroidDevice device = AndroidDeviceGenerator . GetRandomAndroidDevice ( ) ;
267+ string jsonString = "```\n " + JsonSerializer . Serialize ( device ) + "\n ```" ;
268+ await message . ReplyAsync ( "Device:\n " + jsonString ) ;
269+ }
270+ }
271+ else if ( message . Content . ToLower ( ) . StartsWith ( "accountdevice" ) )
272+ {
273+ if ( ! string . IsNullOrEmpty ( _config [ "OwnerID" ] ) && message . Author . Id == ulong . Parse ( _config [ "OwnerID" ] ) )
274+ {
275+ foreach ( IGAccount user in InstagramProcessor . AccountFinder . Accounts )
276+ {
277+ AndroidDevice device = user . StaticDevice ;
278+ string jsonString = "```\n " + JsonSerializer . Serialize ( device ) + "\n ```" ;
279+ await message . ReplyAsync ( user . UserName + " Device:\n " + jsonString ) ;
280+ }
281+ }
282+ }
260283 return ;
261284 }
262285
You can’t perform that action at this time.
0 commit comments