예제 #1
0
파일: dt.py 프로젝트: Silox/Python-IRC-bot
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]))
예제 #2
0
def addquote(conn, msg):
    if len(msg.text.split()) > 1:
        quote = ' '.join(msg.text.split()[1:])
        rowid = sqlite.set('INSERT INTO irc_quote (quote) VALUES (?)', (quote,))
        conn.send('PRIVMSG %s :Quote %i added!\r\n' % (msg.channel, rowid))
    else:
        usage = 'Gebruik: !addquote quote'
        conn.send('PRIVMSG %s :%s\r\n' % (msg.user, usage))
예제 #3
0
def delquote(conn, msg):
    if msg.user == settings.irc_OWNER or utils.isadmin(conn, msg):
        if len(msg.text.split()) > 1 and msg.text.split()[1].isdigit():
            rowid = sqlite.set('DELETE FROM irc_quote WHERE id=?', (msg.text.split()[1],))
            conn.send('PRIVMSG %s :Quote %i deleted!\r\n' % (msg.channel, int(msg.text.split()[1])))
        else:
            usage = 'Gebruik: !delquote id'
            conn.send('PRIVMSG %s :%s\r\n' % (msg.user, usage))
    else:
        usage = 'Je moet een operator zijn om dit commando te kunnen gebruiken.'
        conn.send('PRIVMSG %s :%s\r\n' % (msg.user, usage))
예제 #4
0
def tell(conn, msg):
    if len(msg.text.split()) > 2:
        message = ' '.join(msg.text.split()[2:])
        to = msg.text.split()[1]
        frm = msg.user

        rowid = sqlite.set("INSERT INTO irc_tell (`user`, `to`, `message`) VALUES (?, ?, ?)", (frm, to, message))
        conn.send('PRIVMSG %s :I will tell %s that when %s is here.\r\n' % (msg.channel, to, to))
    else:
        usage = 'Gebruik: !tell naam tekst'
        conn.send('PRIVMSG %s :%s\r\n' % (msg.user, usage))
예제 #5
0
def unassign(conn, msg):
    if msg.user == settings.irc_OWNER or utils.isadmin(conn, msg):
        if len(msg.text.split()) > 1:
            word = msg.text.split()[1]
            rowid = sqlite.set('DELETE FROM irc_assign WHERE word=?', (word,))
            conn.send('PRIVMSG %s :%s unassigned.\r\n' % (msg.channel, word))
        else:
            usage = 'Gebruik: !unassign woord'
            conn.send('PRIVMSG %s :%s\r\n' % (msg.user, usage))
    else:
        usage = 'Je moet een operator zijn om dit commando te kunnen gebruiken.'
        conn.send('PRIVMSG %s :%s\r\n' % (msg.user, usage))
예제 #6
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))
예제 #7
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))
예제 #8
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],))