From c220b5b5908e2dfe05f67ed4e470020b209b7470 Mon Sep 17 00:00:00 2001 From: matnad Date: Mon, 11 Feb 2019 14:40:40 +0100 Subject: [PATCH] migration prep --- changelog.md | 45 ++++++++++++++++++++ cogs/poll.py | 18 +++++--- cogs/poll_controls.py | 11 ++--- pollmaster.py | 23 +++++++++-- utils/import_old_database.py | 79 ++++++++++++++++++++++++++++++++++++ utils/paginator.py | 4 +- 6 files changed, 165 insertions(+), 15 deletions(-) create mode 100644 changelog.md create mode 100644 utils/import_old_database.py diff --git a/changelog.md b/changelog.md new file mode 100644 index 0000000..cd413cd --- /dev/null +++ b/changelog.md @@ -0,0 +1,45 @@ +# Changelog for Version 2.0 + +## TL;DR +- Poll creation now interactive +- New prefix: **pm!** (can be customized) +- All commands and roles have been changed, check **pm!help** + +## Complete Overhaul +- Voting is no longer done per text, but by using reactions +- Poll creation has been streamlined and is now interactive +- An exhaustive pm!help function + +## New features +- Prepare polls in advance and schedule them or activate them on demand +- A quick poll function with default settings +- Multiple Choice as new settings (allow more than one answer) + +## Full Private Message and Multi Server Support +- **Every command can be used in private messages with pollmaster** +- This works even if you are in many servers with the bot +- Context sensitive detection of which server(s) are affected +- Promt the user for a server if still ambiguous + +## New Look +- Complete visual overhaul for every aspect +- New custom icons + +## New Database +- Changed the way all the polls are stored +- Added server specific configurations + +## New Prefix +- **pm!** is the new default prefix +- Prefix can be customized for each server + +## New roles and permissions +- Users with "Manage Server" permissions can now use all functions regardless of pollmaster specific permissions +- Two new type of roles: *polladmin* and *polluser* +- They can be set with *!polladmin role* and *!polluser role* +- More infos pm!help -> configuration +- The *pollmaster* role is deprecated + +## Compability +- Most databases will be preserved and converted to the new format +- If your server lost data, please join the support server or contact the developer \ No newline at end of file diff --git a/cogs/poll.py b/cogs/poll.py index a09746f..a9183c1 100644 --- a/cogs/poll.py +++ b/cogs/poll.py @@ -705,10 +705,18 @@ class Poll: async def to_dict(self): + if self.channel is None: + cid = 0 + else: + cid = self.channel.id + if self.author is None: + aid = 0 + else: + aid = self.author.id return { 'server_id': str(self.server.id), - 'channel_id': str(self.channel.id), - 'author': str(self.author.id), + 'channel_id': str(cid), + 'author': str(aid), 'name': self.name, 'short': self.short, 'anonymous': self.anonymous, @@ -827,9 +835,9 @@ class Poll: return None async def from_dict(self, d): - self.server = self.bot.get_server(d['server_id']) - self.channel = self.bot.get_channel(d['channel_id']) - self.author = await self.bot.get_user_info(d['author']) + self.server = self.bot.get_server(str(d['server_id'])) + self.channel = self.bot.get_channel(str(d['channel_id'])) + self.author = await self.bot.get_user_info(str(d['author'])) self.name = d['name'] self.short = d['short'] self.anonymous = d['anonymous'] diff --git a/cogs/poll_controls.py b/cogs/poll_controls.py index 5f8592d..0a535be 100644 --- a/cogs/poll_controls.py +++ b/cogs/poll_controls.py @@ -215,7 +215,8 @@ class PollControls: query = self.bot.db.polls.find({'server_id': str(server.id), 'active': False}) if query is not None: - polls = [poll async for poll in query] + # sort by newest first + polls = [poll async for poll in query.sort('_id', -1)] else: return @@ -228,9 +229,9 @@ class PollControls: # await self.bot.say(embed=await self.embed_list_paginated(polls, item_fct, embed)) # msg = await self.embed_list_paginated(ctx, polls, item_fct, embed, per_page=8) pre = await get_server_pre(self.bot, server) - footer_text = '' # f'type {pre}show