# -*- encoding: iso-8859-2 -*-

import ekg
import re
import os

regexp=re.compile("((http|ftp)\:\/\/[\S]+)")

def message_handler(session, uid, type, text, sent_time, ignore_level):
	reg_matches = regexp.findall(text)
	if reg_matches:
		a=[]
		
		for match in reg_matches:
			a.append(match[0] + "\n")
		
		file = open("/home/dragonee/.ekg2/links", 'a')
		file.writelines(a);
		file.close()
		
		ekg.echo("Link(i) zostały wysłane...")
ekg.handler_bind('protocol-message-received', message_handler)
			
		
