mirror of
https://github.com/believethehype/nostrdvm.git
synced 2025-06-29 05:08:54 +02:00
allow 2 inputs after link for bot
This commit is contained in:
37
bot/bot.py
37
bot/bot.py
@ -213,7 +213,7 @@ class Bot:
|
|||||||
if entry is not None:
|
if entry is not None:
|
||||||
user = get_or_add_user(db=self.dvm_config.DB, npub=entry['npub'],
|
user = get_or_add_user(db=self.dvm_config.DB, npub=entry['npub'],
|
||||||
client=self.client, config=self.dvm_config)
|
client=self.client, config=self.dvm_config)
|
||||||
|
time.sleep(2.0)
|
||||||
reply_event = EventBuilder.new_encrypted_direct_msg(self.keys,
|
reply_event = EventBuilder.new_encrypted_direct_msg(self.keys,
|
||||||
PublicKey.from_hex(user.npub),
|
PublicKey.from_hex(user.npub),
|
||||||
content,
|
content,
|
||||||
@ -420,22 +420,36 @@ class Bot:
|
|||||||
tags.append(tag)
|
tags.append(tag)
|
||||||
output = Tag.parse(["output", "text/plain"])
|
output = Tag.parse(["output", "text/plain"])
|
||||||
tags.append(output)
|
tags.append(output)
|
||||||
relaylist = ["relays"]
|
relay_list = ["relays"]
|
||||||
for relay in self.dvm_config.RELAY_LIST:
|
for relay in self.dvm_config.RELAY_LIST:
|
||||||
relaylist.append(relay)
|
relay_list.append(relay)
|
||||||
relays = Tag.parse(relaylist)
|
relays = Tag.parse(relay_list)
|
||||||
tags.append(relays)
|
tags.append(relays)
|
||||||
return tags
|
return tags
|
||||||
|
|
||||||
|
|
||||||
|
tags = []
|
||||||
command = decrypted_text.replace(split[0] + " ", "")
|
command = decrypted_text.replace(split[0] + " ", "")
|
||||||
split = command.split(" -")
|
split = command.split(" -")
|
||||||
input = split[0].rstrip()
|
input = split[0].rstrip()
|
||||||
print(input)
|
|
||||||
input_type = "text"
|
|
||||||
if input.startswith("http"):
|
if input.startswith("http"):
|
||||||
input_type = "url"
|
temp = input.split(" ")
|
||||||
|
if len(temp) > 1:
|
||||||
i_tag = Tag.parse(["i", input, input_type])
|
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])
|
alt_tag = Tag.parse(["alt", self.dvm_config.SUPPORTED_DVMS[index].TASK])
|
||||||
tags.append(alt_tag)
|
tags.append(alt_tag)
|
||||||
@ -443,10 +457,11 @@ class Bot:
|
|||||||
for relay in self.dvm_config.RELAY_LIST:
|
for relay in self.dvm_config.RELAY_LIST:
|
||||||
relaylist.append(relay)
|
relaylist.append(relay)
|
||||||
relays_tag = Tag.parse(relaylist)
|
relays_tag = Tag.parse(relaylist)
|
||||||
# TODO readd relays tag, but need to find a way to parse it for both str and tag
|
tags.append(relays_tag)
|
||||||
tags = [i_tag, relays_tag, alt_tag]
|
|
||||||
remaining_text = command.replace(input, "")
|
remaining_text = command.replace(input, "")
|
||||||
print(remaining_text)
|
print(remaining_text)
|
||||||
|
|
||||||
|
|
||||||
params = remaining_text.rstrip().split(" -")
|
params = remaining_text.rstrip().split(" -")
|
||||||
|
|
||||||
for i in params:
|
for i in params:
|
||||||
|
@ -247,7 +247,7 @@ if __name__ == '__main__':
|
|||||||
admin_config.REBROADCAST_NIP89 = False
|
admin_config.REBROADCAST_NIP89 = False
|
||||||
admin_config.UPDATE_PROFILE = False
|
admin_config.UPDATE_PROFILE = False
|
||||||
admin_config.LUD16 = ""
|
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()
|
dvm.run()
|
||||||
|
|
||||||
keep_alive()
|
keep_alive()
|
||||||
|
@ -103,7 +103,7 @@ def build_example(name, identifier, admin_config):
|
|||||||
nip89info = {
|
nip89info = {
|
||||||
"name": name,
|
"name": name,
|
||||||
"image": "https://image.nostr.build/c33ca6fc4cc038ca4adb46fdfdfda34951656f87ee364ef59095bae1495ce669.jpg",
|
"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
|
"nip90Params": nip90params
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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_ADMIN_KEY = '' # In order to pay invoices, e.g. from the bot to DVMs, or reimburse users.
|
||||||
LNBITS_URL = 'https://lnbits.com'
|
LNBITS_URL = 'https://lnbits.com'
|
||||||
DB: str
|
DB: str
|
||||||
NEW_USER_BALANCE: int = 250 # Free credits for new users
|
NEW_USER_BALANCE: int = 0 # Free credits for new users
|
||||||
NIP89: NIP89Config
|
NIP89: NIP89Config
|
||||||
SHOW_RESULT_BEFORE_PAYMENT: bool = False # if this is true show results even when not paid right after autoprocess
|
SHOW_RESULT_BEFORE_PAYMENT: bool = False # if this is true show results even when not paid right after autoprocess
|
||||||
|
|
||||||
|
@ -35,7 +35,6 @@ def nip89_announce_tasks(dvm_config, client):
|
|||||||
|
|
||||||
|
|
||||||
def fetch_nip89_paramters_for_deletion(keys, eventid, client, dvmconfig):
|
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)
|
idfilter = Filter().id(EventId.from_hex(eventid)).limit(1)
|
||||||
nip89events = client.get_events_of([idfilter], timedelta(seconds=dvmconfig.RELAY_TIMEOUT))
|
nip89events = client.get_events_of([idfilter], timedelta(seconds=dvmconfig.RELAY_TIMEOUT))
|
||||||
d_tag = ""
|
d_tag = ""
|
||||||
@ -51,17 +50,13 @@ def fetch_nip89_paramters_for_deletion(keys, eventid, client, dvmconfig):
|
|||||||
print("No dtag found")
|
print("No dtag found")
|
||||||
return
|
return
|
||||||
|
|
||||||
pubkey = event.pubkey().to_hex()
|
if event.pubkey().to_hex() == keys.public_key().to_hex():
|
||||||
print("Pubkey of Event: " + pubkey)
|
|
||||||
if pubkey == keys.public_key().to_hex():
|
|
||||||
nip89_delete_announcement(event.id().to_hex(), keys, d_tag, client, dvmconfig)
|
nip89_delete_announcement(event.id().to_hex(), keys, d_tag, client, dvmconfig)
|
||||||
print("NIP89 announcement deleted from known relays!")
|
print("NIP89 announcement deleted from known relays!")
|
||||||
else:
|
else:
|
||||||
print("Privatekey does not belong to event")
|
print("Privatekey does not belong to event")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def nip89_delete_announcement(eid: str, keys: Keys, dtag: str, client: Client, config):
|
def nip89_delete_announcement(eid: str, keys: Keys, dtag: str, client: Client, config):
|
||||||
e_tag = Tag.parse(["e", eid])
|
e_tag = Tag.parse(["e", eid])
|
||||||
a_tag = Tag.parse(["a", str(EventDefinitions.KIND_ANNOUNCEMENT) + ":" + keys.public_key().to_hex() + ":" + dtag])
|
a_tag = Tag.parse(["a", str(EventDefinitions.KIND_ANNOUNCEMENT) + ":" + keys.public_key().to_hex() + ":" + dtag])
|
||||||
|
Reference in New Issue
Block a user