summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorschneefux <schneefux+commit@schneefux.xyz>2016-12-03 14:20:49 +0100
committerschneefux <schneefux+commit@schneefux.xyz>2016-12-03 14:20:49 +0100
commit526740569b3ea61b5b3e655f743f111bd1910254 (patch)
tree200719e608cbbffa361d9cd2116531a5333787e3
parent5ffea4d9865d2a6642ba648d74ffb2e41e8f6e92 (diff)
downloadVainbot-526740569b3ea61b5b3e655f743f111bd1910254.tar.gz
Vainbot-526740569b3ea61b5b3e655f743f111bd1910254.zip
use logging module
-rw-r--r--main.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/main.py b/main.py
index ed33fc4..83d8b74 100644
--- a/main.py
+++ b/main.py
@@ -3,6 +3,7 @@ import pymongo
import discord
import asyncio
import threading
+import logging
import parsedatetime
import datetime
@@ -18,13 +19,10 @@ cli = discord.Client()
@cli.event
async def on_ready():
- print("Logged in as")
- print(cli.user.name)
- print(cli.user.id)
- print("-----")
+ log.warning("Logged in as " + cli.user.name + " (" + str(cli.user.id) + ")")
def cleanup():
- print("purging old data from database")
+ log.warning("purging old data from database")
now = datetime.datetime.utcnow()
db.usercache.remove({
"date": {"$lt": now - datetime.timedelta(minutes=30)}
@@ -72,7 +70,7 @@ async def search_teammates(who, query):
"end": end
})
- print(who.name + " requested a game " + ", ".join([str(d) for d in (start, end)]))
+ log.debug(who.name + " requested a game " + ", ".join([str(d) for d in (start, end)]))
players = []
for teammate in db.playwithme.find({"end": {"$gt": start, "$lt": end}}):
@@ -112,7 +110,7 @@ async def on_message(message):
#
if msg.startswith("\\getrole play"):
# toggles the "play" role
- print("toggled " + message.author.name + "'s play role")
+ log.debug("toggled " + message.author.name + "'s play role")
for role in message.author.roles:
if role.name == "play":
await cli.remove_roles(message.author, role)
@@ -125,5 +123,7 @@ async def on_message(message):
await cli.send_message(message.channel, "Added the 'play' role.")
if __name__ == '__main__':
+ logging.basicConfig()
+ log = logging.getLogger()
threading.Timer(10 * 60, cleanup).start()
cli.run(TOKEN)