allow 2 inputs after link for bot

This commit is contained in:
Believethehype 2023-12-01 21:17:32 +01:00
parent 01bd25ce40
commit 85bc9eabb7
5 changed files with 30 additions and 20 deletions

View File

@ -213,7 +213,7 @@ class Bot:
if entry is not None:
user = get_or_add_user(db=self.dvm_config.DB, npub=entry['npub'],
client=self.client, config=self.dvm_config)
time.sleep(2.0)
reply_event = EventBuilder.new_encrypted_direct_msg(self.keys,
PublicKey.from_hex(user.npub),
content,
@ -420,22 +420,36 @@ class Bot:
tags.append(tag)
output = Tag.parse(["output", "text/plain"])
tags.append(output)
relaylist = ["relays"]
relay_list = ["relays"]
for relay in self.dvm_config.RELAY_LIST:
relaylist.append(relay)
relays = Tag.parse(relaylist)
relay_list.append(relay)
relays = Tag.parse(relay_list)
tags.append(relays)
return tags
tags = []
command = decrypted_text.replace(split[0] + " ", "")
split = command.split(" -")
input = split[0].rstrip()
print(input)
input_type = "text"
if input.startswith("http"):
input_type = "url"
i_tag = Tag.parse(["i", input, input_type])
temp = input.split(" ")
if len(temp) > 1:
input_type = "url"
i_tag1 = Tag.parse(["i", temp[0], input_type])
tags.append(i_tag1)
input_type = "text"
i_tag2 = Tag.parse(["i", input.replace(temp[0], "").lstrip(), input_type])
tags.append(i_tag2)
else:
input_type = "url"
i_tag = Tag.parse(["i", input, input_type])
tags.append(i_tag)
else:
print(input)
input_type = "text"
i_tag = Tag.parse(["i", input, input_type])
tags.append(i_tag)
alt_tag = Tag.parse(["alt", self.dvm_config.SUPPORTED_DVMS[index].TASK])
tags.append(alt_tag)
@ -443,10 +457,11 @@ class Bot:
for relay in self.dvm_config.RELAY_LIST:
relaylist.append(relay)
relays_tag = Tag.parse(relaylist)
# TODO readd relays tag, but need to find a way to parse it for both str and tag
tags = [i_tag, relays_tag, alt_tag]
tags.append(relays_tag)
remaining_text = command.replace(input, "")
print(remaining_text)
params = remaining_text.rstrip().split(" -")
for i in params:

View File

@ -247,7 +247,7 @@ if __name__ == '__main__':
admin_config.REBROADCAST_NIP89 = False
admin_config.UPDATE_PROFILE = False
admin_config.LUD16 = ""
dvm = build_example("Image Converter Inkpunk", "image_converter_inkpunk", admin_config, os.getenv("NOVA_SERVER"), "inkpunk", 0.6)
dvm = build_example("Image Converter Inkpunk", "image2image", admin_config, os.getenv("NOVA_SERVER"), "", 0.6)
dvm.run()
keep_alive()

View File

@ -103,7 +103,7 @@ def build_example(name, identifier, admin_config):
nip89info = {
"name": name,
"image": "https://image.nostr.build/c33ca6fc4cc038ca4adb46fdfdfda34951656f87ee364ef59095bae1495ce669.jpg",
"about": "I extract text from pdf documents",
"about": "I extract text from pdf documents. I only support Latin letters",
"nip90Params": nip90params
}

View File

@ -21,7 +21,7 @@ class DVMConfig:
LNBITS_ADMIN_KEY = '' # In order to pay invoices, e.g. from the bot to DVMs, or reimburse users.
LNBITS_URL = 'https://lnbits.com'
DB: str
NEW_USER_BALANCE: int = 250 # Free credits for new users
NEW_USER_BALANCE: int = 0 # Free credits for new users
NIP89: NIP89Config
SHOW_RESULT_BEFORE_PAYMENT: bool = False # if this is true show results even when not paid right after autoprocess

View File

@ -35,7 +35,6 @@ def nip89_announce_tasks(dvm_config, client):
def fetch_nip89_paramters_for_deletion(keys, eventid, client, dvmconfig):
print("Pubkey generated from Private Key " + keys.public_key().to_hex())
idfilter = Filter().id(EventId.from_hex(eventid)).limit(1)
nip89events = client.get_events_of([idfilter], timedelta(seconds=dvmconfig.RELAY_TIMEOUT))
d_tag = ""
@ -51,17 +50,13 @@ def fetch_nip89_paramters_for_deletion(keys, eventid, client, dvmconfig):
print("No dtag found")
return
pubkey = event.pubkey().to_hex()
print("Pubkey of Event: " + pubkey)
if pubkey == keys.public_key().to_hex():
if event.pubkey().to_hex() == keys.public_key().to_hex():
nip89_delete_announcement(event.id().to_hex(), keys, d_tag, client, dvmconfig)
print("NIP89 announcement deleted from known relays!")
else:
print("Privatekey does not belong to event")
def nip89_delete_announcement(eid: str, keys: Keys, dtag: str, client: Client, config):
e_tag = Tag.parse(["e", eid])
a_tag = Tag.parse(["a", str(EventDefinitions.KIND_ANNOUNCEMENT) + ":" + keys.public_key().to_hex() + ":" + dtag])