(topgg): Minor linting and wording changes.
This commit is contained in:
@@ -1,29 +1,30 @@
|
||||
import discord
|
||||
from .module import module
|
||||
from wards import guild_admin
|
||||
from bot.cmdClient.checks.global_perms import in_guild
|
||||
from bot.cmdClient.checks import in_guild, is_owner
|
||||
from settings.user_settings import UserSettings
|
||||
|
||||
from .webhook import on_dbl_vote
|
||||
from .utils import *
|
||||
from .utils import lion_loveemote
|
||||
|
||||
|
||||
@module.cmd(
|
||||
"forcevote",
|
||||
desc="Simulate Topgg Vote.",
|
||||
group="Guild Admin",
|
||||
aliases=('debugvote', 'topggvote')
|
||||
desc="Simulate a Topgg Vote from the given user.",
|
||||
group="Bot Admin",
|
||||
)
|
||||
@guild_admin()
|
||||
@is_owner()
|
||||
async def cmd_forcevote(ctx):
|
||||
"""
|
||||
Usage``:
|
||||
{prefix}forcevote
|
||||
Description:
|
||||
Simulate Topgg Vote without actually a confirmation from Topgg site.
|
||||
Simulate Top.gg vote without actually a confirmation from Topgg site.
|
||||
|
||||
Can be used for force a vote for testing or if topgg has an error or production time bot error.
|
||||
"""
|
||||
target = ctx.author
|
||||
|
||||
# Identify the target
|
||||
if ctx.args:
|
||||
if not ctx.msg.mentions:
|
||||
@@ -36,7 +37,7 @@ async def cmd_forcevote(ctx):
|
||||
|
||||
@module.cmd(
|
||||
"vote",
|
||||
desc="Get top.gg boost for 25% more LCs.",
|
||||
desc="[Vote](https://top.gg/bot/889078613817831495/vote) for me to get 25% more LCs!",
|
||||
group="Economy",
|
||||
aliases=('topgg', 'topggvote', 'upvote')
|
||||
)
|
||||
@@ -48,11 +49,12 @@ async def cmd_vote(ctx):
|
||||
Description:
|
||||
Get Top.gg bot's link for +25% Economy boost.
|
||||
"""
|
||||
target = ctx.author
|
||||
|
||||
embed=discord.Embed(
|
||||
embed = discord.Embed(
|
||||
title="Claim your boost!",
|
||||
description='Please click [here](https://top.gg/bot/889078613817831495/vote) vote and support our bot!\n\nThank you! {}.'.format(lion_loveemote),
|
||||
description=(
|
||||
"Please click [here](https://top.gg/bot/889078613817831495/vote) to vote and support our bot!\n\n"
|
||||
"Thank you! {}.".format(lion_loveemote)
|
||||
),
|
||||
colour=discord.Colour.orange()
|
||||
).set_thumbnail(
|
||||
url="https://cdn.discordapp.com/attachments/908283085999706153/933012309532614666/lion-love.png"
|
||||
|
||||
@@ -1,31 +1,30 @@
|
||||
from multiprocessing import context
|
||||
from LionModule import LionModule
|
||||
from LionContext import register_reply_callback, unregister_reply_callback
|
||||
from bot.data.conditions import NOT
|
||||
from meta.client import client
|
||||
from core.lion import Lion
|
||||
|
||||
from .utils import *
|
||||
from .utils import get_last_voted_timestamp, lion_loveemote, lion_yayemote
|
||||
from .webhook import init_webhook
|
||||
|
||||
module = LionModule("Topgg")
|
||||
|
||||
upvote_info = "You have a boost available {}, to support our project and earn **25% more LionCoins** type `{}vote` {}"
|
||||
|
||||
|
||||
@module.launch_task
|
||||
async def register_hook(client):
|
||||
init_webhook()
|
||||
register_reply_callback(reply)
|
||||
Lion.register_economy_bonus(economy_bonus)
|
||||
|
||||
client.log("Registered LionContext reply util hook.", context="Topgg" )
|
||||
client.log("Registered LionContext reply util hook.", context="Topgg")
|
||||
|
||||
|
||||
@module.unload_task
|
||||
async def unregister_hook(client):
|
||||
unregister_reply_callback(reply)
|
||||
Lion.unregister_economy_bonus(economy_bonus)
|
||||
|
||||
client.log("Unregistered LionContext reply util hook.", context="Topgg" )
|
||||
client.log("Unregistered LionContext reply util hook.", context="Topgg")
|
||||
|
||||
|
||||
def reply(util_func, *args, **kwargs):
|
||||
|
||||
@@ -4,7 +4,8 @@ from settings.setting_types import Boolean
|
||||
from modules.reminders.reminder import Reminder
|
||||
from modules.reminders.data import reminders
|
||||
|
||||
from .utils import *
|
||||
from .utils import create_remainder, remainder_content
|
||||
|
||||
|
||||
@UserSettings.attach_setting
|
||||
class topgg_vote_remainder(Boolean, UserSetting):
|
||||
|
||||
@@ -12,14 +12,20 @@ from . import data as db
|
||||
from data.conditions import GEQ
|
||||
|
||||
topgg_upvote_link = 'https://top.gg/bot/889078613817831495/vote'
|
||||
remainder_content = "You can now vote again on top.gg!\nClick [here]({}) to vote, thank you for the support!".format(topgg_upvote_link)
|
||||
remainder_content = (
|
||||
"You can now vote again on top.gg!\n"
|
||||
"Click [here]({}) to vote, thank you for the support!"
|
||||
).format(topgg_upvote_link)
|
||||
|
||||
lion_loveemote = '<:lionloveemote:933003977656795136>'
|
||||
lion_yayemote = '<:lionyayemote:933003929229352990>'
|
||||
|
||||
# Will return None if user has not voted in [-12.5hrs till now]
|
||||
# else will return a Tuple containing timestamp of when exactly she voted
|
||||
|
||||
def get_last_voted_timestamp(userid: Integer):
|
||||
"""
|
||||
Will return None if user has not voted in [-12.5hrs till now]
|
||||
else will return a Tuple containing timestamp of when exactly she voted
|
||||
"""
|
||||
return db.topggvotes.select_one_where(
|
||||
userid=userid,
|
||||
select_columns="boostedTimestamp",
|
||||
@@ -27,9 +33,12 @@ def get_last_voted_timestamp(userid: Integer):
|
||||
_extra="ORDER BY boostedTimestamp DESC LIMIT 1"
|
||||
)
|
||||
|
||||
# Checks if a remainder is already running (immaterial of remind_at time)
|
||||
# If no remainder exists creates a new remainder and schedules it
|
||||
|
||||
def create_remainder(userid):
|
||||
"""
|
||||
Checks if a remainder is already running (immaterial of remind_at time)
|
||||
If no remainder exists creates a new remainder and schedules it
|
||||
"""
|
||||
if not reminders.select_one_where(
|
||||
userid=userid,
|
||||
content=remainder_content,
|
||||
@@ -46,7 +55,11 @@ def create_remainder(userid):
|
||||
interval=None,
|
||||
title="Your boost is now available! {}".format(lion_yayemote),
|
||||
footer="Use `{}vote_reminder off` to stop receiving reminders.".format(client.prefix),
|
||||
remind_at=last_vote_time[0] + datetime.timedelta(hours=12.5) if last_vote_time else datetime.datetime.utcnow() + datetime.timedelta(minutes=5)
|
||||
remind_at=(
|
||||
last_vote_time[0] + datetime.timedelta(hours=12.5)
|
||||
if last_vote_time else
|
||||
datetime.datetime.utcnow() + datetime.timedelta(minutes=5)
|
||||
)
|
||||
# remind_at=datetime.datetime.utcnow() + datetime.timedelta(minutes=2)
|
||||
)
|
||||
|
||||
@@ -64,10 +77,13 @@ async def send_user_dm(userid):
|
||||
pass
|
||||
if user:
|
||||
try:
|
||||
embed=discord.Embed(
|
||||
embed = discord.Embed(
|
||||
title="Thank you for supporting our bot on Top.gg! {}".format(lion_yayemote),
|
||||
description="By voting every 12 hours you will allow us to reach and help even more students all over the world.\n \
|
||||
Thank you for supporting us, enjoy your LionCoins boost!",
|
||||
description=(
|
||||
"By voting every 12 hours you will allow us to reach and help "
|
||||
"even more students all over the world.\n"
|
||||
"Thank you for supporting us, enjoy your LionCoins boost!"
|
||||
),
|
||||
colour=discord.Colour.orange()
|
||||
).set_image(
|
||||
url="https://cdn.discordapp.com/attachments/908283085999706153/932737228440993822/lion-yay.png"
|
||||
|
||||
@@ -4,7 +4,8 @@ from utils.lib import utc_now
|
||||
from meta.config import conf
|
||||
|
||||
import topgg
|
||||
from .utils import *
|
||||
from .utils import db, send_user_dm, create_remainder
|
||||
|
||||
|
||||
@client.event
|
||||
async def on_dbl_vote(data):
|
||||
@@ -13,7 +14,7 @@ async def on_dbl_vote(data):
|
||||
|
||||
db.topggvotes.insert(
|
||||
userid=data['user'],
|
||||
boostedTimestamp = utc_now()
|
||||
boostedTimestamp=utc_now()
|
||||
)
|
||||
|
||||
await send_user_dm(data['user'])
|
||||
@@ -32,5 +33,8 @@ async def on_dbl_test(data):
|
||||
|
||||
|
||||
def init_webhook():
|
||||
client.topgg_webhook = topgg.WebhookManager(client).dbl_webhook(conf.bot.get("topgg_route"), conf.bot.get("topgg_password"))
|
||||
client.topgg_webhook = topgg.WebhookManager(client).dbl_webhook(
|
||||
conf.bot.get("topgg_route"),
|
||||
conf.bot.get("topgg_password")
|
||||
)
|
||||
client.topgg_webhook.run(conf.bot.get("topgg_port"))
|
||||
|
||||
Reference in New Issue
Block a user