flottbot icon indicating copy to clipboard operation
flottbot copied to clipboard

how to call a function with params inside program when a action triggered?a

Open lucasjinreal opened this issue 3 years ago • 6 comments

how to call a function with params inside program when a action triggered?a

lucasjinreal avatar Sep 11 '22 03:09 lucasjinreal

do you have an example?

you can do:

actions:
  - name: sample script
    type: exec
    cmd: python config/scripts/main.py <insert parameter>

and your script would handle what to do with the parameter. if you're talking about something else, i might need an example.

wass3r avatar Sep 12 '22 03:09 wass3r

@wass3r hi, I am not using script, I wanna call a function inside go program itself, with params. Is that possible?

lucasjinreal avatar Sep 12 '22 03:09 lucasjinreal

i think the short answer is "no".

however, you could modify the Go app to accept command line args that call the function. but without modifying the Go code, i don't think there's a way.

wass3r avatar Sep 12 '22 05:09 wass3r

@wass3r no , I mean, call the go code along with bot code, I have a operator object must initialized along with bot it self. which is injected into flatboat already.

I just wanna using yaml to config a func, and then execute this func (by name) inside same program , not a standalone executable file.

lucasjinreal avatar Sep 12 '22 06:09 lucasjinreal

so you kind of want to use this as a module in your own code? it's not really meant or written for that purpose.

wass3r avatar Sep 15 '22 00:09 wass3r

@wass3r Yes. May can done with some reflection way? Do u know any idea if I have this command?

lucasjinreal avatar Sep 15 '22 02:09 lucasjinreal