__module_name__ = 'Notify'
__module_description__ = 'Sends a notification on highlight/notice/pm'
__module_version__ = '1.0'

import os
import hexchat


def notice_callback(word, word_eol, userdata):
    if hexchat.get_info("win_status") == 'active':
        return
    os.system(
        hexchat.strip('notify-send \"Notice from %s\" \"%s\"' %
                      (word[0], word[1])))
    return hexchat.EAT_NONE


def pm_callback(word, word_eol, userdata):
    if hexchat.get_info("win_status") == 'active':
        return
    os.system(
        hexchat.strip('notify-send \"PM from %s\" \"%s\"' %
                      (word[0], word[1])))
    return hexchat.EAT_NONE


def highlight_callback(word, word_eol, userdata):
    if hexchat.get_info("win_status") == 'active':
        return
    os.system(
        hexchat.strip('notify-send \"Highlight from %s\" \"%s\"' %
                      (word[0], word[1])))
    return hexchat.EAT_NONE

hexchat.hook_print("Channel Msg Hilight", highlight_callback)
hexchat.hook_print("Channel Action Hilight", highlight_callback)
hexchat.hook_print("Notice", notice_callback)
hexchat.hook_print("Private Action", pm_callback)
hexchat.hook_print("Private Message", pm_callback)
hexchat.hook_print("Private Action to Dialog", pm_callback)
hexchat.hook_print("Private Message to Dialog", pm_callback)
