Ejemplo n.º 1
0
    def __init__(self, name="0000000", count=0, makeRooms=[]):
        self.robot = Robot()
        self.http = Http()
        self.name = name
        self.count = count  #编号

        self.listMsgQue = []  #消息发送队列
        self.timeDetaMsgSend = 1.1  #最小发送消息间隔s

        self.makeRooms = makeRooms
        self.roomIndex = {}  #房间号 及其<用户>信息
        self.roomMsg = {}  #消息 记录
        self.roomId = ""  #当前房号

        ############### 心情模块
        self.statusMin = 20
        self.statusMax = 95
        self.statusDefault = 80
        self.status = 90  #说话欲望值 0-100
        self.statusOnDeta = 15  #开心
        self.statusOffDeta = 15  #难过
        self.statusDownDeta = 40  #闭嘴

        self.getMsgDetaTime = 1  #抓取消息间隔
        self.lastMsgTime = int(
            time.time() * 10000) * 1.0 / 10000  #上一次更新房间聊天记录时间
        self.lastEchoTime = tool.getNowTime()  #上次说话时间
        self.maxDetaTime = 1000 * 60 * 3  # 最大沉默时间
        self.lastMusicTime = tool.getNowTime()
        self.maxMusicTime = 1000 * 60 * 4  #音乐间隔 暂不解析音乐文件时长控制
        self.musicNow = {}
        self.musicPlayType = -1
        self.ifOnMusic = True
        self.tail = " の... "
Ejemplo n.º 2
0
    def __init__(self, name="Test", id="18408249138", pwd="1234qwer"):
        reload(sys)
        sys.setdefaultencoding('utf8') #针对socket发送中文异常
        self.detaTime = 3600 * 1000 #推送延时 60min
        self.detaTimeMin = 1200 * 1000 #推送延时 20min

        self.id = id
        self.pwd = pwd
        self.name = name
        self.robot = Robot()
        self.http = Http()
        self.db = Database('sqlite_' + self.id + '.db')
        self.socket = Socket()
        self.onConnect = False
        self.ifOk = False
        # sendTime添加时间, type消息类型, msg发送消息体, deta间隔发送时间, preTime预期发送时间节点
        self.db.execute(
            ''' 
            create table if not exists cochat(
                id  text,
                sendTime    text,
                sendTimeT text,
                deta    text,
                preTime text,
                preTimeT text,
                type        text,
                msg    text,
                flag    text
            )
            ''' )
        self.sendList = [] #发送队列 (time, deta, type, data)
        return
Ejemplo n.º 3
0
def get_event_content(event_id):
    #os.system('''export http_proxy=""''')
    print '获取id为[%d]的活动内容' % event_id

    http = Http('plogin.12580.com', 80)
    #para = {'act':'xml','id':event_id}
    #req_para = http.getparams(para)
    url = '%s%d' % ('/cmps/wapcms/wap/web_online_xml.php?id=', event_id)
    ret = http.request(url)

    #解析返回的xml报文
    #om = parseString(ret)
    #field_node = dom.documentElement
    #content_node = field_node.getElementsByTagName('content')[0]

    #data = None
    #if content_node.nodeType in (content_node.TEXT_NODE,content_node.CDATA_SECTION_NODE):
    #	data = content_node.data
    #else:
    #	print content_node.nodeType
    print 'cms返回报文: %s ' % ret

    root = ET.fromstring(ret)
    msg = {}
    for node in root:
        msg[node.tag] = node.text

    data = msg['content']
    print 'cms返回的活动内容为:%s' % (data or 'cms返回空')

    #os.system('''export http_proxy="http://127.0.0.1:8087/"''')
    return data
Ejemplo n.º 4
0
 def doProcess(self, index, showInfo):
     try:
         mobile = Mobile()
         items = mobile.assemble(
             self._config.choiceDev(),
             int(self._config.getGlobal('count'))).__dict__
         items.update(self._config.choiceAct())
         data = package('password', json.dumps(items))
         http = Http(self._config.getGlobal('host'),
                     self._config.getGlobal('port'))
         data = http.request(data)
         size = hex2int(data[36:44])
         body = data[44:45 + size]
         ret = None
         if showInfo:
             print 'start %s' % ("=" * 20)
             if ftype.isZIP(body):
                 ret = "BINARY"
                 print 'recv zip format data.'
             else:
                 ret = "TEXT"
                 print '%s' % ungzip(body)
             print 'End %s %s' % (index, "=" * 20)
         else:
             ret = body
     except:
         ret = None
     return ret
Ejemplo n.º 5
0
 def __init__(self, url, account=None, passwd=None, encoding='utf-8'):
     self.url = url.rstrip("/")
     self.account = account
     self.passwd = passwd
     self.encoding = encoding
     self.token = None
     self.uttpUtil = Http()
Ejemplo n.º 6
0
 def __init__(self, name="0000000"):
     self.http = Http()
     self.name = name
     # https://console.bce.baidu.com/ai/?_=1533038198056&fromai=1#/ai/speech/app/detail~appId=464300
     self.appId = "11615410"
     self.appKey = "zzTM1VXx7Edmj4QXqCcnhZfF"
     self.appSecret = "jekAAbrElm87rpMM7jVBFFuKrm8ZWbwy"
     self.loginRes = {}
     self.access_token = ""
Ejemplo n.º 7
0
 def run(self):
     self._debug('started')
     inmates = Inmates(Inmate, self._monitor)
     inmates_scraper = InmatesScraper(Http(), inmates, InmateDetails, self._monitor)
     search_commands = SearchCommands(inmates_scraper, self._monitor)
     controller = Controller(self._monitor, search_commands, inmates_scraper, inmates)
     controller.run()
     self._debug('waiting for processing to finish')
     controller.wait_for_finish()
     self._debug('finished')
Ejemplo n.º 8
0
 def check_for_missing_inmates(self, start_date):
     self._debug('started check_for_missing_inmates')
     inmates = Inmates(Inmate, self._monitor)
     inmates_scraper = InmatesScraper(Http(), inmates, InmateDetails, self._monitor, workers_to_start=70)
     search_commands = SearchCommands(inmates_scraper, self._monitor)
     controller = Controller(self._monitor, search_commands, inmates_scraper, inmates)
     controller.find_missing_inmates(start_date)
     self._debug('waiting for check_for_missing_inmates processing to finish')
     controller.wait_for_finish()
     self._debug('finished check_for_missing_inmates')
Ejemplo n.º 9
0
    def __init__(self, name="Test"):
        self.name = name

        self.http = Http()
        self.db = Database()
        self.db.execute(''' 
            create table if not exists music(
                url         text primary key,
                name        text,
                fromName    text,
                count       text
            )
            ''')

        return
Ejemplo n.º 10
0
    def __init__(self, name="Test"):
        self.name = name

        self.http = Http()
        self.db = Database()
        self.db.execute(''' 
            create table if not exists auto(
                url         text,
                about        text,
                time        text,
                v1       text,
                v2       text,
                v3       text,
                v4       text,
                v5       text
            )
            ''')

        return
Ejemplo n.º 11
0
    def __init__(self, name="0000000",flowName="", count = 0, makeRooms=[]):
        self.robot = Robot()
        self.http = Http()
        self.name = name
        self.flowName = flowName
        self.count = count   #编号

        self.listMsgQue = []    #消息发送队列
        self.timeDetaMsgSend = 1.5    #最小发送消息间隔s
        self.makeRooms = makeRooms
        self.userIndex = {} # 用户name -> 用户id
        self.userIndexRe = {} #id -> name
        self.roomIndex = {} #房间号 及其<用户>信息
        self.roomMsg = {}   #消息 记录
        self.roomId = ""  #当前房号
        self.ifWelcom = False #是否迎客
        self.ifTime = False #是否存货确认
        self.admins = {}
        self.tripcodeIndex = {} #上次房间记录 的 用户名 绑定的 tc code
        self.linkStart = 0 #链接状态

        self.init()
        self.tail = " の... "
Ejemplo n.º 12
0
    def __init__(self):
        self.id = "test id"
        self.name = "test name"
        self.http = Http()
        self.auto163 = Auto163("Music")
        self.apiKey = "bfbf6432b655493b9e861b470bca9921"
        self.userId = "WalkerDust"

        self.db = Database()
        self.db.execute(''' 
        create table if not exists music(
            url         text primary key,
            name        text,
            duration    text,
            fromName    text,
            count       text
        )
        ''')
        self.db.execute(''' 
            create table if not exists user(
                name        text primary key,
                id          text,
                icon        text,
                flag        text
            )
            ''')
        self.db.execute(''' 
            create table if not exists msg(
                id            text primary key, 
                userName      text,
                data          text,
                time          text
            )
            ''')
        self.initMusic()
        self.palyHistoryMusic = []
        return
Ejemplo n.º 13
0
 def __init__(self,option={}):
     self.__http=Http(option)
     self.__tools=Tools()
Ejemplo n.º 14
0
 def __init__(self, name="0000000"):
     self.http = Http()
     self.name = name
Ejemplo n.º 15
0
 def __init__(self, maxDepth, startUrl):
     self.maxDepth = maxDepth
     self.linkDict = {}
     self.startUrl = [startUrl]
     self.http = Http()
     self.freqDict = {}