Fixes to cleanup and fetch scripts

This commit is contained in:
Jeremy Zhang 2017-09-22 01:33:55 +00:00
parent 91f926bfe3
commit 495a08ea12
2 changed files with 8 additions and 5 deletions

View File

@ -89,7 +89,7 @@ class Titan(discord.Client):
d = session.query(Messages).filter(Messages.channel_id == chanid, ~Messages.id.in_(keep_these)).delete(synchronize_session=False) d = session.query(Messages).filter(Messages.channel_id == chanid, ~Messages.id.in_(keep_these)).delete(synchronize_session=False)
session.commit() session.commit()
print(" --{} [{}]".format(channel["name"], d)) print(" --{} [{}]".format(channel["name"], d))
d = session.query(Messages).filter(~Messages.channel_id.in_(active_channels)).delete(synchronize_session=False) d = session.query(Messages).filter(Messages.guild_id == guild.id, ~Messages.channel_id.in_(active_channels)).delete(synchronize_session=False)
session.commit() session.commit()
print(" INACTIVE {}".format(d)) print(" INACTIVE {}".format(d))
print("done!") print("done!")

View File

@ -69,10 +69,13 @@ class Titan(discord.Client):
print("working on this...") print("working on this...")
for channel in self.get_all_channels(): for channel in self.get_all_channels():
try:
if str(channel.type) == "text": if str(channel.type) == "text":
print("Processing channel: ID-{} Name-'{}' ServerID-{} Server-'{}'".format(channel.id, channel.name, channel.server.id, channel.server.name)) print("Processing channel: ID-{} Name-'{}' ServerID-{} Server-'{}'".format(channel.id, channel.name, channel.server.id, channel.server.name))
async for message in self.logs_from(channel, limit=50, reverse=True): async for message in self.logs_from(channel, limit=50, reverse=True):
await self.database.push_message(message) await self.database.push_message(message)
except:
continue
print("done!") print("done!")
await self.logout() await self.logout()