2021-04-30 17:30:24 +00:00
|
|
|
"""
|
|
|
|
|
Example of how to request a Transfer
|
|
|
|
|
"""
|
|
|
|
|
from typing import *
|
|
|
|
|
|
2021-12-03 05:38:40 +00:00
|
|
|
from hippolyzer.lib.base.inventory import InventoryModel, InventoryItem
|
2021-06-03 02:58:41 +00:00
|
|
|
from hippolyzer.lib.base.message.message import Block, Message
|
2021-06-01 08:23:33 +00:00
|
|
|
from hippolyzer.lib.base.templates import (
|
2021-04-30 17:30:24 +00:00
|
|
|
AssetType,
|
|
|
|
|
EstateAssetType,
|
|
|
|
|
TransferRequestParamsSimEstate,
|
|
|
|
|
TransferRequestParamsSimInvItem,
|
|
|
|
|
TransferSourceType,
|
|
|
|
|
XferFilePath,
|
|
|
|
|
)
|
2021-06-01 08:23:33 +00:00
|
|
|
from hippolyzer.lib.proxy.addon_utils import BaseAddon, show_message
|
|
|
|
|
from hippolyzer.lib.proxy.commands import handle_command
|
|
|
|
|
from hippolyzer.lib.proxy.region import ProxiedRegion
|
|
|
|
|
from hippolyzer.lib.proxy.sessions import Session
|
2021-04-30 17:30:24 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
class TransferExampleAddon(BaseAddon):
|
|
|
|
|
@handle_command()
|
|
|
|
|
async def get_covenant(self, _session: Session, region: ProxiedRegion):
|
|
|
|
|
"""Get the current region's covenent"""
|
|
|
|
|
transfer = await region.transfer_manager.request(
|
|
|
|
|
source_type=TransferSourceType.SIM_ESTATE,
|
|
|
|
|
params=TransferRequestParamsSimEstate(
|
|
|
|
|
EstateAssetType=EstateAssetType.COVENANT,
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
show_message(transfer.reassemble_chunks().decode("utf8"))
|
|
|
|
|
|
|
|
|
|
@handle_command()
|
|
|
|
|
async def get_first_script(self, session: Session, region: ProxiedRegion):
|
|
|
|
|
"""Get the contents of the first script in the selected object"""
|
|
|
|
|
# Ask for the object inventory so we can find a script
|
2021-12-09 05:30:12 +00:00
|
|
|
region.circuit.send(Message(
|
2021-04-30 17:30:24 +00:00
|
|
|
'RequestTaskInventory',
|
|
|
|
|
Block('AgentData', AgentID=session.agent_id, SessionID=session.id),
|
|
|
|
|
Block('InventoryData', LocalID=session.selected.object_local),
|
|
|
|
|
))
|
2021-06-12 10:43:16 +00:00
|
|
|
inv_message = await region.message_handler.wait_for(('ReplyTaskInventory',), timeout=5.0)
|
2021-04-30 17:30:24 +00:00
|
|
|
|
|
|
|
|
# Xfer the inventory file and look for a script
|
|
|
|
|
xfer = await region.xfer_manager.request(
|
|
|
|
|
file_name=inv_message["InventoryData"]["Filename"], file_path=XferFilePath.CACHE)
|
|
|
|
|
inv_model = InventoryModel.from_bytes(xfer.reassemble_chunks())
|
|
|
|
|
first_script: Optional[InventoryItem] = None
|
2022-07-09 02:48:23 +00:00
|
|
|
for item in inv_model.all_items:
|
2021-04-30 17:30:24 +00:00
|
|
|
if item.type == "lsltext":
|
|
|
|
|
first_script = item
|
|
|
|
|
if not first_script:
|
|
|
|
|
show_message("No scripts in object?")
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
# Ask for the actual script contents
|
|
|
|
|
transfer = await region.transfer_manager.request(
|
|
|
|
|
source_type=TransferSourceType.SIM_INV_ITEM,
|
|
|
|
|
params=TransferRequestParamsSimInvItem(
|
|
|
|
|
OwnerID=first_script.permissions.owner_id,
|
|
|
|
|
TaskID=inv_model.root.node_id,
|
|
|
|
|
ItemID=first_script.item_id,
|
|
|
|
|
AssetType=AssetType.LSL_TEXT,
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
show_message(transfer.reassemble_chunks().decode("utf8"))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
addons = [TransferExampleAddon()]
|