Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3.x 将输入传递到python3中的Curl命令_Python 3.x_Curl_Errbot - Fatal编程技术网

Python 3.x 将输入传递到python3中的Curl命令

Python 3.x 将输入传递到python3中的Curl命令,python-3.x,curl,errbot,Python 3.x,Curl,Errbot,我目前正在使用errbot,但在允许用户输入消息以随curl命令一起传递时遇到了问题。我的插件如下所示: @arg_botcmd('team_key', type=str) @arg_botcmd('--message' , dest='message', type=str) def oncall_page(self, msg, team_key=None, message=None): if team_key in page_list.keys(): team_id = page

我目前正在使用errbot,但在允许用户输入消息以随curl命令一起传递时遇到了问题。我的插件如下所示:

@arg_botcmd('team_key', type=str)
@arg_botcmd('--message' , dest='message', type=str)
def oncall_page(self, msg, team_key=None, message=None):
  if team_key in page_list.keys():
     team_id = page_list[team_key]
     data = {"message_type":"CRITICAL","state_message":"{0}".format(message)}                                     
     response = requests.post('https://www.apiurl.com/{0}'.format( team_id), data)
     yield "Paging {0} ".format( team_id )
我的问题是这一行:

data = {"message_type":"CRITICAL","state_message":"{0}".format(message)}
这似乎完全破坏了命令,我希望用户可以执行一个命令,比如“!oncall page team_name--message”

任何帮助都将不胜感激:)

这是解决这个问题的办法

@arg_botcmd('team_key', type=str)
@arg_botcmd('--message' , dest='message', type=str)
def oncall_page(self, msg, team_key=None, message=None):
  if team_key in page_list.keys():
     team_id = page_list[team_key]
     text = str(message)
     msg_type = "critical"
     data = '{"message_type":"%s", "state_message":"%s"}' % (msg_type, text)
    # data = '{"message_type":"critical", "state_message":"%s"}'(text)
     URL = 'https://www.apiurl.com/{0}'.format( team_id)
     response = requests.post(URL , data)