示例#1
0
def _clear_reminder(conn, rem_name):
    """Is for appending to old reminders in the db"""

    db.set_cell(conn, 'reminders', 'msg', '', 'name', rem_name)
    db.set_cell(conn, 'reminders', 'last_updated', str(int(time.time())),
                'name', rem_name)
    db.ccache()
示例#2
0
async def inittell(client):
    """Is used to initialize the tell database"""
    conn = client.bot.dbs[client.server_tag]
    print (f'Initializing tell table in /persist/db/{client.server_tag}.db...')
    db.init_table(conn, 'tells', tell_columns)
    db.ccache()
    print ('Tell initialization complete.')
示例#3
0
def _delete_tell(conn, tell):
    """ Is used to delete tells """
    cur = conn.cursor()
    cur.execute('DELETE FROM tells WHERE msg=? AND time=? AND seen_time=?',
                (tell[2], tell[3], tell[5]))
    conn.commit()
    db.ccache()
示例#4
0
async def tell(client, data):
    """.tell - send a message to an user which is currently inactive"""
    conn = client.bot.dbs[data.server]
    split = data.split_message

    tables = db.get_table_names(conn)
    if 'tells' not in tables:
        asyncio.create_task(
            client.message(
                data.target,
                'Tell table uninitialized, ask your nearest bot admin to restart the bot.'
            ))

    if len(split) > 1:
        recipient = split[0]
        recipient = recipient.lower()
        message = ' '.join(split[1:])
    else:
        return

    telldata = (recipient, data.nickname, message, int(time.time()), '0', '0')
    db.set_row(conn, 'tells', telldata)
    db.ccache()

    asyncio.create_task(
        client.notice(data.nickname, 'Your message will be sent.'))
示例#5
0
async def reminit(client):
    """Db init command, run once on startup"""
    conn = client.bot.dbs[client.server_tag]
    print(('Initializing reminder database table'
           f'in /persist/db/{client.server_tag}.db...'))
    db.init_table(conn, 'reminders', reminder_columns)
    db.ccache()
    print('Reminder initialization complete.')
示例#6
0
async def quoteinit(client, data):
    """admin only quote db table initiation hook, since trying to init
    on every quote(even though the db functions account for that) is kinda
    wasteful"""
    conn = client.bot.dbs[data.server]
    print(f'Initializing quote table in /persist/db/{data.server}.db...')
    db.init_table(conn, 'quotes', quote_columns)
    db.ccache()
    print('Initialization complete.')
示例#7
0
def _set_tell_seen(conn, tell):
    """ Is used to set a tell's status to seen """
    if tell[4] == '1':
        return

    cur = conn.cursor()
    cur.execute("UPDATE tells SET seen='1', seen_time=? WHERE msg=? AND time=?", (str(int(time.time())), tell[2], tell[3]))
    del cur
    conn.commit()
    db.ccache()
示例#8
0
def _append_reminder(conn, rem_name, rem_text):
    """Is for appending to old reminders in the db"""
    old_rem_text = _get_reminder_text(conn, rem_name)
    new_rem_text = f'{old_rem_text} and {rem_text}'

    rem_text_trunc = new_rem_text[:max_reminder_len]

    db.set_cell(conn, 'reminders', 'msg', rem_text_trunc, 'name', rem_name)
    db.set_cell(conn, 'reminders', 'last_updated', str(int(time.time())),
                'name', rem_name)
    db.ccache()
示例#9
0
def _create_new_reminder(conn, rem_name, rem_text):
    """Is for creating new reminders in the db"""

    rem_text_trunc = rem_text[:max_reminder_len]
    rem_data = (
        rem_name,
        rem_text_trunc,
        str(int(time.time())),
        str(int(time.time())),
    )
    db.set_row(conn, 'reminders', rem_data)
    db.ccache()