Exemple #1
0
    def __init__(self, config):
        """
        Initialize the notification system.

        Opens a FIFO (named pipe) and registers handlers.

        :param config: ekg2's config (ekg.config)
        :type config: :class:`dict`

        """
        self.ekgconfig = config

        fifo = self.ekgconfig['notify:fifo']
        ekg.echo("Opening pipe at %s!" % fifo)
        self.pipe = open(fifo, 'w+')

        ekg.handler_bind('protocol-message-received', self.message_handler)
        ekg.command_bind('notify-test', self.test_handler)
Exemple #2
0
    This function is bound to notify:send command
    """
    args = args.split(None, 1)
    if (len(args) == 0):
        title="Test"
    else:
        title=args[0]
  
    if (len(args) <= 1):
        text="Pięćdziesiąt trzy"
    else:
        text = args[1]
  
    return displayNotify(title, text, TIMEOUT_MSG, ekg.config["notify:icon_msg"])

ekg.handler_bind('protocol-status', notifyStatus)
ekg.handler_bind("protocol-message-received", notifyMessage)
ekg.variable_add("notify:ignore_sessions_regexp", "^irc:")
ekg.variable_add("notify:ignore_uids_regexp", "^xmpp:.*@conference\.")
ekg.variable_add("notify:urgency_critical_regexp", "^$")
ekg.variable_add("notify:urgency_normal_regexp", "^$")
ekg.variable_add("notify:icon_status", "dialog-warning")
ekg.variable_add("notify:icon_msg", "dialog-warning")
ekg.variable_add("notify:message_timeout", "3500", timeCheck)
ekg.variable_add("notify:message_notify", "1")
ekg.variable_add("notify:message_notify_unknown", "1")
ekg.variable_add("notify:show_timestamps", "1")
ekg.variable_add("notify:status_timeout", "3500", timeCheck)
ekg.variable_add("notify:status_notify", "1")
ekg.variable_add("notify:catch_url", "1")
ekg.variable_add("notify:catch_url_timeout", "5000", timeCheck)
Exemple #3
0
		if not desc: desc = ""
		else: desc = unicode(desc, current_encoding)
		timeout = 2000 + len(desc)*50

# (s appname, u id, s icon, s header, s body, as actions a{sv} hints, i timeout_ms)
		notif.Notify (dbus.String("ekg2"), dbus.UInt32(0), "",
			dbus.String(htxt), dbus.String(desc),
			dbus.String(""), {}, dbus.Int32(timeout) )

		return 1

def message_handler(session, uid, type, text, sent_time, ignore_level):
	current_encoding = ekg.config["console_charset"] or "iso-8859-2"
		
	user = ekg.session_get(session).user_get(uid)
	uname = unicode(user.nickname or uid, current_encoding)
	
	htxt = uname + ":"
	msg = unicode(text[0:127], current_encoding)
		
	timeout = 2000 + len(msg)*50

	notif.Notify (dbus.String("ekg2"), dbus.UInt32(0), "",
		dbus.String(htxt), dbus.String(msg),
		dbus.String(""), {}, dbus.Int32(timeout) )

	return 1

ekg.handler_bind('protocol-status', status_handler)
ekg.handler_bind('protocol-message-received', message_handler)
Exemple #4
0
		file.close()
		os.unlink("%s/%s" % (dir, fname))

def messageHandler(session, uid, type, text, stime, ignore_level):
	for c in command:
		mx = command[c][0].search(text)
		if (mx):
			ekg.command(("/msg %s %s" % (uid, command[c][1](mx))).encode('UTF8'))
			break

def testMessageHandler(session, uid, type, text, stime, ignore_level):
	if text[-21:-4] == "!jirabot selftest":
		for i in color.test():
			ekg.command("/msg %s TEST [%s]" % (uid, i))

ekg.handler_bind("protocol-message-received", messageHandler)
ekg.handler_bind("protocol-message-received", testMessageHandler)
ekg.timer_bind(5, handleSignals)

ekg.variable_add("jirabot:url", "")
ekg.variable_add("jirabot:username", "")
ekg.variable_add("jirabot:password", "")
ekg.variable_add("jirabot:project", "")
ekg.variable_add("jirabot:channel", "")
ekg.variable_add("jirabot:sigdir", "/nonexistent")
ekg.variable_add("jirabot:projectregexp", "[A-Z]+")

ekg.command_bind("jirabot:initialize", initialize)
ekg.command_bind("jirabot:print_config", print_config)
ekg.command_bind("jirabot:signal", lambda n, a: messageHandler(None, ekg.config["jirabot:channel"], None, a, None, None))
Exemple #5
0
        else: desc = unicode(desc, current_encoding)
        timeout = 2000 + len(desc) * 50

        # (s appname, u id, s icon, s header, s body, as actions a{sv} hints, i timeout_ms)
        notif.Notify(dbus.String("ekg2"), dbus.UInt32(0), "",
                     dbus.String(htxt), dbus.String(desc), dbus.String(""), {},
                     dbus.Int32(timeout))

        return 1


def message_handler(session, uid, type, text, sent_time, ignore_level):
    current_encoding = ekg.config["console_charset"] or "iso-8859-2"

    user = ekg.session_get(session).user_get(uid)
    uname = unicode(user.nickname or uid, current_encoding)

    htxt = uname + ":"
    msg = unicode(text[0:127], current_encoding)

    timeout = 2000 + len(msg) * 50

    notif.Notify(dbus.String("ekg2"), dbus.UInt32(0), "", dbus.String(htxt),
                 dbus.String(msg), dbus.String(""), {}, dbus.Int32(timeout))

    return 1


ekg.handler_bind('protocol-status', status_handler)
ekg.handler_bind('protocol-message-received', message_handler)
Exemple #6
0
        elif text == "!rss":
            rssReader()
            return 1
    elif text == "!wersja":
        ekg.command("gg:msg %s Moja wersja to %s" % (uid, config.version))
        return 1
    elif text == "!autorzy":
        ekg.command("gg:msg %s Stworzyl mnie %s i nadal rozwija." % (uid, config.autor))
        return 1
    else:
        ekg.command(
            "gg:msg %s Witaj! Nazywam sie %s i jestem botem GG stworzonym i rozwijanym przez %s .\nBot zostal wylacznie do uzytku autora. Nie masz co szukac :)"
            % (uid, config.nazwa_kodowa, config.autor)
        )
        return 1


def connect_handler(session):
    ekg.echo("Sesja : " + session)
    sesja = ekg.session_get(session)
    if sesja.connected():
        ekg.echo("Połączony! Silnik i sto turbin poszło w ruch! :)")
    else:
        ekg.echo("W tym miejscu jeszcze nie połączony")


ekg.handler_bind("protocol-connected", connect_handler)
ekg.handler_bind("protocol-status", status_handler)
ekg.handler_bind("protocol-message-received", message_handler)
ekg.timer_bind(30, checkMail)
Exemple #7
0
	    ekg.echo('£adnie to tak ircowaæ w pracy? ;)')
    sesja = ekg.session_get(session)
    if sesja.connected():
	ekg.echo('Po³±czony!')
    else:
	ekg.echo('W tym miejscu jeszcze nie po³±czony')
    ekg.echo('Lista userów sesji: '+", ".join(sesja.users()))

def keypress(key):
    ekg.echo('nacisnales #'+ str(key));
    

def disconnect_handler(session):
    ekg.echo("£o, sesja %s nam pad³a" % (session,))
    ekg.echo("Wysy³amy smsa ¿e nam cu¶ pad³o...")

def foo_command(name, args):
    ekg.echo("Wywo³ane polecenie foo!")

def varchange(name, newval):
    ekg.echo("Zmienna %s zmieni³a warto¶æ na %s" % (name, newval) )
    
ekg.command_bind('foo', foo_command)
ekg.handler_bind('protocol-message-received', message_handler)
ekg.handler_bind('protocol-message-sent', own_message_handler)
ekg.handler_bind('protocol-status', status_handler)
ekg.handler_bind('protocol-connected', connect_handler)
ekg.handler_bind('protocol-disconnected', disconnect_handler)
ekg.handler_bind('ui-keypress', keypress)
ekg.variable_add('zmienna_testowa', 'warto¶æ', varchange)
Exemple #8
0
#!/usr/bin/python2.7
# -*- coding: ISO-8859-2 -*-

import ekg
import string

def keypress(key):
        ekg.echo("Przycisk " + str(key))

ekg.handler_bind('ui-keypress', keypress)
Exemple #9
0
    else:
        ekg.echo('W tym miejscu jeszcze nie po³±czony')
    ekg.echo('Lista userów sesji: ' + ", ".join(sesja.users()))


def keypress(key):
    ekg.echo('nacisnales #' + str(key))


def disconnect_handler(session):
    ekg.echo("£o, sesja %s nam pad³a" % (session, ))
    ekg.echo("Wysy³amy smsa ¿e nam cu¶ pad³o...")


def foo_command(name, args):
    ekg.echo("Wywo³ane polecenie foo!")


def varchange(name, newval):
    ekg.echo("Zmienna %s zmieni³a warto¶æ na %s" % (name, newval))


ekg.command_bind('foo', foo_command)
ekg.handler_bind('protocol-message-received', message_handler)
ekg.handler_bind('protocol-message-sent', own_message_handler)
ekg.handler_bind('protocol-status', status_handler)
ekg.handler_bind('protocol-connected', connect_handler)
ekg.handler_bind('protocol-disconnected', disconnect_handler)
ekg.handler_bind('ui-keypress', keypress)
ekg.variable_add('zmienna_testowa', 'warto¶æ', varchange)
Exemple #10
0
                ssh = main.SSHConnection()
                server = main.getServerNameFromUid(uid)
                username = main.getUserNameFromUid(uid)
                mysql.query('SELECT execute FROM botssh WHERE command=%s',
                            i[0])
                execute = mysql.fetchOne()
                s = Template(execute[0])
                s = s.safe_substitute(nick=username[0],
                                      name=re.split(' ', text, 2)[1])
                ssh.setConnection(server, 'root', secret.serversList[server])
                ssh.setCommand(s)
                sendMessage = main.SendMessage()
                sendMessage.setUid(uid)
                sendMessage.setMsg(ssh.getResult())
                sendMessage.sendMessageByUid()
                break


def messageHandler(session, uid, type, text, sent_time, ignore_level):
    text = ' '.join(text.split())
    if text.find('!') == 0:
        mysql_local = main.MySQLConnection('local')
        mysql_remote = main.MySQLConnection('remote')

        messagesForEveryone(uid, mysql_local, text)
        sshCommands(uid, mysql_local, text)
        accountCommands(uid, mysql_remote, text)


ekg.handler_bind('protocol-message-received', messageHandler)