mirror of
https://github.com/vishalxl/nostr_console.git
synced 2025-05-28 13:09:57 +02:00
default without argument invocation now possible with no pubkey
This commit is contained in:
parent
ebbc1776c0
commit
a5e320cf72
@ -93,23 +93,23 @@ Future<void> main(List<String> arguments) async {
|
||||
return;
|
||||
}
|
||||
userPrivateKey = "";
|
||||
print("Going to use public key $userPublicKey. You will not be able to send posts/replies.");
|
||||
}
|
||||
|
||||
// process private key argument, and it overrides what's given in pub key argument, if any pubkey is given
|
||||
if( argResults[prikeyArg] != null) {
|
||||
userPrivateKey = argResults[prikeyArg];
|
||||
if( userPrivateKey.length != 64){
|
||||
print("Length of provided private key should be 64. Exiting.");
|
||||
return;
|
||||
}
|
||||
userPublicKey = myGetPublicKey(userPrivateKey);
|
||||
userPublicKey = myGetPublicKey(userPrivateKey);
|
||||
print("Going to use the provided private key");
|
||||
}
|
||||
|
||||
// write informative message in case user is using the default private key
|
||||
// write informative message in case user is not using proper keys
|
||||
if( userPublicKey == gDefaultPublicKey) {
|
||||
print("${gWarningColor}You seem to be using the default public key starting with e8c, which comes bundled with this $exename ");
|
||||
print("You should ideally create your own private key and use it with ${gWarningColor}--prikey$gColorEndMarker program argument. ");
|
||||
print("You can create your own private key from ${gWarningColor}astral.ninja, branle.netlify.app$gColorEndMarker, or other such tools.\n");
|
||||
print("Create a private key from ${gWarningColor}astral.ninja, @damusapp or anigma.io, or even from command line using `openssl rand -hex 32`.$gColorEndMarker.\n");
|
||||
}
|
||||
|
||||
// handle relay related argument
|
||||
@ -297,8 +297,10 @@ Future<void> main(List<String> arguments) async {
|
||||
}
|
||||
|
||||
// get event for user
|
||||
getUserEvents(gListRelayUrls1, userPublicKey, limitPerSubscription, getSecondsDaysAgo(limitSelfEvents));
|
||||
getMentionEvents(gListRelayUrls2, userPublicKey, limitPerSubscription, getSecondsDaysAgo(limitSelfEvents)); // from relay group 2
|
||||
if( userPublicKey!= "") {
|
||||
getUserEvents(gListRelayUrls1, userPublicKey, limitPerSubscription, getSecondsDaysAgo(limitSelfEvents));
|
||||
getMentionEvents(gListRelayUrls2, userPublicKey, limitPerSubscription, getSecondsDaysAgo(limitSelfEvents)); // from relay group 2
|
||||
}
|
||||
|
||||
// get other user events
|
||||
getMultiUserEvents(gListRelayUrls1, gDefaultFollows, limitPerSubscription, getSecondsDaysAgo(limitFollowPosts));
|
||||
@ -326,27 +328,27 @@ Future<void> main(List<String> arguments) async {
|
||||
if( gDebug > 0) log.info("Received user events.");
|
||||
|
||||
initialEvents.forEach((e) => processKind3Event(e)); // first process the kind 3 event
|
||||
// get the latest kind 3 event for the user, which lists his 'follows' list
|
||||
Event? contactEvent = getContactEvent(userPublicKey);
|
||||
|
||||
if( userPublicKey != "") {
|
||||
// get the latest kind 3 event for the user, which lists his 'follows' list
|
||||
Event? contactEvent = getContactEvent(userPublicKey);
|
||||
|
||||
// if contact list was found, get user's feed; also get some default contacts
|
||||
Set<String> contacts = {};
|
||||
//contacts.addAll(gDefaultFollows);
|
||||
if (contactEvent != null ) {
|
||||
if(gDebug > 0) print("In main: found contact list: \n ${contactEvent.originalJson}");
|
||||
contactEvent.eventData.contactList.forEach((contact) {
|
||||
contacts.add(contact.id);
|
||||
});
|
||||
// if contact list was found, get user's feed; also get some default contacts
|
||||
Set<String> contacts = {};
|
||||
//contacts.addAll(gDefaultFollows);
|
||||
if (contactEvent != null ) {
|
||||
if(gDebug > 0) print("In main: found contact list: \n ${contactEvent.originalJson}");
|
||||
contactEvent.eventData.contactList.forEach((contact) {
|
||||
contacts.add(contact.id);
|
||||
});
|
||||
}
|
||||
getContactFeed(gListRelayUrls1, contacts, gLimitPerSubscription, getSecondsDaysAgo(2 * limitFollowPosts));
|
||||
}
|
||||
getContactFeed(gListRelayUrls1, contacts, gLimitPerSubscription, getSecondsDaysAgo(2 * limitFollowPosts));
|
||||
|
||||
// calculate top mentioned ptags, and then get the events for those users
|
||||
//log.info('calling getpTags');
|
||||
List<String> pTags = getpTags(initialEvents, gMaxPtagsToGet);
|
||||
//log.info('after getpTags\n');
|
||||
getMultiUserEvents(gListRelayUrls1, pTags, gLimitPerSubscription, getSecondsDaysAgo(limitFollowPosts));
|
||||
|
||||
|
||||
stdout.write('Waiting for feed to come in..............');
|
||||
Future.delayed(Duration(milliseconds: gDefaultNumWaitSeconds * 1), () {
|
||||
|
||||
@ -357,10 +359,7 @@ Future<void> main(List<String> arguments) async {
|
||||
if( gDebug > 0) log.info("Received ptag events events.");
|
||||
|
||||
// Creat tree from all events read form file
|
||||
//log.info("going to call getTree.");
|
||||
Store node = getTree(initialEvents);
|
||||
//node.printEventInfo();
|
||||
//log.info("after getTree returned.");
|
||||
gStore = node;
|
||||
|
||||
clearEvents();
|
||||
|
@ -19,7 +19,7 @@ Future<void> processAnyIncomingEvents(Store node, [bool printNotifications = tru
|
||||
|
||||
String nameToDisplay = userPrivateKey.length == 64?
|
||||
"$gCommentColor${getAuthorName(userPublicKey)}$gColorEndMarker":
|
||||
"${gWarningColor}You are not signed in$gColorEndMarker but are using public key $userPublicKey";
|
||||
"${gWarningColor}You are not signed in$gColorEndMarker";
|
||||
|
||||
if( printNotifications) {
|
||||
node.printNotifications(newEventIdsSet, nameToDisplay);
|
||||
@ -414,11 +414,11 @@ int showMenu(List<String> menuOptions, String menuName, [String menuInfo = ""])
|
||||
print("\n");
|
||||
|
||||
printMenu(menuOptions);
|
||||
String nameToDisplay = userPrivateKey.length == 64?
|
||||
"$gCommentColor${getAuthorName(userPublicKey)}$gColorEndMarker":
|
||||
"${gWarningColor}You are not signed in$gColorEndMarker but are using public key $userPublicKey";
|
||||
String promptWithName = userPrivateKey.length == 64?
|
||||
"Signed in as $gCommentColor${getAuthorName(userPublicKey)}$gColorEndMarker":
|
||||
"${gWarningColor}You are not signed in so can't send any messages$gColorEndMarker";
|
||||
|
||||
stdout.write("Signed in as $nameToDisplay. ");
|
||||
stdout.write("$promptWithName. ");
|
||||
stdout.write("Type option number: ");
|
||||
String? userOptionInput = stdin.readLineSync();
|
||||
String userOption = userOptionInput??"";
|
||||
@ -493,6 +493,11 @@ Future<void> otherOptionsMenuUi(Store node) async {
|
||||
|
||||
|
||||
case 2: //edit your profile
|
||||
if( userPublicKey == "" || userPrivateKey == "") {
|
||||
printWarning("No private key provided so you can't edit your profile.");
|
||||
break;
|
||||
}
|
||||
|
||||
print("Your current name: ${getAuthorName(userPublicKey)}");
|
||||
print("Your 'about me': ${gKindONames[userPublicKey]?.about}");
|
||||
print("Your current profile picture: ${gKindONames[userPublicKey]?.picture}\n");
|
||||
@ -515,6 +520,11 @@ Future<void> otherOptionsMenuUi(Store node) async {
|
||||
break;
|
||||
|
||||
case 3:
|
||||
if( userPublicKey == "" || userPrivateKey == "") {
|
||||
printWarning("No private key provided so you can't delete any event.");
|
||||
break;
|
||||
}
|
||||
|
||||
stdout.write("Enter event id to delete: ");
|
||||
String? $tempEventId = stdin.readLineSync();
|
||||
String userInputId = $tempEventId??"";
|
||||
|
@ -1499,7 +1499,7 @@ extension StringX on String {
|
||||
|
||||
// https://www.thoughtco.com/most-common-french-words-1372759
|
||||
Set<String> frenchWords = {"oui", "je", "le", "un", "de", "et", "merci", "une", "ce", "pas"};
|
||||
Set<String> spanishWords = {"y", "se", "el", "uso", "que", "te", "los", "va", "ser", "si", "por", "lo", "es", "era", "un"};;
|
||||
Set<String> spanishWords = {"y", "se", "el", "uso", "que", "te", "los", "va", "ser", "si", "por", "lo", "es", "era", "un", "o"};;
|
||||
|
||||
Set<String> romanceWords = frenchWords.union(spanishWords);
|
||||
for( String word in romanceWords) {
|
||||
|
@ -58,7 +58,7 @@ List<String> gListRelayUrls2 = [
|
||||
];
|
||||
|
||||
// well known disposable test private key
|
||||
const String gDefaultPublicKey = "e8caa2028a7090ffa85f1afee67451b309ba2f9dee655ec8f7e0a02c29388180";
|
||||
const String gDefaultPublicKey = "";
|
||||
String userPrivateKey = "";
|
||||
String userPublicKey = gDefaultPublicKey;
|
||||
|
||||
|
@ -6,7 +6,7 @@ homepage: https://github.com/vishalxl/nostr_console
|
||||
# Release 0.1.9-beta
|
||||
# used kind 104
|
||||
# fix for tag related test fail
|
||||
# removed debug prints
|
||||
# default without argument invocation now possible with no pubkey
|
||||
|
||||
environment:
|
||||
sdk: '>=2.17.3 <3.0.0'
|
||||
|
@ -251,7 +251,7 @@ String expectedResult =
|
||||
Store node = await getTree(initialEvents);
|
||||
|
||||
//await node.printDirectRoomInfo(showAllRooms);
|
||||
expect(7, node.getNumDirectRooms(), reason:'verify correct number of direct chat rooms created');
|
||||
expect(0, node.getNumDirectRooms(), reason:'verify correct number of direct chat rooms created');
|
||||
expect(78, node.getNumChannels(), reason: 'verify correct number of public channels created');
|
||||
|
||||
expect(3046, node.getNumMessagesInChannel('25e5c82273a271cb1a840d0060391a0bf4965cafeb029d5ab55350b418953fbb'),
|
||||
|
Loading…
x
Reference in New Issue
Block a user