# coding:utf-8
from ctypes import *
import requests
import json
import random
import binascii
from config import config
class Dama2():
"""Coding rabbit code.""""
_username = ''
_password = ''
__attrs__ = ['DM', 'username', 'password', 'softuuid', 'timeout']
def __init__(self):
= WinDLL('lib/')
if not self._username:
Dama2._username = config['dama']['dama2']['username']
Dama2._password = config['dama']['dama2']['password']
= c_char_p(self._username)
= c_char_p(self._password)
= c_char_p('6fbc06efdc777eee854842572102daec')
= c_ushort(30)
def recv_byte(self, imgdata, imgtype=42):
# imgdata = c_void_p(imgdata)
imgleng = c_uint(len(imgdata))
imgtype = c_ulong(imgtype)
res = c_char_p('')
code = .D2Buf(, , , imgdata, imgleng, , imgtype, res)
if code > 0:
return
return False
def report_err(self, imgid):
return False
class Chaoren():
_username = ''
_password = ''
__attrs__ = ['DM', 'username', 'password', 'softuuid', 'timeout']
def __init__(self):
if not self._username:
Chaoren._username = config['dama']['chaoren']['username']
Chaoren._password = config['dama']['chaoren']['password']
= ()
= 'utf-8'
= 16
= {
'username': ,
'password': ,
'softid': '1234',#1234 is replaced by your own
'imgid': '',
'imgdata': ''
}
def get_left_point(self):
try:
r = ('http://apib.:88/', )
return ()
except :
return self.get_left_point()
except:
return False
def recv_byte(self, imgdata):
['imgdata'] = binascii.b2a_hex(imgdata).upper()
try:
r = ('http://apib.:88/', )
res = ()
if res[u'info'] == -1:
self.report_err(res[u'imgid']) # Identification error
return False
return ()[u'result']
except :
return self.recv_byte(imgdata)
except:
return False
def report_err(self, imgid):
['imgid'] = imgid
if ['imgdata']:
del ['imgdata']
try:
r = ('http://apib.:88/', )
return ()
except :
return self.report_err(imgid)
except:
return False
class Dama():
flag = 'dama2'
def __init__(self):
if == 'dama2':
= Dama2()
elif == 'chaoren':
= Chaoren()
else:
= Dama2() # Default
def recv_byte(self, imgdata):
return .recv_byte(imgdata)
def report_err(self, imgid):
return .report_err(imgid)
# test
if __name__ == '__main__':
pass
"""
username and password replace with your own
"""