Create a custom robot using Python to send a message to a group of people

Source: Internet
Author: User

Create a robot

  1. Open the group where you want to create the robot, click the icon for the group robot

    650) this.width=650; "Src=" https://s2.51cto.com/wyfs02/M02/06/93/wKiom1m6Qiag-2SSAADfeBdEZsA899.png-wh_500x0-wm_ 3-wmp_4-s_2016073780.png "title=" 1.png "alt=" Wkiom1m6qiag-2ssaadfebdezsa899.png-wh_50 "/>

  2. Click the + Sign button to create the robot

    650) this.width=650; "Src=" https://s5.51cto.com/wyfs02/M00/A5/44/wKioL1m6QgiS37b6AAE8hHx-QuY355.png-wh_500x0-wm_ 3-wmp_4-s_3126552676.png "title=" 2.png "alt=" Wkiol1m6qgis37b6aae8hhx-quy355.png-wh_50 "/>

  3. Click Customize to create your own custom robot

    650) this.width=650; "Src=" https://s1.51cto.com/wyfs02/M02/06/93/wKiom1m6Qliw8_jsAAGlWXnX-o8521.png-wh_500x0-wm_ 3-wmp_4-s_677229735.png "title=" 3.png "alt=" Wkiom1m6qliw8_jsaaglwxnx-o8521.png-wh_50 "/>

  4. Click Add

    650) this.width=650; "Src=" https://s4.51cto.com/wyfs02/M02/06/93/wKiom1m6QmOSv4K1AAEO7qg-OQY497.png-wh_500x0-wm_ 3-wmp_4-s_2946430144.png "title=" 4.png "alt=" Wkiom1m6qmosv4k1aaeo7qg-oqy497.png-wh_50 "/>

  5. Set the robot avatar, robot name, Robot group, click Next

    650) this.width=650; "Src=" https://s5.51cto.com/wyfs02/M02/A5/44/wKioL1m6QkLD8TIKAADhK89zX6g281.png-wh_500x0-wm_ 3-wmp_4-s_2541975346.png "title=" 5.png "alt=" Wkiol1m6qkld8tikaadhk89zx6g281.png-wh_50 "/>

  6. Copy API (Webhook), click Done

    650) this.width=650; "Src=" https://s1.51cto.com/wyfs02/M01/A5/44/wKioL1m6QkzzyDKeAAEfycXlOw0743.png-wh_500x0-wm_ 3-wmp_4-s_573530806.png "title=" 6.png "alt=" Wkiol1m6qkzzydkeaaefycxlow0743.png-wh_50 "/>

Writing a Python script

Note: Modify the value of the Requrl within the script to the Webhook address of the robot

Script Usage Instructions:

How to use: Follow the script with the message to be sent

At all people change the value of Isatall to True

At the designated person in the Atmobiles list defined by the at person's phone, list form

The Requrl value is the robot's API, which automatically generates the API when the robot is created.

#!/usr/bin/python#coding=utf-8import urllibimport urllib2import jsonimport sysimport  reheaders = {' Content-type ':  ' Application/json '}test_data = {     ' Msgtype ': "Text",     "text":{         ' content ': '%s " % sys.argv[1]    },     " at ":{          "Atmobiles":[             133xxxx0502,            186xxxx6057         ],          "Isatall": false    }}requrl =  "https://oapi.dingtalk.com/robot/send?access_token= Xxxxxxxxxxxxxxxxxx "Req = urllib2. Request (Url = requrl,headers = headers,data = json.dumps (Test_data)) Response = urllib2.urlopen (req) 


This article is from the "Blue _ Storm" blog, make sure to keep this source http://270142877.blog.51cto.com/12869137/1965374

Create a custom robot using Python to send a message to a group of people

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.