Exemplo n.º 1
0
def dt(conn, msg):
    if len(msg.text.split()) > 2:
        naam = msg.text.split()[1]
        error = ' '.join(msg.text.split()[2:])
        rowid = sqlite.set('INSERT INTO irc_dt (name, error) VALUES (?, ?)', (naam, error,))
        conn.send('PRIVMSG %s :DT-fout %i added!\r\n' % (msg.channel, rowid))
    else:
        parts = msg.text.split()
        if len(parts) == 1:
            rows, count = sqlite.get('SELECT * FROM irc_dt ORDER BY RANDOM()', ())

            if count != 0:
                conn.send('PRIVMSG %s :DT-fout %i: [%s] %s\r\n' % (msg.channel, rows[0][0], rows[0][1], rows[0][2]))

        elif parts[1].isdigit():
            rows, count = sqlite.get('SELECT * FROM irc_dt WHERE id=?', (parts[1],))

            if count != 0:
                conn.send('PRIVMSG %s :DT-fout %i: [%s] %s\r\n' % (msg.channel, rows[0][0], rows[0][1], rows[0][2]))

        else:
            rows, count = sqlite.get('SELECT * FROM irc_dt WHERE name=? ORDER BY RANDOM()', (parts[1],))

            if count != 0:
                conn.send('PRIVMSG %s :DT-fout: %s heeft in totaal al %i DT-fouten gemaakt\r\n' % (msg.channel, rows[0][1], count))
            else:
                conn.send('PRIVMSG %s :DT-fout: %s heeft nog geen DT-fouten gemaakt\r\n' % (msg.channel, parts[1]))
Exemplo n.º 2
0
def quote(conn, msg):
    parts = msg.text.split()
    if len(parts) == 1: # Random quote
        rows, count = sqlite.get('SELECT * FROM irc_quote ORDER BY RANDOM()', ())

    elif parts[1].isdigit(): # Haal quote nummer zoveel op
        rows, count = sqlite.get('SELECT * FROM irc_quote WHERE id=?', (parts[1],))

    else:
        rows, count = sqlite.get('SELECT * FROM irc_quote WHERE quote LIKE ? ORDER BY RANDOM()', ("%"+parts[1]+"%",))
    if count != 0:
        conn.send('PRIVMSG %s :Quote %i: %s\r\n' % (msg.channel, rows[0][0], rows[0][1]))
Exemplo n.º 3
0
def explain(conn, msg):
     if len(msg.text.split()) > 1:
         word = msg.text.split()[1]
         rows, count = sqlite.get('SELECT * FROM irc_assign WHERE word = ?', (word,))
         if count != 0:
             conn.send('PRIVMSG %s :%s: %s\r\n' % (msg.channel, word, rows[0][2]))
     else:
        usage = 'Gebruik: ? woord'
        conn.send('PRIVMSG %s :%s\r\n' % (msg.user, usage))
Exemplo n.º 4
0
    def Broadcasts(self, filter=None):
        Page = startHTML + "<H1> User Broadcasts </H1><br/>"
        try:
            ApiApp.report(self, cherrypy.session['status'])
            blocked = list()
            blocked = cherrypy.session['blocked']
            data = sqlite.get(self)
            Page += "<a href='/index'>Home</a></br>"
            Page += '<form action="/Broadcasts" method="post" enctype="multipart/form-data">'
            Page += '<br/>'
            Page += '<H2>Filter Posts by username : </H2><input style="height:50px"; type="text" name="filter"/>'
            Page += "&nbsp"
            Page += '<input type="submit" value="filter"/></form>'
            Page += "<a href='Broadcasts'> Go Back </a>"  # maybe put this somewhere else
            Page += "<div class='myBox'>"
            for i in range(len(data["name"]) - 1, -1, -1):
                for j in range(len(blocked)):
                    count = 0
                    if (data["name"][i] == blocked[j]):
                        count = 1

                    if (count == 0):
                        if (filter == None):
                            Page += data["name"][i]
                            Page += ":&nbsp"
                            Page += str(data["message"][i])
                            Page += "&nbspat&nbsp"
                            Page += data["time"][i]
                            Page += "</br>"
                        elif (filter != None):
                            if (data["name"][i] == filter):
                                Page += "</br>"
                                Page += data["name"][i]
                                Page += ":&nbsp"
                                Page += str(data["message"][i])
                                Page += "&nbspat&nbsp"
                                Page += data["time"][i]
                                Page += "</br>"

            Page += "</div>"
        except KeyError:
            Page += "Something went wrong, please log in again </br>"
            Page += "<a href='/index'>Login</a>"
        return Page
Exemplo n.º 5
0
def assign(conn, msg):
    if msg.user == settings.irc_OWNER or utils.isadmin(conn, msg):
        if len(msg.text.split()) > 2:
            word = msg.text.split()[1]
            defin = ' '.join(msg.text.split()[2:])

            rows, count = sqlite.get('SELECT * FROM irc_assign WHERE word=?', (word,))

            if count > 0:
                conn.send('PRIVMSG %s :%s is already defined: %s\r\n' % (msg.channel, rows[0][1], rows[0][2]))
            else:
                rowid = sqlite.set('INSERT INTO irc_assign (word, def) VALUES (?, ?)', (word, defin,))
                conn.send('PRIVMSG %s :%s added to assign list.\r\n' % (msg.channel, word))
        else:
            usage = 'Gebruik: !assign woord definitie'
            conn.send('PRIVMSG %s :%s\r\n' % (msg.user, usage))
    else:
        usage = 'Je moet een administrator zijn om dit commando te kunnen uitvoeren.'
        conn.send('PRIVMSG %s :%s\r\n' % (msg.user, usage))
Exemplo n.º 6
0
def reassign(conn, msg):
    if msg.user == settings.irc_OWNER or utils.isadmin(conn, msg):
        if len(msg.text.split()) > 2:
            word = msg.text.split()[1]
            defin = ' '.join(msg.text.split()[2:])

            rows, count = sqlite.get('SELECT * FROM irc_assign WHERE word=?', (word,))

            if count == 0:
                conn.send('PRIVMSG %s :%s is not defined yet. Use !assign word def to assign it.\r\n' % (msg.channel, word))
            else:
                rowid = sqlite.set('UPDATE irc_assign SET def=? WHERE word=?', (defin, word,))
                conn.send('PRIVMSG %s :%s reassigned to: %s\r\n' % (msg.channel, word, defin))
        else:
            usage = 'Gebruik: !reassign woord definitie'
            conn.send('PRIVMSG %s :%s\r\n' % (msg.user, usage))
    else:
        usage = 'Je moet een administrator zijn om dit commando te kunnen uitvoeren.'
        conn.send('PRIVMSG %s :%s\r\n' % (msg.user, usage))
Exemplo n.º 7
0
def list(conn, msg):

    aantal = 5
    if len(msg.text.split()) > 1:
        getal = msg.text.split()[1]
        if getal.isdigit():
            getal = int(getal)
            if getal > 0:
                aantal = getal
            if getal > 15:
                aantal = 15

    rows, count = sqlite.get('SELECT name, COUNT(*) FROM `irc_dt` GROUP BY name ORDER BY COUNT(*) DESC', ())
    conn.send('PRIVMSG %s :Nr.: Naam - Aantal\r\n' % (msg.channel))

    if count < aantal:
        aantal = count

    conn.send('PRIVMSG %s :DT-fouten top %i:\r\n' % (msg.channel, aantal))
    for row in range(0, aantal):
        conn.send('PRIVMSG %s :  %i: %s - %s\r\n' % (msg.channel, (row+1), rows[row][0], rows[row][1]))
Exemplo n.º 8
0
def list(conn, msg):
    aantal = 10
    if len(msg.text.split()) > 1:
        getal = msg.text.split()[1]
        if getal.isdigit():
            getal = int(getal)
            if getal > 0:
                aantal = getal
            if getal > 30:
                aantal = 30

    rows, count = sqlite.get('SELECT * FROM irc_assign ORDER BY id DESC', ())

    if aantal > count:
        aantal = count

    out=[]
    for row in range(0, aantal):
        out.append(rows[row][1])

    conn.send('PRIVMSG %s :Last %i assigns: %s\r\n' % (msg.channel, aantal, ', '.join(out)))
Exemplo n.º 9
0
def active(conn, msg):
    rows, count = sqlite.get('SELECT * FROM irc_tell WHERE `to`=?', (msg.user,))
    for row in rows:
        conn.send('PRIVMSG %s :%s: [%s] %s: %s\r\n' % (msg.channel, row[3], row[1], row[2], row[4]))
        count = sqlite.set('DELETE FROM irc_tell WHERE `id`=?', (row[0],))