public override Task <int> RunAsync(string[] args) { if (!AccessKey.IsSet && !Authorization.IsSet) { throw new ArgumentNullException("You must provide at least one of the key parameters for a bot. Use 'k' or 'a' parameters"); } if (!Node.IsSet) { throw new ArgumentNullException("You must provide the node or a bot identifier using 'n' parameter. For example: 'saveNode -n papagaio -k YOUR KEY' or 'saveNode -n [email protected] -k YOUR KEY'"); } var stringNode = Node.Value.ToLowerInvariant().Trim(); if (!stringNode.Contains("@")) { stringNode += "@msging.net"; } var node = Lime.Protocol.Node.Parse(stringNode); var authorization = Authorization.Value; var accessKey = AccessKey.Value; if (!Authorization.IsSet) { authorization = BlipKeysFormater.GetAuthorizationKey(node.Name, accessKey); } _settingsFile.AddNodeCredentials(new NodeCredential { Node = node, Authorization = authorization }); return(Task.FromResult(0)); }
public override Task <int> RunAsync(string[] args) { var authorization = Authorization.Value; var accessKey = AccessKey.Value; if (!AccessKey.IsSet && !Authorization.IsSet) { throw new ArgumentNullException("You must provide at least one of the key parameters for a bot. Use 'k' or 'a' parameters"); } if (AccessKey.IsSet) { authorization = BlipKeysFormater.GetAuthorizationKey(Identifier.Value, accessKey); } else { accessKey = BlipKeysFormater.GetAccessKey(authorization); } Console.WriteLine($"Identifier: {Identifier.Value.ToLowerInvariant()}\n"); Console.Write("AccessKey: "); using (CLI.WithForeground(ConsoleColor.Blue)) { Console.Write($"{accessKey}\n"); } Console.Write("Authorization: "); using (CLI.WithForeground(ConsoleColor.Blue)) { Console.Write($"{authorization}\n"); } return(Task.FromResult(0)); }