python类send()的实例源码

jubi_wechat.py 文件源码 项目:jubi_api 作者: Rockyzsu 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def send_wechat(self,name,content):
        w_content=name+' '+content
        itchat.send(w_content,toUserName=self.toName)
        time.sleep(1)
        itchat.send(w_content,toUserName='filehelper')
jubi_wechat.py 文件源码 项目:jubi_api 作者: Rockyzsu 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def warming(self, coin, up_price, down_price):
        url = 'https://www.jubi.com/api/v1/ticker/'
        while 1:
            time.sleep(5)
            try:
                data = requests.post(url, data={'coin': coin}).json()
            except Exception,e:
                print e
                print "time out. Retry"
                time.sleep(15)
                continue

            current = float(data['last'])
            if current >= up_price:
                print "Up to ", up_price
                print "current price ",current

                if self.send=='msn':
                    self.send_text(coin,str(current))
                if self.send=='wechat':
                    self.send_wechat(coin,str(current))

                time.sleep(1200)
            if current <= down_price:
                print "Down to ", down_price
                print "current price ",current
                if self.send=='msn':
                    self.send_text(coin,str(current))
                if self.send=='wechat':
                    self.send_wechat(coin,str(current))
                time.sleep(1200)
    #????????????
itchat_weather.py 文件源码 项目:hzlgithub 作者: hzlRises 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def  main():
    #????
    itchat.auto_login(hotReload=True)
    user_content = itchat.search_friends(name=u'????')
    userName = user_content[0]['UserName']
    itchat.send(getWeather(101230201),toUserName = userName)#??
    itchat.send(getWeather(101010100),toUserName = userName)#??
DoutuProcessor.py 文件源码 项目:WechatForwardBot 作者: grapeot 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def DoutuEnd(destinationChatroomId):
    sleep(DoutuProcessor.doutuTimeInterval)
    itchat.send('???? ?????', destinationChatroomId)
GroupMessageForwarder.py 文件源码 项目:WechatForwardBot 作者: grapeot 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def process(self, msg, type):
        if not self.isInitialized:
            logging.error('The forwarder was not properly initialized. Please send a message in the groups you want to connect and try again.')
            return
        shallSendObj = self.shallSend(msg)
        if not shallSendObj['shallSend']:
            return
        if type == TEXT:
            fromText = '[{0}]'.format(self.chatroomDisplayNames[shallSendObj['fromChatroom']])
            destinationChatroomId = self.chatroomIds[not shallSendObj['fromChatroom']]
            content = '{0} {1}: {2}'.format(fromText, msg['ActualNickName'], msg['Content'])
            logging.info(content)
            itchat.send(content, destinationChatroomId)
        elif type == PICTURE:
            fn = msg['FileName']
            newfn = os.path.join(self.fileFolder, fn)
            msg['Text'](fn)
            os.rename(fn, newfn)
            type = {'Picture': 'img', 'Video': 'vid'}.get(msg['Type'], 'fil')
            typeText = {'Picture': '??', 'Video': '??'}.get(msg['Type'], '??')
            fromText = '[{0}]'.format(self.chatroomDisplayNames[shallSendObj['fromChatroom']])
            destinationChatroomId = self.chatroomIds[not shallSendObj['fromChatroom']]
            content = '{0} {1} ???{2}:'.format(fromText, self.nickNameLookup.lookupNickName(msg), typeText)
            itchat.send(content, destinationChatroomId)
            logging.info(content)
            itchat.send('@{0}@{1}'.format(type, newfn), destinationChatroomId)
        elif type == SHARING:
            fromText = '[{0}]'.format(self.chatroomDisplayNames[shallSendObj['fromChatroom']])
            destinationChatroomId = self.chatroomIds[not shallSendObj['fromChatroom']]
            content = '{0} {1} ?????: {2} {3}'.format(fromText, self.nickNameLookup.lookupNickName(msg), msg['Text'], msg['Url'])
            logging.info(content)
            itchat.send(content, destinationChatroomId)
        else:
            logging.info('Unknown type encoutered.')
        pass
GaTextHook.py 文件源码 项目:WechatForwardBot 作者: grapeot 项目源码 文件源码 阅读 15 收藏 0 点赞 0 评论 0
def process(self, msg, type):
        if type != TEXT:
            return
        groupName = msg['User']['NickName']
        toSend = None
        if any([ re.search(x, groupName) is not None for x in self.blacklist ]):
            return
        if re.search(self.forceTriggerText, msg['Content']):
            currentTime = time()
            gaNextTime = self.forceTriggerNextTimestamp.get(groupName, 0)
            if currentTime < gaNextTime:
                logging.info("Don't force Ga because time {0} < NextTime {1} for group {2}.".format(currentTime, gaNextTime, groupName))
                return;
            self.forceTriggerNextTimestamp[groupName] = currentTime + self.forceTriggerInterval
            toSend = self.forceTriggerGaText
            logging.info('{0} => {1}'.format(msg['Content'], toSend))
            itchat.send(toSend, msg['FromUserName'])
            return
        if re.search(self.triggerText, msg['Content']):
            # Check the ga time
            if groupName not in GaTextHook.gaNumDict:
                GaTextHook.gaNumDict[groupName] = 0
            GaTextHook.gaNumDict[groupName] += 1
            self.gaColl.update({'GroupName': groupName}, {'$set': { 'CurrentGaNum': GaTextHook.gaNumDict[groupName] } }, upsert=True)
            if GaTextHook.gaNumDict[groupName] > self.gaNumMax:
                logging.info("Don't Ga because GaNum {0} exceeds max {1} for group {2}.".format(GaTextHook.gaNumDict[groupName], self.gaNumMax, groupName))
                return
            toSend = '{0} x{1}'.format(self.gaText, GaTextHook.gaNumDict[groupName])
            logging.info('{0} => {1}'.format(msg['Content'], toSend))
            itchat.send(toSend, msg['FromUserName'])
run.py 文件源码 项目:EasierLife 作者: littlecodersh 项目源码 文件源码 阅读 47 收藏 0 点赞 0 评论 0
def music_player(msg):
    if msg['ToUserName'] != 'filehelper': return
    if msg['Text'] == u'??':
        close_music()
        itchat.send(u'?????', 'filehelper')
    if msg['Text'] == u'??':
        itchat.send(HELP_MSG, 'filehelper')
    else:
        itchat.send(interact_select_song(msg['Text']), 'filehelper')
lifeline4linux.py 文件源码 项目:Python-Learner 作者: fire717 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def wait_active(seconds,msg):
    global user_step
    time.sleep(seconds)
    user_step[msg['FromUserName']] /= 1000  #???????

    back_re=random.randint(1,3)   #?????????
    if back_re == 1:
        backword=u'???'
    if back_re == 2:
        backword=u'????'
    if back_re == 3:
        backword=u'?'
    itchat.send(backword, toUserName=msg['FromUserName'])
    return
lifeline4linux.py 文件源码 项目:Python-Learner 作者: fire717 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def delay_reply(delay_time,words,msg):
    time.sleep(delay_time)
    itchat.send(words, toUserName=msg['FromUserName'])
    return 

######################?????########################
Untitled-1.py 文件源码 项目:turing-chat 作者: CosmoGao 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def chgr_reply(msg):
    #print(msg)
    chcont=msg['Content']
    if chcont.find('revokemsg')>0:
        loc1=max(chcont.find('/oldmsgid&gt;&lt;msgid&gt;')+26,chcont.find('</oldmsgid><msgid>')+18)
        loc2=max(chcont.find('&lt;/msgid&gt;&lt;replacemsg&gt;&lt;![CDATA'),chcont.find('</msgid><replacemsg><![CDATA'))
        messageid=chcont[loc1:loc2]
        print(messageid)
        chtext=msg['Text']
        print(chtext)
        chlen=len(chtext)
        aname=chtext[:chlen-7]
        try:
            oritun=IDandTUN[str(messageid)]
            orifun=IDandFUN[str(messageid)]
        except:
            print('dont chehui twice')
        if (oritun==myusrname or orifun==myusrname)and (chtext.find('You')>0 or chtext.find('?')>0) or chtext=="You've recalled a message.":
            aname='myself'
        else:
            aname=aname + '[not me]'
        try:
            itchat.send("[Autoreply] The message revoked by '"+aname+"' just now is :"+IDandMESSAGE[str(messageid)],oritun)
            itchat.send("[Autoreply] The message revoked by '"+aname+"' just now is :"+IDandMESSAGE[str(messageid)],orifun)
        except:
            print("-----Can't find original msg")
wx_personal.py 文件源码 项目:Python-Projects 作者: PP8818 项目源码 文件源码 阅读 15 收藏 0 点赞 0 评论 0
def tick():
    users = itchat.search_friends(name=u'xxx') # ?????????
    userName = users[0]['UserName']
    meetDate = dt.date(2015,9,29)  # ?????????????
    now = dt.datetime.now()     # ?????
    nowDate = dt.date.today()  # ?????
    passDates = (nowDate-meetDate).days # ???????????
    itchat.send(u'????????%d??%s,??'%(passDates,random.sample(greetList,1)[0]),toUserName=userName) # ?????????
    nextTickTime = now + dt.timedelta(days=1)
    nextTickTime = nextTickTime.strftime("%Y-%m-%d 00:00:00")
    my_scheduler(nextTickTime)
run.py 文件源码 项目:wbot 作者: ciknight 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def text_reply(msg):
    nickName = itchat.search_friends(userName=msg['FromUserName']).get('NickName', 'Unknown')
    logging.info('{}-{} send: {}'.format(nickName, msg['FromUserName'], msg['Content']))
    if msg["FromUserName"] == itchat.get_friends()[0]["UserName"]:
        # dont replay self
        return

    # if invite
    if faq.invite_key in msg['Text'].upper():
        # TODO Modify add_member_into_chatroom
        invite_friend = [{'UserName': msg['FromUserName']}]
        grouproom = itchat.search_chatrooms(name=faq.group_name)
        grouproom = grouproom and grouproom[0] or None
        result = itchat.add_member_into_chatroom(grouproom.get('UserName'),
                invite_friend, useInvitation=True)

        # invite success
        if result['BaseResponse']['Ret'] == 0:
            logging.info('invite user {}-{} successful'.format(nickName, msg['FromUserName']))
        else:
            logging.error('invite user {}-{} failed'.format(nickName, msg['FromUserName']))
            itchat.send(REPLAY_ERROR_TEXT, msg['FromUserName'])
    else:
        # else TuLing replay
        replay_text = tuling.replay_text(msg['Text'],
                msg['FromUserName']) or REPLAY_ERROR_TEXT
        logging.info('tuling replay user {}-{}: {}'.format(nickName, msg['FromUserName'], replay_text))
        itchat.send(replay_text, msg['FromUserName'])

    # TODO can not return Bool
    return
run.py 文件源码 项目:wbot 作者: ciknight 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def groupchat_reply(msg):
    groupNmae = itchat.search_chatrooms(userName=msg['FromUserName']).get('NickName')
    logging.info('group {}-{}: {}-{}: send {}'.format(
        groupNmae, msg['FromUserName'], msg['ActualNickName'], msg['ActualUserName'], msg['Content']))

    if msg['Text'][0] == interpreter.PY_SYMBLOE:
        replay_text = interpreter.run_py_cmd(msg['Text'][1:])
    elif msg['isAt']:
        replay_text = tuling.replay_text(msg['Text'], msg['ActualNickName']) or REPLAY_ERROR_TEXT
    else:
        replay_text = ''

    if replay_text:
        itchat.send(replay_text, msg['FromUserName'])


问题


面经


文章

微信
公众号

扫码关注公众号