在下面的代码中, 当在 slack 中执行your_method
时被调用your_command
from flask_slack import Slack
slack = Slack(app)
app.add_url_rule('/', view_func=slack.dispatch)
@slack.command('your_command', token='your_token',
team_id='your_team_id', methods=['POST'])
def your_method(**kwargs):
text = kwargs.get('text')
return text
如何your_method
从这个 python 程序中的另一个函数调用它。
例如。
def print:
a = your_method('hello','world')
这给了我错误=>
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1381, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1475, in full_dispatch_request
rv = self.dispatch_request()
return func(**kwargs)
File "sample.py", line 197
a = your_method('hello','world')
TypeError: your_method() takes exactly 0 arguments (1 given)