Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to modify scripts so I can run them on back4app? #299

Open
DagriffpatchfanHosting opened this issue Dec 17, 2024 · 6 comments
Open

How to modify scripts so I can run them on back4app? #299

DagriffpatchfanHosting opened this issue Dec 17, 2024 · 6 comments
Labels
question Further information is requested

Comments

@DagriffpatchfanHosting
Copy link

DagriffpatchfanHosting commented Dec 17, 2024

How can I modify the following scripts to run properly with the back4app template? The docs said to put things like client.start() in a def run() function, but I'm not sure what that means. Is it possible for someone to help me out?

import scratchattach as sa
import json

session = sa.login("Dagriffpatchfan", "the_pw")
cloud = session.connect_cloud("1110802552") #replace with your project id
client = cloud.requests()

@client.request
def agent(argument1): #called when client receives request
    print(f"User: {argument1}")
    user = session.connect_user(argument1)
    project = user.projects(limit=3, offset=0)[0]
    print (f"Project URL: {project.url}")
    agent = project.raw_json().get('meta', {}).get('agent')
    print(f"Agent: {agent}")
    return agent

@client.event
def on_ready():
    print("Request handler is running")

client.start(thread=True) # thread=True is an optional argument. It makes the cloud requests handler run in a thread

and

import scratchattach as sa

session = sa.login("Dagriffpatchfan", "the_pw")

project1_cloud = session.connect_cloud("843162693")
project1_events = project1_cloud.events()
project2_cloud = session.connect_cloud("1102436009")
project2_events = project2_cloud.events()
 
@project1_events.event
def on_set(activity):
    project2_cloud.set_var(activity.var, activity.value)
@project2_events.event
def on_set(activity):
    project1_cloud.set_var(activity.var, activity.value)
 
project1_events.start()
project2_events.start()

Also, is it possible to run multiple scripts with just one back4app? If it matters, here is my forked template with the first script is here https://github.com/DagriffpatchfanHosting/for-8to16-/tree/main

@FAReTek1
Copy link
Collaborator

Change your password NOW

@DagriffpatchfanHosting
Copy link
Author

Change your password NOW

Thanks so much. I can't believe I put that in there!

@SpyC0der77
Copy link

oh sheesh

@DagriffpatchfanHosting
Copy link
Author

oh sheesh

It was an accident! I only put it in the second script, I somehow forgot to change it to 'the_pw' there. Please be nice.

@FAReTek1
Copy link
Collaborator

hmm, maybe it should be advised to store credentials seperately to prevent issues like this.
relating the original issue idrk how this back4app thing works so idrk how to help

@SpyC0der77
Copy link

oh sheesh

It was an accident! I only put it in the second script, I somehow forgot to change it to 'the_pw' there. Please be nice.

I wasn't meaning to be mean, I was saying sheesh because of what could've happened

@TimMcCool TimMcCool added the question Further information is requested label Dec 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants