Skip to content

Search Function

Sam edited this page Mar 29, 2025 · 2 revisions

About

When a user selects a module in Sampyhub, we use search(name,author) to send the data to the function where the user can choose to use it or not.

Screen.Recording.2025-03-29.124912.mp4

As you can see in the video, it prompts the user if they want to run the script or not. This is so the user doesn't run the wrong script by mistake (e.g., a spelling mistake).

The actual function

It is found at line 29 in Sampyhub.

def search(name,author): # Tells you about the module if it exists
    print("Searching...") # Tells you it's searching
    time.sleep(3)
    print("")
    print(f"{bcolors.OKGREEN}Found module!{bcolors.ENDC}")
    print("")
    print(f"{name} by {author} [{bcolors.OKGREEN}VERIFIED{bcolors.ENDC}]")
    if click.confirm("Do you want to run this script?"):
        time.sleep(0.5)
        print("Starting module...")
        time.sleep(2)
    else:
        kill(499)

Example

search("name.py","sam51210")

Clone this wiki locally