예제 #1
0
def Signature(orderid,reportid):
    api_url = HOST + "/api/Report/Signature"
    header = {'content-type': 'application/octet-stream',  # 头信息
              'Authorization': config.get_token(),
              'userinfo': USERINFO}

    from ProtobufPy.ReportRequestPb_pb2 import ReportRequestPb
    rr_body = ReportRequestPb()
    """对象入参赋值"""
    rr_body.orderID = orderid
    rr_body.reportID = reportid
    rr_body.abnormalFlag = '0'
    # rr_body.imagingFinding = '影像所见测试内容'
    rr_body.imagingFinding = FakerData.fake.paragraph()
    print(rr_body.imagingFinding)
    # rr_body.imagingDiagnosis = '影像诊断测试内容'
    rr_body.imagingDiagnosis = FakerData.fake.paragraph()
    rr_body.resultAssistantID = '42819E01-C077-4DB5-8B09-ACBC00A5343E'
    rr_body.resultAssistantName = '贾苗'
    rr_body.resultPrincipalID = '42819E01-C077-4DB5-8B09-ACBC00A5343E'
    rr_body.resultPrincipalName = '贾苗'
    rr_body.isCheckedWriteAndAudit = 1
    from ProtobufPy.OrderReportRequestPb_pb2 import OrderReportRequestPb
    orr_body = OrderReportRequestPb()
    orr_body.report.CopyFrom(rr_body)
    orr_body = orr_body.SerializeToString()  # 将对象转化成字符串
    print(orr_body)

    """模拟客户端发出请求"""
    with request(method='POST', url=api_url, data=orr_body, headers=header,timeout=5,
                             ) as ar_res:

        """解析返回结果"""
        res_str = ar_res.content  # 获取返回的正文
예제 #2
0
파일: yikyakapi.py 프로젝트: ashley/WHack5
def yaks(user, location):
    """Return raw response data for messages at location using user"""
    params = [("accuracy", user.location.accuracy), ("lat", location.latitude),
              ("long", location.longitude), ("token", get_token()),
              ("userID", user.user_id), ("userLat", user.location.latitude),
              ("userLong", user.location.longitude)]
    return _send("GET", settings.YIKYAK_ENDPOINT, "yaks", params)
예제 #3
0
파일: yikyakapi.py 프로젝트: ashley/WHack5
def get_message(user, message_id):
    """Return raw response data for a message (ID: message_id) using user"""
    params = [("accuracy", user.location.accuracy), ("messageID", message_id),
              ("token", get_token()), ("userID", user.user_id),
              ("userLat", user.location.latitude),
              ("userLong", user.location.longitude)]
    return _send("GET", settings.YIKYAK_ENDPOINT, "getMessage", params)
예제 #4
0
def place_order(env, location_id, lines_qty, stock_file, template_file):
    get_stock(env, stock_file)
    contracts_list = get_contracts_list(env=env, location_id=location_id)
    service_contract = next(contracts_list)[0:-1]

    order = generate_template(env=env,
                              location_id=location_id,
                              contract=service_contract,
                              template_file=template_file,
                              stock_file=stock_file,
                              lines_qty=lines_qty)

    endpoint = f"https://co-winter-{env}.tom.takeoff.com/order"
    send_order = requests.post(url=endpoint,
                               json=order,
                               headers={"X-Token": get_token(env)})
    if send_order.status_code != 200:
        response_content = send_order.content
        response_content_dict = ast.literal_eval(
            response_content.decode("utf-8"))
        if "details-from-3dparty-service" in response_content_dict:
            print(response_content_dict['details-from-3dparty-service']
                  ["message"])
        print(f"error sending order {send_order.status_code}")
    else:
        order_id = order["order-id"]
        print(f"{order_id} successfully placed!")
        print("waiting for split")
        time.sleep(1)
        print(f"trying to split {order_id}")
        split_order(env=env, order_id=order_id)
        return order_id

    return None
예제 #5
0
파일: yikyakapi.py 프로젝트: ashley/WHack5
def save_basecamp(user, name, location):
    """Return raw response data from saving a basecamp"""
    params = [("token", get_token()), ("userID", user.user_id)]
    data = [("bcLat", location.latitude), ("bcLong", location.longitude),
            ("bcName", name), ("bcPeekId", 0)]
    return _send("POST", settings.BASECAMP_ENDPOINT, "saveBasecamp", params,
                 data)
예제 #6
0
def request(options: dict, url):
    x = generateRandomID()
    config.set_uniqueid(x)
    get_url = API_URL + url
    headers = {
        'content-type': 'application/json',
        'X-AppVersion': config.get_app_version(),
        'X-UniqueId': config.unique_id,
        'X-Location': config.get_location(),
        'authorization': 'Bearer ' + config.get_token()
    }
    print(headers)
    headers.update(options.get('headers', {}))

    if options['method'] == 'GET':
        r = requests.get(get_url, headers=headers, params=options.get('params', ''))
    elif options['method'] == 'POST':
        r = requests.post(get_url, headers=headers, json=options['body'])
    elif options['method'] == 'DELETE':
        r = requests.delete(get_url, headers=headers)
    else:
        return {'success': False, 'message': 'Bad parameters, please try again'}, 401

    ret_dict = {'status_code' : r.status_code}
    ret_dict.update(r.json())

    return ret_dict
예제 #7
0
파일: yikyakapi.py 프로젝트: ashley/WHack5
def get_basecamps(user):
    """Return raw response data for all basecamps of user"""
    params = [("lat", user.location.latitude),
              ("long", user.location.longitude), ("token", get_token()),
              ("userID", user.user_id), ("userLat", user.location.latitude),
              ("userLong", user.location.longitude)]
    return _send("GET", settings.BASECAMP_ENDPOINT, "getBasecamps", params)
예제 #8
0
파일: yikyakapi.py 프로젝트: ashley/WHack5
def get_area_tops(user):
    """Return raw response data for top Yaks in area"""
    params = [("lat", user.location.latitude),
              ("long", user.location.longitude), ("token", get_token()),
              ("userID", user.user_id), ("userLat", user.location.latitude),
              ("userLong", user.location.longitude)]
    return _send("GET", settings.YIKYAK_ENDPOINT, "getAreaTops", params)
예제 #9
0
파일: yikyakapi.py 프로젝트: ashley/WHack5
def get_my_recent_replies(user):
    """Return raw response data for recent replies of user"""
    params = [("accuracy", user.location.accuracy),
              ("lat", user.location.latitude),
              ("long", user.location.longitude), ("token", get_token()),
              ("userID", user.user_id), ("userLat", user.location.latitude),
              ("userLong", user.location.longitude)]
    return _send("GET", settings.YIKYAK_ENDPOINT, "getMyRecentReplies", params)
예제 #10
0
파일: yikyakapi.py 프로젝트: ashley/WHack5
def downvote_message(user, message_id, basecamp=0):
    """Return raw response data from downvoting a message (ID: message_id)
    using user (optionally at basecamp)"""
    params = [("accuracy", user.location.accuracy), ("bc", int(basecamp)),
              ("messageID", message_id), ("token", get_token()),
              ("userID", user.user_id), ("userLat", user.location.latitude),
              ("userLong", user.location.longitude)]
    return _send("GET", settings.YIKYAK_ENDPOINT, "downvoteMessage", params)
예제 #11
0
파일: yikyakapi.py 프로젝트: ashley/WHack5
def like_comment(user, comment_id, basecamp=0):
    """Return raw response data from upvoting a comment (ID: comment_id) using
    user (optionally at basecamp)"""
    params = [("accuracy", user.location.accuracy), ("bc", int(basecamp)),
              ("commentID", comment_id), ("token", get_token()),
              ("userID", user.user_id), ("userLat", user.location.latitude),
              ("userLong", user.location.longitude)]
    return _send("GET", settings.YIKYAK_ENDPOINT, "likeComment", params)
예제 #12
0
파일: yikyakapi.py 프로젝트: katshew/WHack5
def get_area_tops(user):
    """Return raw response data for top Yaks in area"""
    params = [("lat", user.location.latitude),
              ("long", user.location.longitude),
              ("token", get_token()),
              ("userID", user.user_id),
              ("userLat", user.location.latitude),
              ("userLong", user.location.longitude)]
    return _send("GET", settings.YIKYAK_ENDPOINT, "getAreaTops", params)
예제 #13
0
파일: yikyakapi.py 프로젝트: katshew/WHack5
def get_message(user, message_id):
    """Return raw response data for a message (ID: message_id) using user"""
    params = [("accuracy", user.location.accuracy),
              ("messageID", message_id),
              ("token", get_token()),
              ("userID", user.user_id),
              ("userLat", user.location.latitude),
              ("userLong", user.location.longitude)]
    return _send("GET", settings.YIKYAK_ENDPOINT, "getMessage", params)
예제 #14
0
파일: yikyakapi.py 프로젝트: ashley/WHack5
def register_user(user):
    """Return raw response data from registering user"""
    params = [("accuracy", user.location.accuracy),
              ("deviceID", generate_id(dashes=False, upper=True)),
              ("lat", user.location.latitude),
              ("long", user.location.longitude), ("token", get_token()),
              ("userID", user.user_id), ("userLat", user.location.latitude),
              ("userLong", user.location.longitude)]
    return _send("GET", settings.YIKYAK_ENDPOINT, "registerUser", params)
예제 #15
0
파일: yikyakapi.py 프로젝트: katshew/WHack5
def get_basecamps(user):
    """Return raw response data for all basecamps of user"""
    params = [("lat", user.location.latitude),
              ("long", user.location.longitude),
              ("token", get_token()),
              ("userID", user.user_id),
              ("userLat", user.location.latitude),
              ("userLong", user.location.longitude)]
    return _send("GET", settings.BASECAMP_ENDPOINT, "getBasecamps", params)
예제 #16
0
파일: yikyakapi.py 프로젝트: katshew/WHack5
def contact_us(user, message, category, email):
    """Return raw response data from contacting Yik Yak with message in
    particular category using user with specified email"""
    params = [("token", get_token()),
              ("userID", user.user_id)]
    data = [("category", category),
            ("email", email),
            ("message", message)]
    return _send("POST", settings.YIKYAK_ENDPOINT, "contactUs", params, data)
예제 #17
0
파일: yikyakapi.py 프로젝트: ashley/WHack5
def log_event(user, event_type):
    """Return raw response data from logging an app event of type event_type
    using user"""
    params = [("accuracy", user.location.accuracy), ("token", get_token()),
              ("userID", user.user_id), ("userLat", user.location.latitude),
              ("userLong", user.location.longitude)]
    data = [("eventType", event_type), ("lat", user.location.latitude),
            ("long", user.location.longitude)]
    return _send("POST", settings.YIKYAK_ENDPOINT, "logEvent", params, data)
예제 #18
0
파일: yikyakapi.py 프로젝트: katshew/WHack5
def save_basecamp(user, name, location):
    """Return raw response data from saving a basecamp"""
    params = [("token", get_token()),
              ("userID", user.user_id)]
    data = [("bcLat", location.latitude),
            ("bcLong", location.longitude),
            ("bcName", name),
            ("bcPeekId", 0)]
    return _send("POST", settings.BASECAMP_ENDPOINT, "saveBasecamp", params,
                 data)
예제 #19
0
def split_order(env, order_id):
    url = f"https://co-winter-{env}.tom.takeoff.com/order/split/{order_id}"
    split = requests.put(url=url, headers={"X-Token": get_token(env)})
    if split.status_code != 200:
        response_content = split.content
        response_content_dict = ast.literal_eval(
            response_content.decode("utf-8"))
        print(f"split failed {split.status_code}")
    else:
        print("order split!")
예제 #20
0
파일: yikyakapi.py 프로젝트: ashley/WHack5
def get_peek_messages(user, peek_id):
    """Return raw response data for messages at peek location (ID: peek_id)
    using user"""
    params = [("accuracy", user.location.accuracy),
              ("lat", user.location.latitude),
              ("long", user.location.longitude), ("peekID", peek_id),
              ("token", get_token()), ("userID", user.user_id),
              ("userLat", user.location.latitude),
              ("userLong", user.location.longitude)]
    return _send("GET", settings.YIKYAK_ENDPOINT, "getPeekMessages", params)
예제 #21
0
파일: yikyakapi.py 프로젝트: katshew/WHack5
def get_my_recent_replies(user):
    """Return raw response data for recent replies of user"""
    params = [("accuracy", user.location.accuracy),
              ("lat", user.location.latitude),
              ("long", user.location.longitude),
              ("token", get_token()),
              ("userID", user.user_id),
              ("userLat", user.location.latitude),
              ("userLong", user.location.longitude)]
    return _send("GET", settings.YIKYAK_ENDPOINT, "getMyRecentReplies", params)
예제 #22
0
파일: yikyakapi.py 프로젝트: katshew/WHack5
def yaks(user, location):
    """Return raw response data for messages at location using user"""
    params = [("accuracy", user.location.accuracy),
              ("lat", location.latitude),
              ("long", location.longitude),
              ("token", get_token()),
              ("userID", user.user_id),
              ("userLat", user.location.latitude),
              ("userLong", user.location.longitude)]
    return _send("GET", settings.YIKYAK_ENDPOINT, "yaks", params)
예제 #23
0
파일: yikyakapi.py 프로젝트: katshew/WHack5
def register_user(user):
    """Return raw response data from registering user"""
    params = [("accuracy", user.location.accuracy),
              ("deviceID", generate_id(dashes=False, upper=True)),
              ("lat", user.location.latitude),
              ("long", user.location.longitude),
              ("token", get_token()),
              ("userID", user.user_id),
              ("userLat", user.location.latitude),
              ("userLong", user.location.longitude)]
    return _send("GET", settings.YIKYAK_ENDPOINT, "registerUser", params)
예제 #24
0
파일: yikyakapi.py 프로젝트: ashley/WHack5
def hot(user, location, basecamp=0):
    """Return raw response data for top messages in location/basecamp using
    user"""
    if basecamp:
        location = user.basecamp_location
    params = [("accuracy", user.location.accuracy), ("bc", int(basecamp)),
              ("lat", location.latitude), ("long", location.longitude),
              ("token", get_token()), ("userID", user.user_id),
              ("userLat", user.location.latitude),
              ("userLong", user.location.longitude)]
    return _send("GET", settings.YIKYAK_ENDPOINT, "hot", params)
예제 #25
0
파일: yikyakapi.py 프로젝트: katshew/WHack5
def downvote_message(user, message_id, basecamp=0):
    """Return raw response data from downvoting a message (ID: message_id)
    using user (optionally at basecamp)"""
    params = [("accuracy", user.location.accuracy),
              ("bc", int(basecamp)),
              ("messageID", message_id),
              ("token", get_token()),
              ("userID", user.user_id),
              ("userLat", user.location.latitude),
              ("userLong", user.location.longitude)]
    return _send("GET", settings.YIKYAK_ENDPOINT, "downvoteMessage", params)
예제 #26
0
파일: yikyakapi.py 프로젝트: katshew/WHack5
def like_comment(user, comment_id, basecamp=0):
    """Return raw response data from upvoting a comment (ID: comment_id) using
    user (optionally at basecamp)"""
    params = [("accuracy", user.location.accuracy),
              ("bc", int(basecamp)),
              ("commentID", comment_id),
              ("token", get_token()),
              ("userID", user.user_id),
              ("userLat", user.location.latitude),
              ("userLong", user.location.longitude)]
    return _send("GET", settings.YIKYAK_ENDPOINT, "likeComment", params)
예제 #27
0
def main():
    logging.basicConfig(format='[%(asctime)s][%(levelname)s]:%(message)s',
                        level=logging.WARNING,
                        datefmt='%d.%m.%Y %H:%M:%S')

    token = config.get_token()
    db_url = config.get_db_url()

    bot_db = dbconnect.BotDB(db_url)

    thesisbot = ThesisBot(token, bot_db)
    thesisbot.run()
예제 #28
0
파일: yikyakapi.py 프로젝트: katshew/WHack5
def log_event(user, event_type):
    """Return raw response data from logging an app event of type event_type
    using user"""
    params = [("accuracy", user.location.accuracy),
              ("token", get_token()),
              ("userID", user.user_id),
              ("userLat", user.location.latitude),
              ("userLong", user.location.longitude)]
    data = [("eventType", event_type),
            ("lat", user.location.latitude),
            ("long", user.location.longitude)]
    return _send("POST", settings.YIKYAK_ENDPOINT, "logEvent", params, data)
예제 #29
0
파일: yikyakapi.py 프로젝트: katshew/WHack5
def get_peek_messages(user, peek_id):
    """Return raw response data for messages at peek location (ID: peek_id)
    using user"""
    params = [("accuracy", user.location.accuracy),
              ("lat", user.location.latitude),
              ("long", user.location.longitude),
              ("peekID", peek_id),
              ("token", get_token()),
              ("userID", user.user_id),
              ("userLat", user.location.latitude),
              ("userLong", user.location.longitude)]
    return _send("GET", settings.YIKYAK_ENDPOINT, "getPeekMessages", params)
예제 #30
0
파일: yikyakapi.py 프로젝트: ashley/WHack5
def submit_peek_message(user, message, peek_id, handle=None, btp=0):
    """Return raw response data from submitting a peek message with an optional
    handle at peek location with ID peek_id using user (optionally with
    parameter bypassedThreatPopup as btp)"""
    params = [("token", get_token()), ("userID", user.user_id)]
    data = [("bypassedThreatPopup", int(btp)), ("lat", user.location.latitude),
            ("long", user.location.longitude), ("message", message),
            ("peekID", peek_id)]
    if handle:
        data += [("hndl", handle)]
    return _send("POST", settings.YIKYAK_ENDPOINT, "submitPeekMessage", params,
                 data)
예제 #31
0
def get_scs(env, location_id):
    with open("contracts_list.txt", "r+") as scs:
        scs.truncate(0)
    url = get_scs_url(env=env, location_id=location_id)
    data = (requests.get(url=url, headers={"X-Token": get_token(env)})).json()
    contracts = []
    for record in data:
        contracts.append(record["service-window-start"])
    for contract in contracts:
        dt = zulu.parse(contract)
        usable_contract = f"{(dt.isoformat())[0:-6]}" + "Z"
        with open("contracts_list.txt", "a+") as contracts_list_file:
            contracts_list_file.write(f"{usable_contract}\n")
예제 #32
0
파일: yikyakapi.py 프로젝트: ashley/WHack5
def get_comments(user, message_id, basecamp=0):
    """Return raw response data for all comments on a message (ID: message_id)
    using user (optionally at basecamp)"""
    if basecamp:
        location = user.basecamp_location
    else:
        location = user.location
    params = [("accuracy", user.location.accuracy), ("bc", int(basecamp)),
              ("lat", location.latitude), ("long", location.longitude),
              ("messageID", message_id), ("token", get_token()),
              ("userID", user.user_id), ("userLat", user.location.latitude),
              ("userLong", user.location.longitude)]
    return _send("GET", settings.YIKYAK_ENDPOINT, "getComments", params)
예제 #33
0
파일: yikyakapi.py 프로젝트: katshew/WHack5
def hot(user, location, basecamp=0):
    """Return raw response data for top messages in location/basecamp using
    user"""
    if basecamp:
        location = user.basecamp_location
    params = [("accuracy", user.location.accuracy),
              ("bc", int(basecamp)),
              ("lat", location.latitude),
              ("long", location.longitude),
              ("token", get_token()),
              ("userID", user.user_id),
              ("userLat", user.location.latitude),
              ("userLong", user.location.longitude)]
    return _send("GET", settings.YIKYAK_ENDPOINT, "hot", params)
예제 #34
0
파일: yikyakapi.py 프로젝트: ashley/WHack5
def report_message(user, message_id, reason, basecamp=0):
    """Return raw response data from reporting a message (ID: message_id) for a
    specified reason using user (optionally at basecamp)"""
    if basecamp:
        location = user.basecamp_location
    else:
        location = user.location
    params = [("accuracy", user.location.accuracy), ("bc", int(basecamp)),
              ("lat", location.latitude), ("long", location.longitude),
              ("messageID", message_id), ("reason", reason),
              ("token", get_token()), ("userID", user.user_id),
              ("userLat", user.location.latitude),
              ("userLong", user.location.longitude)]
    return _send("GET", settings.YIKYAK_ENDPOINT, "reportMessage", params)
예제 #35
0
파일: yikyakapi.py 프로젝트: katshew/WHack5
def submit_peek_message(user, message, peek_id, handle=None, btp=0):
    """Return raw response data from submitting a peek message with an optional
    handle at peek location with ID peek_id using user (optionally with
    parameter bypassedThreatPopup as btp)"""
    params = [("token", get_token()),
              ("userID", user.user_id)]
    data = [("bypassedThreatPopup", int(btp)),
            ("lat", user.location.latitude),
            ("long", user.location.longitude),
            ("message", message),
            ("peekID", peek_id)]
    if handle:
        data += [("hndl", handle)]
    return _send("POST", settings.YIKYAK_ENDPOINT, "submitPeekMessage",
                 params, data)
예제 #36
0
파일: yikyakapi.py 프로젝트: ashley/WHack5
def send_message(user, message, handle=None, btp=0, basecamp=0):
    """Return raw response data from sending a message with an optional handle
    using user (optionally at basecamp and optionally with parameter
    bypassedThreatPopup as btp)"""
    if basecamp:
        location = user.basecamp_location
    else:
        location = user.location
    params = [("bc", int(basecamp)), ("token", get_token()),
              ("userID", user.user_id)]
    data = [("bypassedThreatPopup", int(btp)), ("lat", location.latitude),
            ("long", location.longitude), ("message", message)]
    if handle:
        data += [("hndl", handle)]
    return _send("POST", settings.YIKYAK_ENDPOINT, "sendMessage", params, data)
예제 #37
0
파일: yikyakapi.py 프로젝트: ashley/WHack5
def delete_comment(user, comment_id, message_id, basecamp=0):
    """Return raw response data from deleting a comment (ID: comment_id)
    belonging to a message (ID: message_id) with user (optionally at
    basecamp)"""
    if basecamp:
        location = user.basecamp_location
    else:
        location = user.location
    params = [("accuracy", user.location.accuracy), ("bc", int(basecamp)),
              ("commentID", comment_id), ("lat", location.latitude),
              ("long", location.longitude), ("messageID", message_id),
              ("token", get_token()), ("userID", user.user_id),
              ("userLat", user.location.latitude),
              ("userLong", user.location.longitude)]
    return _send("GET", settings.YIKYAK_ENDPOINT, "deleteComment", params)
예제 #38
0
def send_req(nam, path, meth = 'GET', body = '', isCorrect = lambda c: c == 200):
	url = config.get_url(nam)
	cn = mk_conn(url)
	fullUrl = '%s/api/v3/%s' % (url, path)
	cn.request(meth, fullUrl, body, {
		'PRIVATE-TOKEN': config.get_token(nam),
		'Content-Type': 'application/json'
	})
	rsp = cn.getresponse()
	ret = rsp.read()
	assert isCorrect(rsp.status), '''Server has returned an error
URL: %s
Status: %d
Body: %s''' % (fullUrl, rsp.status, ret)
	return json.loads(ret)
예제 #39
0
def send_req(nam, path, meth='GET', body='', isCorrect=lambda c: c == 200):
    url = config.get_url(nam)
    cn = mk_conn(url)
    fullUrl = '%s/api/v3/%s' % (url, path)
    cn.request(meth, fullUrl, body, {
        'PRIVATE-TOKEN': config.get_token(nam),
        'Content-Type': 'application/json'
    })
    rsp = cn.getresponse()
    ret = rsp.read()
    assert isCorrect(rsp.status), '''Server has returned an error
URL: %s
Status: %d
Body: %s''' % (fullUrl, rsp.status, ret)
    return json.loads(ret)
예제 #40
0
파일: yikyakapi.py 프로젝트: ashley/WHack5
def post_comment(user, comment, message_id, btp=0, basecamp=0):
    """Return raw response data from posting a comment belonging to message
    (ID: message_id) using user (optionally at basecamp and optionally with
    parameter bypassedThreatPopup as btp)"""
    if basecamp:
        location = user.basecamp_location
    else:
        location = user.location
    params = [("accuracy", user.location.accuracy), ("bc", int(basecamp)),
              ("token", get_token()), ("userID", user.user_id),
              ("userLat", user.location.latitude),
              ("userLong", user.location.longitude)]
    data = [("bypassedThreatPopup", int(btp)), ("comment", comment),
            ("lat", location.latitude), ("long", location.longitude),
            ("messageID", message_id)]
    return _send("POST", settings.YIKYAK_ENDPOINT, "postComment", params, data)
예제 #41
0
파일: yikyakapi.py 프로젝트: katshew/WHack5
def get_comments(user, message_id, basecamp=0):
    """Return raw response data for all comments on a message (ID: message_id)
    using user (optionally at basecamp)"""
    if basecamp:
        location = user.basecamp_location
    else:
        location = user.location
    params = [("accuracy", user.location.accuracy),
              ("bc", int(basecamp)),
              ("lat", location.latitude),
              ("long", location.longitude),
              ("messageID", message_id),
              ("token", get_token()),
              ("userID", user.user_id),
              ("userLat", user.location.latitude),
              ("userLong", user.location.longitude)]
    return _send("GET", settings.YIKYAK_ENDPOINT, "getComments", params)
예제 #42
0
파일: yikyakapi.py 프로젝트: katshew/WHack5
def report_message(user, message_id, reason, basecamp=0):
    """Return raw response data from reporting a message (ID: message_id) for a
    specified reason using user (optionally at basecamp)"""
    if basecamp:
        location = user.basecamp_location
    else:
        location = user.location
    params = [("accuracy", user.location.accuracy),
              ("bc", int(basecamp)),
              ("lat", location.latitude),
              ("long", location.longitude),
              ("messageID", message_id),
              ("reason", reason),
              ("token", get_token()),
              ("userID", user.user_id),
              ("userLat", user.location.latitude),
              ("userLong", user.location.longitude)]
    return _send("GET", settings.YIKYAK_ENDPOINT, "reportMessage", params)
예제 #43
0
파일: yikyakapi.py 프로젝트: katshew/WHack5
def send_message(user, message, handle=None, btp=0, basecamp=0):
    """Return raw response data from sending a message with an optional handle
    using user (optionally at basecamp and optionally with parameter
    bypassedThreatPopup as btp)"""
    if basecamp:
        location = user.basecamp_location
    else:
        location = user.location
    params = [("bc", int(basecamp)),
              ("token", get_token()),
              ("userID", user.user_id)]
    data = [("bypassedThreatPopup", int(btp)),
            ("lat", location.latitude),
            ("long", location.longitude),
            ("message", message)]
    if handle:
        data += [("hndl", handle)]
    return _send("POST", settings.YIKYAK_ENDPOINT, "sendMessage", params, data)
예제 #44
0
def PageList():
    api_url = HOST + "/api/ReportList/PageList"  #RIS接口地址
    header = {'content-type': 'application/octet-stream',  # 头信息
              'Authorization': config.get_token(),
              'userinfo': USERINFO}
    #导入protobuf入参文件
    from ProtobufPy.ViOrderReportRequestPb_pb2 import ViOrderReportRequestPb
    ar_body = ViOrderReportRequestPb()
    """对象入参赋值"""
    ar_body.observationEndDate = '2021-05-08 00:00:00|2021-05-08 23:59:59'
    ar_body.resultStatus = '2090'
    ar_body.currentPage = 1
    ar_body.pageSize = 20
    ar_body = ar_body.SerializeToString()  # 将对象转化成字符串

    """模拟客户端发出请求"""
    with request(method='POST', url=api_url, data=ar_body, headers=header,timeout=5,
                             ) as ar_res:

        """解析返回结果"""
    # print(ar_res.content)
    # print(ar_res.status_code)
    from ProtobufPy.PageResponsePb_pb2 import PageResponsePb
    ar_data = PageResponsePb()  # 创建返回参数pb对象
    res_str = ar_res.content  # 获取返回的正文
    ar_data.ParseFromString(res_str)  # 从返回正文解析(第一层解析)
    # print(ar_data)
    # print("---------------------")
    from google.protobuf.json_format import MessageToJson  # 用于第二层解析特殊的类型
    from ProtobufPy.ReportListResponsePb_pb2 import ReportListResponsePb  # 导入返回参数中的相关pb
    ar_json = MessageToJson(ar_data)
    # print(ar_data)
    ar_dict = json.loads(ar_json.encode('utf-8').decode("unicode_escape"),
                         strict=False)  # 先处理unicode成中文,然后转化成字典
    # print(ar_dict)
    # 获取检查列表信息
    orderlist = ar_dict['data'][0]['orderReport']
    print(orderlist,type(orderlist))
    for a in orderlist:
        print(a,type(a))
        orderid = a['orderID']
        reportid = Loading(orderid)
        Signature(orderid,reportid)
        print('orderid为{0},reportid为{1}的检查签名成功'.format(orderid,reportid))
예제 #45
0
파일: yikyakapi.py 프로젝트: katshew/WHack5
def delete_comment(user, comment_id, message_id, basecamp=0):
    """Return raw response data from deleting a comment (ID: comment_id)
    belonging to a message (ID: message_id) with user (optionally at
    basecamp)"""
    if basecamp:
        location = user.basecamp_location
    else:
        location = user.location
    params = [("accuracy", user.location.accuracy),
              ("bc", int(basecamp)),
              ("commentID", comment_id),
              ("lat", location.latitude),
              ("long", location.longitude),
              ("messageID", message_id),
              ("token", get_token()),
              ("userID", user.user_id),
              ("userLat", user.location.latitude),
              ("userLong", user.location.longitude)]
    return _send("GET", settings.YIKYAK_ENDPOINT, "deleteComment", params)
예제 #46
0
파일: yikyakapi.py 프로젝트: katshew/WHack5
def post_comment(user, comment, message_id, btp=0, basecamp=0):
    """Return raw response data from posting a comment belonging to message
    (ID: message_id) using user (optionally at basecamp and optionally with
    parameter bypassedThreatPopup as btp)"""
    if basecamp:
        location = user.basecamp_location
    else:
        location = user.location
    params = [("accuracy", user.location.accuracy),
              ("bc", int(basecamp)),
              ("token", get_token()),
              ("userID", user.user_id),
              ("userLat", user.location.latitude),
              ("userLong", user.location.longitude)]
    data = [("bypassedThreatPopup", int(btp)),
            ("comment", comment),
            ("lat", location.latitude),
            ("long", location.longitude),
            ("messageID", message_id)]
    return _send("POST", settings.YIKYAK_ENDPOINT, "postComment", params, data)
예제 #47
0
def Loading(orderid):
    api_url = HOST + "/api/Report/Loading"
    header = {'content-type': 'application/octet-stream',  # 头信息
              'Authorization': config.get_token(),
              'userinfo': USERINFO}

    from ProtobufPy.ReportRequestPb_pb2 import ReportRequestPb
    rr_body = ReportRequestPb()
    """对象入参赋值"""
    rr_body.orderID = orderid
    from ProtobufPy.OrderReportRequestPb_pb2 import OrderReportRequestPb
    orr_body = OrderReportRequestPb()
    orr_body.report.CopyFrom(rr_body)
    orr_body = orr_body.SerializeToString()  # 将对象转化成字符串

    """模拟客户端发出请求"""
    with request(method='POST', url=api_url, data=orr_body, headers=header,timeout=5,
                             ) as ar_res:

        """解析返回结果"""
    from ProtobufPy.PageResponsePb_pb2 import PageResponsePb
    ar_data = PageResponsePb()  # 创建返回参数pb对象
    res_str = ar_res.content  # 获取返回的正文
    ar_data.ParseFromString(res_str)
    # print(ar_data)
    from google.protobuf.json_format import MessageToJson  # 用于第二层解析特殊的类型
    from ProtobufPy.ReportWriteListResponsePb_pb2 import ReportWriteListResponsePb
    ar_json = MessageToJson(ar_data)
    # print(ar_data)
    ar_dict = json.loads(ar_json.encode('utf-8').decode("unicode_escape"),
                         strict=False)  # 先处理unicode成中文,然后转化成字典
    # print(ar_dict)
    report = ar_dict['data'][0]['report']
    # print(report,type(report))
    # print(report['reportID'])
    return report['reportID']
예제 #48
0
import discord
import config
import traceback
import sys
from discord.ext import commands
from discord import Status

###########################
# Setup Bot Configuration #
###########################

# Create a config if it does not yet exist
config.initialize()

TOKEN = config.get_token()
COMMAND_PREFIX = config.get_command_prefix()

bot = commands.Bot(command_prefix=COMMAND_PREFIX)

# Define bot extensions
extensions = ['cogs.chat', 'cogs.timein', 'cogs.help']


# Update members in configuration
async def update_members():
    for user in bot.get_all_members():
        if not config.user_in_config(user) and user.id != bot.user.id:
            config.add_user(user)


###############
예제 #49
0
파일: __init__.py 프로젝트: kemadz/enpaste
 def __init__(self):
     self.tk = get_token()
     self.cl = EvernoteClient(token=self.tk, sandbox=True)
     self.ns = self.cl.get_note_store()
예제 #50
0
                        message.channel, "I have PM'd you the list of places")
                elif command == "commands" and config.check_command(command):
                    tmp = await client.send_message(message.author,
                                                    commands.list_commands())
                    tmp2 = await client.send_message(
                        message.channel,
                        "I have PM'd you the list of commands")
                else:
                    try:
                        args = message.content.split(' ', 1)[1]
                    except:
                        args = ""
                    if config.check_command(command):
                        tmp = await client.send_message(
                            message.channel,
                            commands.get_response(message, command, args))
                    else:
                        tmp = await client.send_message(
                            message.channel,
                            commands.get_unsupported_msg(command))


async def check_triggers(message):
    for response in triggers.get_response(message):
        tmp = await client.send_message(message.channel, response)
    return


print(config.get_token())
client.run(config.get_token())
예제 #51
0
    if profile.running():
        await ctx.channel.send(f'`{key}` is running')
    else:
        await ctx.channel.send(f'`{key}` has stopped')

@bot.command()
async def kill(ctx, key: str) -> None:
    if ctx.channel.id not in config.get_channels():
        await ctx.channel.send('Not authorised to run in this channel!')
        return

    profile = config.get_profile(key)

    if profile is None:
        await ctx.channel.send(f'Unknown profile `{key}`')
        return

    if not profile.running():
        await ctx.channel.send(f'Profile `{key}` is already not running')
        return

    profile.kill()
    await ctx.channel.send(f'Killed `{key}`!')

if not config.load_config():
    print('No config file found! New one created @ config.json. Please fill it out and run me again!')
    sys.exit(1)

bot.run(config.get_token())
예제 #52
0
파일: main.py 프로젝트: Shymain/widget-pi
async def on_socket_closed():
    client.run(config.get_token())
예제 #53
0
파일: main.py 프로젝트: Shymain/widget-pi
    if message.channel.id in wpi.pogo.filterChannels:
        await wpi.pogo.filter(message, client)
        if message == None:
            return
    if message.content.startswith('$') and \
            message.author.id != client.user.id:
        command = message.content[len("$"):].split()[0].lower()
        if command in wpi.core.functions:
            wpi.util.increment_command(message)
            await client.send_typing(message.channel)
            await wpi.core.functions[command](message, client)
        else:
            await client.send_message(message.channel, "That is not a valid command!")

@client.event
async def on_member_join(member):
    string = "Welcome to **" + member.server.name + "**, " + member.mention + "!\n" + "Please make sure to read <#221767295171559425>!"
    await client.send_message(member.server.default_channel, string)
    #if not member.server in wpi.util.commands:
        #wpi.util.add_server(member.server.id)
    #if wpi.util.commands[member.server.id]["welcome_enabled"]:
        #await client.send_message(member.server.default_channel, wpi.util.commands[member.server.id]["welcome_m

@client.event
async def on_socket_closed():
    client.run(config.get_token())

client.run(config.get_token())


예제 #54
0
def error_handler(bot, update, error):
    if is_authorized(update):
        err_msg = 'Update "{}" caused error "{}"'.format(update, error)
        send_message(bot, update, err_msg)

def help_cmd(bot, update):
    send_message(bot, update, get_help_text())

if __name__ == '__main__':

    logging.basicConfig(
        level=logging.DEBUG,
        format='%(asctime)s - %(name)s - %(levelname)s - %(message)s'
    )

    updater = telegram.Updater(token=config.get_token())
    bc.dispatcher = updater.dispatcher

    PLUGINS = [
        cancel,
        clear,
        emojis,
        gimme,
        insult,
        lights,
        quote,
        random_fact,
        shell_exec,
        sms,
        snap,
    ]