Пример #1
0
def respondCall():
	call = CallInfo()
	number = call.get_caller_number()
	caller = call.get_caller_name()

	global win
	win = Tkinter.Tk()
	win.overrideredirect(1)
	win.title("Incoming Call")
	
	width = 370
	height = 100
	win.resizable(width=FALSE, height=FALSE)
	ws = win.winfo_screenwidth() # width of the screen
	hs = win.winfo_screenheight() # height of the screen
	x = (ws/1.2) - (width/2)
	y = (hs/1.3) - (height/2)
	win.geometry('%dx%d+%d+%d' % (width, height, x, y))
	win.configure(background='white')
	
	message = '{} ({})\n is calling'.format(caller, number)
	Label(win, text=message, background="white", font=tkFont.Font(family="Helvetica", size=15)).pack()

	photoImage_accept = ImageTk.PhotoImage(file="images/accept.png")
	photoImage_reject = ImageTk.PhotoImage(file="images/reject.png")

	button_accept = Button(win, image=photoImage_accept, command=acceptCall, bd = 0, background="white").pack(side=LEFT)
	button_reject = Button(win, image=photoImage_reject, command=rejectCall, bd = 0, background="white").pack(side=RIGHT)

	global play_sound_thread
	play_sound_thread = Process(target=playSound)
	play_sound_thread.start()

	win.mainloop()
Пример #2
0
def main():
	call = CallInfo()
	check_call = False
	while(not check_call):
		check_call = call.check_if_calling()
		if(check_call == True):
			respondCall()
Пример #3
0
def main():
    call = CallInfo()
    check_call = False
    while (not check_call):
        check_call = call.check_if_calling()
        if (check_call == True):
            respondCall()
Пример #4
0
def respondCall():
    call = CallInfo()
    number = call.get_caller_number()
    caller = call.get_caller_name()

    global win
    win = Tkinter.Tk()
    win.overrideredirect(1)
    win.title("Incoming Call")

    width = 370
    height = 100
    win.resizable(width=FALSE, height=FALSE)
    ws = win.winfo_screenwidth()  # width of the screen
    hs = win.winfo_screenheight()  # height of the screen
    x = (ws / 1.2) - (width / 2)
    y = (hs / 1.3) - (height / 2)
    win.geometry('%dx%d+%d+%d' % (width, height, x, y))
    win.configure(background='white')

    message = '{} ({})\n is calling'.format(caller, number)
    Label(win,
          text=message,
          background="white",
          font=tkFont.Font(family="Helvetica", size=15)).pack()

    photoImage_accept = ImageTk.PhotoImage(file="images/accept.png")
    photoImage_reject = ImageTk.PhotoImage(file="images/reject.png")

    button_accept = Button(win,
                           image=photoImage_accept,
                           command=acceptCall,
                           bd=0,
                           background="white").pack(side=LEFT)
    button_reject = Button(win,
                           image=photoImage_reject,
                           command=rejectCall,
                           bd=0,
                           background="white").pack(side=RIGHT)

    global play_sound_thread
    play_sound_thread = Process(target=playSound)
    play_sound_thread.start()

    win.mainloop()
Пример #5
0
def rejectCall():
	call = CallInfo()
	call.decline_call()
	play_sound_thread.terminate()
	win.destroy()
	main()
Пример #6
0
def acceptCall():
	call = CallInfo()
	call.accept_call()
	play_sound_thread.terminate()
	win.destroy()
	main()
Пример #7
0
def rejectCall():
    call = CallInfo()
    call.decline_call()
    play_sound_thread.terminate()
    win.destroy()
    main()
Пример #8
0
def acceptCall():
    call = CallInfo()
    call.accept_call()
    play_sound_thread.terminate()
    win.destroy()
    main()
Пример #9
0
    def parse_and_examine_line(self, raw_line):
        """ Parse call monitor line, if RING event not in lists, rate and maybe block the number. """
        if time() - self.list_age >= 3600:  # Reload phonebooks if list is outdated
            self.reload_phonebooks()
        log.debug(raw_line)
        cm_line = CallMonitorLine(raw_line)
        print(cm_line)

        # New: also examine calls from inside to outside (CallMonitorType.CALL)
        if cm_line.type in [CallMonitorType.RING.value, CallMonitorType.CALL.value]:
            dt = cm_line.datetime  # Use same datetime for exact match

            if cm_line.type == CallMonitorType.RING.value:
                number = cm_line.caller  # Incoming call
            else:
                number = cm_line.callee  # Outgoing call

            if not number:  # Caller uses NO number (so called CLIR feature)

                # We cannot block anon numbers, except you could add a rule in Fritzbox to do so?
                rate = CallBlockerRate.PASS.value  # CallBlockerRate.BLOCK.value if self.block_anon else CallBlockerRate.PASS.value
                raw_line = f'{dt};{rate};0;;ANON;' + "\n"

            else:  # Caller WITH phone number

                is_abroad = number.startswith('00') and not number.startswith(self.cp.country_code)

                if number.startswith('0'):
                    full_number = number  # Number with either country code or area code
                else:
                    full_number = self.cp.area_code + number  # Number in same area network

                # 1. Is either full number 071..123... or short number 123... in the white- or blacklist?
                name_white = self.pb.get_name_for_number_in_dict(number, self.whitelist, area_code=self.cp.area_code)
                name_black = self.pb.get_name_for_number_in_dict(number, self.blacklist, area_code=self.cp.area_code)

                if name_white and name_black:
                    raise Exception(f'Problem in your phonebooks detected: '
                                    f'a number should not be on white- and blacklist. Please fix! Details: '
                                    f'whitelist:{name_white} blacklist:{name_black}')

                if name_white or name_black:
                    name = name_black if name_black else name_white  # Reason: black might win over white by blocking it
                    rate = CallBlockerRate.BLACKLIST.value if name_black else CallBlockerRate.WHITELIST.value
                    raw_line = f'{dt};{rate};0;{full_number};"{name}";' + "\n"

                else:
                    ci = CallInfo(full_number)
                    ci.get_cascade_score()

                    # ToDo: check also if e.g. the prefix is inactive, e.g. DE_LANDLINE_INACTIVE
                    # Is the prefix (Vorwahl) valid, existing country code OR area code?
                    prefix_name = self.cp.get_prefix_name(full_number)
                    if not prefix_name and not number.startswith('00'):  # Do not block e.g. Inmarsat or similar
                        prefix_name = FAKE_PREFIX

                    # If there is no other information name at least the country or area
                    if ci.name == UNKNOWN_NAME:
                        ci.name = prefix_name

                    # Adapt to logging style of call monitor. Task of logger to parse the values to keys/names?
                    score_str = f'"{ci.name}";{ci.score};{ci.comments};{ci.searches};'

                    # Bad code style here - should be rewritten soon
                    if (self.block_illegal_prefix and prefix_name == FAKE_PREFIX) \
                            or (self.block_abroad and is_abroad) \
                            or (ci.score >= self.min_score and ci.comments >= self.min_comments):
                        name = self.blockname_prefix + ci.name
                        # Precaution: should only happen if this is a call from outside, not from inside
                        if cm_line.type == CallMonitorType.RING.value:
                            # ToDo: should go in extra method
                            result = self.pb.add_contact(self.blocklist_pbid, name, full_number)
                            if result:  # If not {} returned, it's an error
                                log.warning("Adding to phonebook failed:")
                                print(result)
                            else:
                                # Reload phonebook to prevent re-adding number for next ring event
                                # self.blacklist = self.pb.get_all_numbers_for_pb_ids(self.blacklist_pbids)
                                self.reload_phonebooks()
                            rate = CallBlockerRate.BLOCK.value
                        else:
                            rate = CallBlockerRate.PASS.value
                    else:
                        rate = CallBlockerRate.PASS.value
                    raw_line = f'{dt};{rate};1;{full_number};{score_str}' + "\n"

            log.debug(raw_line)
            parsed_line = CallBlockerLine(raw_line)
            print(parsed_line)
            if self.logger:
                self.logger(raw_line)

            # ToDo: add that an event is only posted once if same full_number and e.g. not same minute
            if TELEGRAM_BOT_URL:
                requests.get(TELEGRAM_BOT_URL + quote("CallBlocker: " + raw_line))
Пример #10
0
        if number:  # If CLIR / Anon, there is no number
            if not number.startswith('0'):
                number = cp.area_code + number
            numbers.add(number)

    print(f'\nAll {len(calls)} calls, uniqued {len(numbers)}:')
    print(numbers)

    anylist = pb.get_all_numbers_for_pb_ids([0, 1, 2])  # White- or blacklist

    print('\nWhite- or blacklisted:')
    unknowns = set()
    for number in numbers:
        name = pb.get_name_for_number_in_dict(number,
                                              anylist,
                                              area_code=cp.area_code)
        if name:
            print(f'{number} {name}')
        else:
            unknowns.add(number)

    # Idea: rate & info ... auto-block .. or add good names to whitelist?
    print('\nResolving Unknowns:')
    for unknown in unknowns:
        ci = CallInfo(unknown)
        ci.get_cascade_score()
        print(ci)
        sleep(
            10
        )  # Anti-DDOS needed for tellows and wemgehoert, otherwise you get blocked or captcha
Пример #11
0
                number = cp.area_code + number
            numbers.add(number)

    print(f'\nLast {len(calls)} calls, uniqued: {len(numbers)}')
    print(numbers)

    print('\nWhite- or blacklisted:')
    unknowns = set()
    for number in numbers:
        name = pb.get_name_for_number_in_dict(number,
                                              anylist,
                                              area_code=cp.area_code)
        if name:
            print(f'{number} {name}')
        else:
            unknowns.add(number)

    # Idea: rate & info ... auto-block .. or add good names to whitelist?
    print(f'\nResolving Unknowns: {len(unknowns)}')
    for unknown in unknowns:
        ci = CallInfo(unknown)
        ci.get_cascade_score()
        if not ci.location:
            ci.location = cp.get_prefix_name(unknown)
        print(ci)
        sleep(
            5
        )  # Anti-DDOS needed for tellows (and if used, wemgehoert), otherwise you get blocked or captcha

    print('\nREADY.')