Functions
handlers¶
alias()
¶
disable()
¶
enable()
¶
misc¶
error(msg)
¶
abort evaluation with a message.
Arguments¶
msg
:str
Examples¶
1 | error('the food bowl is empty') |
Discussion¶
Aborts that evaluation and comments on the issue in context with this error
get_secret(name):str
¶
Retreives a secret. This can only be called from the root module.
Arguments¶
name
:str
- name of the secret to fetch.
Returns¶
str
See Also¶
- TODO: secrets
http(url,method,body,headers,timeout,json,auth):status,status_code,body,json,headers
¶
Perform an HTTP call.
Arguments¶
url
:str
method
:str
(default=GET)body
:str
(default=None
)headers
:{str: str}
(default={}
)timeout
:int
(default=None
) - Timeout in secondsjson
(default=None
) - JSON body to send to server.auth
:(str, str)
(default=None
) - Username and password to use for basic authentication.
Returns¶
status
:str
- Response status as text.status_code
:int
body
:str
json
- JSON data if parsable.headers
:{str: str}
Examples¶
1 2 3 4 | resp = http("http://aws.random.cat/meow") if resp["status_code"] == 200: url = resp["json"].get("file") github.issue_create_comment("![meow](%s)" % url) |
Create a comment with a random cat image.
parse_commands(body):commands
¶
parse commands in a string
Arguments¶
body
:str
Returns¶
commands
:list({name=str, args=list(str), kwargs={str: str}, parts=list(str)})
Examples¶
1 | parse_commands("/meow" |
Parses the given string. Returns {'name': 'meow', args: [], kwargs: {}, parts: ['meow']}
.
Discussion¶
Usually commands are parsed automatically. Use this to parse commands given in another way.
warn(msg)
¶
emit a warning
Arguments¶
msg
:str
Examples¶
1 | warn('the cat is wiggling its tail') |
Emits a warning to the warnings log.
Discussion¶
Every issue comment after a warning is created will indicate that warning.
modules¶
pin(prefix,ref)
¶
Pin a path to a specific ref. Can only be called from the root module.
Arguments¶
prefix
:str
- '/' is assumed at the end of the prefixref
:str
Examples¶
1 | pin("github.com/owner/repo", "some-ref") |
All loads or uses for this owner/repo
will be fetched from some-ref
.
use(str,perms,events,**kwargs)
¶
Use a module. Can only be used in global scope. Can be called only by the root module.
Arguments¶
str
- Path to module to load. Use the form url#ref to use module at a specific ref.perms
:list(str)
(default=All allowed) - List of privilidged functions the module can call.events
:list(str)
(default=All allowed) - List of events to allow module to fire handlers on.**kwargs
- Additional module specific configuration arguments.
Examples¶
1 2 3 4 5 6 7 | use( "github.com/repokitteh/modules/kitteh.star", perms=[ 'http()', 'github_call(method=POST,path=path=/repos/*/*/issues/*/comments)', ], ) |
Brings in the kitteh module, allowing it only to perform HTTP calls and creating new comments on the same issue.
users¶
user_has_role(role):bool
¶
Checks if the invoking user holds a specific role.
Arguments¶
role
:str
- role to check
Returns¶
bool
- True if the user holds the specific role
Required Permissions¶
users:read
Examples¶
1 | user_has_role("confidant") |
See Also¶
- TODO: configuration
userstore¶
store_get(k):str
¶
Get a string for a specific key
Arguments¶
k
:str
- key
Returns¶
str
Required Permissions¶
userstore:read
store_put(k,v)
¶
Store a string for a specific key
Arguments¶
k
:str
- keyv
:str
- value
Required Permissions¶
userstore:write
Examples¶
1 | store_put("k", "v") |