· 4 years ago · Apr 28, 2021, 09:14 PM
1import time
2import random
3from gql import gql, Client
4from gql.transport.requests import RequestsHTTPTransport
5
6APITOKEN = "INSERT AID API TOKEN (ACCESS KEY) HERE"
7ADVNAME = "INSERT ADVENTURE PUBLIC ID HERE"
8ADVTEXT = "I like to play with horses. Horses are fun."
9
10transport = RequestsHTTPTransport(
11 url="https://api.aidungeon.io/graphql", verify=True, retries=3,
12 headers={'X-Access-Token': APITOKEN}
13)
14
15client = Client(transport=transport, fetch_schema_from_transport=True)
16
17params = {"input":{"publicId":ADVNAME,"type":"story","text":ADVTEXT,"characterName":None}}
18
19query = gql(
20"""
21mutation ($input: ActionInput) {
22 addAction(input: $input) {
23 message
24 time
25 returnedInput
26 __typename
27 }
28}
29"""
30)
31
32for i in range(0,2000):
33 result = client.execute(query, variable_values=params)
34 time.sleep(random.randrange(1, 3, 1))
35 print(i)
36 print(result)