Exemple #1
0
def cb_msg(md, type, tid, params, sbd):
    t = string.split(tid)
    email = t[0]

    # messages from hotmail are only when we connect, and send things
    # regarding, aparently, hotmail issues. we ignore them (basically
    # because i couldn't care less; however if somebody has intrest in
    # these and provides some debug output i'll be happy to implement
    # parsing).
    if email == 'Hotmail':
        return

    # parse
    lines = string.split(params, '\n')
    headers = {}
    eoh = 1
    for i in lines:
        # end of headers
        if i == '\r':
            break
        tv = string.split(i, ':')
        type = tv[0]
        value = string.join(tv[1:], ':')
        value = string.strip(value)
        headers[type] = value

        #    print 'type = %s' % type
        eoh += 1


#  if headers.has_key('Content-Type') and headers['Content-Type'] == 'text/x-msmsgscontrol':
# the typing notices
#    print 'TYPING %s\n' % email
#  else:
# messages
#    print 'MSG %d %d %s\n%s\n' % \
#      (len(lines), eoh, email, string.join(lines, '\n'))

    if lines[4] == 'build' or lines[4] == '빌드' or lines[4] == '빌드해':
        m.change_status("busy")

        buf = '알았어 오빠~~'
        m.sendmsg(email, buf)

        p = subprocess.Popen(
            [r"E:/ForAutoCommit/Develop/!buildall_and_commit.bat"],
            shell=True,
            cwd="E:/ForAutoCommit/Develop",
            stdout=subprocess.PIPE)
        output = p.stdout.read()
        print output
        p.wait()

        buf = '끝났어 오빠..~'
        m.sendmsg(email, buf)

        m.change_status("away")

    msncb.cb_msg(md, type, tid, params, sbd)
Exemple #2
0
def cb_msg(md, type, tid, params, sbd):
	"Gets a message"
	t = tid.split(' ')
	email = t[0]

	# parse
	lines = params.split('\n')
	headers = {} 
	eoh = 0
	for i in lines:
		# end of headers
		if i == '\r':
			break
		tv = i.split(':', 1)
		type = tv[0]
		value = tv[1].strip()
		headers[type] = value
		eoh += 1
	eoh +=1

	# ignore hotmail messages
	if email == 'Hotmail':
		return
	
	if email not in emwin.keys():
		emwin[email] = chatwindow(root, email)
		
	# typing notifications
	if (headers.has_key('Content-Type') and 
			headers['Content-Type'] == 'text/x-msmsgscontrol'):
		if not m.users[email].priv.has_key('typing'):
			m.users[email].priv['typing'] = 1
			msg = now() + ' --- is typing\n'
			emwin[email].append(msg, 'typing')
			
	# normal message
	else:
		if len(lines[eoh:]) > 1:
			msg = now() + ' <<<\n\t'
			msg += string.join(lines[eoh:], '\n\t')
			msg = msg.replace('\r', '')
		else:
			msg = now() + ' <<< ' + lines[eoh] + '\n'
			
		if m.users[email].priv.has_key('typing'):
			del(m.users[email].priv['typing'])
			
		emwin[email].append(msg, 'from')
		root.bell()

	msncb.cb_msg(md, type, tid, params, sbd)
Exemple #3
0
def cb_msg(md, type, tid, params, sbd):
	"Gets a message"
	t = tid.split(' ')
	email = t[0]
        print "################################"
        print email
	# parse
	lines = params.split('\n')
	headers = {} 
	eoh = 0
	for i in lines:
		# end of headers
		if i == '\r':
			break
		tv = i.split(':', 1)
		type = tv[0]
		value = tv[1].strip()
		headers[type] = value
		eoh += 1
	eoh +=1

	# ignore hotmail messages
	if email == 'Hotmail':
		return
	#print headers
	
	# typing notifications
	if (headers.has_key('Content-Type') and 
			headers['Content-Type'] == 'text/x-msmsgscontrol'):
                pass			
	# normal message
	else:
		if len(lines[eoh:]) > 1:
			
			msg += string.join(lines[eoh:], '')
			msg = msg.replace('\r', '')
			print "mesaj"
			callreq(email,msg)
		else:
                        print "mesaj"
                        callreq(email,lines[eoh])
		

	msncb.cb_msg(md, type, tid, params, sbd)
Exemple #4
0
def msnbot_cb_msg(md, type, tid, params, sbd):
	t = tid.split()
	email = t[0]
	
	if email == 'Hotmail':
		return
	
	lines = params.split('\n')
	headers = {}
	eoh = 1
	for i in lines:
		if i == '\r':
			break
		t, v = i.split(':', 1)
		headers[t] = v
		eoh += 1
	if headers.get('Content-Type', '') == 'text/x-msmsgscontrol':
		# typing ignore
		return
	
	md._botobj._handle_msg(email, headers, lines[eoh:])
	msncb.cb_msg(md, type, tid, params, sbd)
Exemple #5
0
def cb_msg(md, type, tid, params, sbd):
	t = string.split(tid)
	email = t[0]
	
	# messages from hotmail are only when we connect, and send things
	# regarding, aparently, hotmail issues. we ignore them (basically
	# because i couldn't care less; however if somebody has intrest in
	# these and provides some debug output i'll be happy to implement
	# parsing).
	if email == 'Hotmail':
		return

	# parse
	lines = string.split(params, '\n')
	headers = {}
	eoh = 1
	for i in lines:
		# end of headers
		if i == '\r':
			break
		tv = string.split(i, ':')
		type = tv[0]
		value = string.join(tv[1:], ':')
		value = string.strip(value)
		headers[type] = value
		eoh += 1
	
	if headers.has_key('Content-Type') and headers['Content-Type'] == 'text/x-msmsgscontrol':
		# the typing notices
		equeue.append('TYPING %s\n' % email)
	else:
		# messages
		equeue.append('MSG %d %d %s\n%s\n' % \
			(len(lines), eoh, email, string.join(lines, '\n')) )
	
	msncb.cb_msg(md, type, tid, params, sbd)
Exemple #6
0
 def test_24_cb_msg_WithArgs_Pass_With_Only_Valid_Arguments(self):
     msncb.cb_msg(5, 'TestStr', 'TestStr', 'TestStr', 'TestStr')
def cb_msg(md, type, tid, params, sbd):
    global last_received
    t = tid.split(' ')
    email = t[0]

    # parse
    lines = params.split('\n')
    headers = {}
    eoh = 0
    for i in lines:
        # end of headers
        if i == '\r':
            break
        tv = i.split(':', 1)
        type = tv[0]
        value = tv[1].strip()
        headers[type] = value
        eoh += 1
    eoh += 1

    # handle special hotmail messages
    if email == 'Hotmail':
        if not headers.has_key('Content-Type'):
            return
        hotmail_info = {}

        # parse the body
        for i in lines:
            i = i.strip()
            if not i:
                continue
            tv = i.split(':', 1)
            type = tv[0]
            value = tv[1].strip()
            hotmail_info[type] = value

        #msnlib.debug(params)
        if headers[
                'Content-Type'] == 'text/x-msmsgsinitialemailnotification; charset=UTF-8':
            newmsgs = int(hotmail_info['Inbox-Unread'])
            if not newmsgs:
                return
            print('\rYou have %s unread email(s)' % str(newmsgs) \
                + ' in your Hotmail account\n')
        elif headers[
                'Content-Type'] == 'text/x-msmsgsemailnotification; charset=UTF-8':
            from_name = hotmail_info['From']
            from_addr = hotmail_info['From-Addr']
            subject = hotmail_info['Subject']
            print('\rYou have just received an email in your' + \
                ' Hotmail account:\n')
            print('\r\tFrom: %s (%s)\n' % (from_name, from_addr))
            print('\r\tSubject: %s\n' % subject)
        return

    if headers.has_key('Content-Type'
                       ) and headers['Content-Type'] == 'text/x-msmsgscontrol':
        # the typing notices
        nick = email2nick(md, email)
        if not nick: nick = email
        if not md.users[email].priv.has_key('typing'):
            md.users[email].priv['typing'] = 0
        if not md.users[email].priv['typing'] and email not in md.glob_ignored:
            print('\r')
            ctime = time.strftime('%I:%M:%S%p', now())
            print('%s ' % ctime)
            print('%s' % nick)
            print(' is typing\n')
        md.users[email].priv['typing'] = time.time()
    elif headers.has_key(
            'Content-Type') and headers['Content-Type'] == 'text/x-clientcaps':
        # ignore the x-clientcaps messages generated from gaim
        pass
    elif headers.has_key(
            'Content-Type') and headers['Content-Type'] == 'text/x-keepalive':
        # ignore kopete's keepalive messages
        pass
    else:
        # messages
        md.users[email].priv['typing'] = 0
        print('\r')
        print_inc_msg(md, email, lines, eoh)

        if len(sbd.emails) > 1:
            log_msg(md, email, 'in', string.join(lines[eoh:], '\n'), \
                users = sbd.emails)
        else:
            log_msg(md, email, 'in', string.join(lines[eoh:], '\n'))

        # append the message to the history, keeping it below the configured limit
        if len(md.glob_history_ring) > md.glob_config['history size']:
            del (md.glob_history_ring[0])
        md.glob_history_ring.append((time.time(), email, lines[eoh:]))

        chatline = lines[eoh:][0].strip()

        # print received msg
        tim = strftime("%a, %d %b %Y %H:%M:%S", gmtime())
        print '(MSNBot) %s <<< %s: %s' % (tim, email, chatline)
        # restart initial_time
        md.initial_time = time.time()
        ans, quit = custom_chat_response(md, chatline)
        md.glob_quit = quit
        if ans:
            tim = strftime("%a, %d %b %Y %H:%M:%S", gmtime())
            print '(MSNBot) %s >>> %s: %s' % (tim, email, ans)
            md.sendmsg(email, ans)

    last_received = email
    msncb.cb_msg(md, type, tid, params, sbd)
	def test_24_cb_msg_WithArgs_Pass_With_Only_Valid_Arguments(self):
		msncb.cb_msg(5,'TestStr','TestStr','TestStr','TestStr')
Exemple #9
0
def cb_msg(md, type, tid, params, sbd):
    t = tid.split(' ')
    email = t[0]

    # parse
    lines = params.split('\n')
    headers = {}
    eoh = 0
    for i in lines:
        # end of headers
        if i == '\r':
            break
        tv = i.split(':', 1)
        type = tv[0]
        value = tv[1].strip()
        headers[type] = value
        eoh += 1
    eoh +=1

    # handle special hotmail messages
    if email == 'Hotmail':
        if not headers.has_key('Content-Type'):
            return
        hotmail_info = {}

        # parse the body
        for i in lines:
            i = i.strip()
            if not i:
                continue
            tv = i.split(':', 1)
            type = tv[0]
            value = tv[1].strip()
            hotmail_info[type] = value

        msnlib.debug(params)
        if headers['Content-Type'] == 'text/x-msmsgsinitialemailnotification; charset=UTF-8':
            newmsgs = int(hotmail_info['Inbox-Unread'])
            if not newmsgs:
                return
            debug('\rYou have %s unread email(s)' % str(newmsgs) \
                + ' in your Hotmail account')
        elif headers['Content-Type'] == 'text/x-msmsgsemailnotification; charset=UTF-8':
            from_name = hotmail_info['From']
            from_addr = hotmail_info['From-Addr']
            subject = hotmail_info['Subject']
            debug('\rYou have just received an email in your' + \
                ' Hotmail account:')
            debug('\r\tFrom: %s (%s)' % (from_name, from_addr))
            debug('\r\tSubject: %s' % subject)
        return

    if headers.has_key('Content-Type') and headers['Content-Type'] == 'text/x-msmsgscontrol':
        # the typing notices
        nick = email2nick(email)
        if not nick: nick = email
        if not m.users[email].priv.has_key('typing'):
            m.users[email].priv['typing'] = 0
        if not m.users[email].priv['typing']:
            debug('\r')
            ctime = time.strftime('%I:%M:%S%p', now())
            debug('%s ' % ctime)
            debug('%s' % nick)
            debug(' is typing')
        m.users[email].priv['typing'] = time.time()
    elif headers.has_key('Content-Type') and headers['Content-Type'] == 'text/x-clientcaps':
        # ignore the x-clientcaps messages generated from gaim
        pass
    elif headers.has_key('Content-Type') and headers['Content-Type'] == 'text/x-keepalive':
        # ignore kopete's keepalive messages
        pass
    else:
        # messages
        m.users[email].priv['typing'] = 0
        argv = [str(x) for x in lines]
        argv.append(str(email))
        argv.append(str(HOST))
        argv.append(str(PORT))
        fp = subprocess.Popen(CMD + ' "' + urllib.quote_plus('\n\r\n'.join(argv)) + '"', shell=True, stdout=subprocess.PIPE, stdin=subprocess.PIPE)
        #m.sendmsg(email, lines[-1])
    msncb.cb_msg(md, type, tid, params, sbd)