ArchiSteamFarm/IPC/Controllers/Api/BotController.cs
/// <summary>
///     Provides input value to given bot for next usage.
/// </summary>
Provides input value to given bot for next usage.
Provides input value to given bot for next usage .
[Consumes("application/json")]
	[HttpPost("{botNames:required}/Input")]
	[ProducesResponseType(typeof(GenericResponse), (int) HttpStatusCode.OK)]
	[ProducesResponseType(typeof(GenericResponse), (int) HttpStatusCode.BadRequest)]
	public async Task<ActionResult<GenericResponse>> InputPost(string botNames, [FromBody] BotInputRequest request) {
		if (string.IsNullOrEmpty(botNames)) {
			throw new ArgumentNullException(nameof(botNames));
		}
		ArgumentNullException.ThrowIfNull(request);
		if ((request.Type == ASF.EUserInputType.None) || !Enum.IsDefined(typeof(ASF.EUserInputType), request.Type) || string.IsNullOrEmpty(request.Value)) {
			return BadRequest(new GenericResponse(false, string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsInvalid, $"{nameof(request.Type)} || {nameof(request.Value)}")));
		}
		HashSet<Bot>? bots = Bot.GetBots(botNames);
		if ((bots == null) || (bots.Count == 0)) {
			return BadRequest(new GenericResponse(false, string.Format(CultureInfo.CurrentCulture, Strings.BotNotFound, botNames)));
		}
		IList<bool> results = await Utilities.InParallel(bots.Select(bot => Task.Run(() => bot.SetUserInput(request.Type, request.Value)))).ConfigureAwait(false);
		return Ok(results.All(static result => result) ? new GenericResponse(true) : new GenericResponse(false, Strings.WarningFailed));
	}
[ Consumes ( " " ) ] [ HttpPost ( " " ) ] [ ProducesResponseType ( typeof ( GenericResponse ) , ( int ) HttpStatusCode . OK ) ] [ ProducesResponseType ( typeof ( GenericResponse ) , ( int ) HttpStatusCode . BadRequest ) ] public async Task < ActionResult < GenericResponse > > InputPost ( string botNames , [ FromBody ] BotInputRequest request ) { if ( string . IsNullOrEmpty ( botNames ) ) { throw new ArgumentNullException ( nameof ( botNames ) ) ; } ArgumentNullException . ThrowIfNull ( request ) ; if ( ( request . Type == ASF . EUserInputType . None ) || ! Enum . IsDefined ( typeof ( ASF . EUserInputType ) , request . Type ) || string . IsNullOrEmpty ( request . Value ) ) { return BadRequest ( new GenericResponse ( false , string . Format ( CultureInfo . CurrentCulture , Strings . ErrorIsInvalid , $" { nameof ( request . Type ) }  ||  { nameof ( request . Value ) } " ) ) ) ; } HashSet < Bot > ? bots = Bot . GetBots ( botNames ) ; if ( ( bots == null ) || ( bots . Count == 0 ) ) { return BadRequest ( new GenericResponse ( false , string . Format ( CultureInfo . CurrentCulture , Strings . BotNotFound , botNames ) ) ) ; } IList < bool > results = await Utilities . InParallel ( bots . Select ( bot => Task . Run ( ( ) => bot . SetUserInput ( request . Type , request . Value ) ) ) ) . ConfigureAwait ( false ) ; return Ok ( results . All ( static result => result ) ? new GenericResponse ( true ) : new GenericResponse ( false , Strings . WarningFailed ) ) ; }
Provides input value to given bot for next usage.
Provides input value to given bot for next usage .
botNames
string
BotInputRequest
[FromBody]