Skip to content

Commit

Permalink
initial deployment fixes
Browse files Browse the repository at this point in the history
- fix anti_spam disable
- fix anti-spam error
- fix syntax & imports
- fix emoji error
  • Loading branch information
AEnterprise committed Mar 6, 2021
1 parent 9a0303b commit 4f70bd8
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 16 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ site/
.gradle/
logs/
*.json
!template.json
4 changes: 2 additions & 2 deletions GearBot/Cogs/AntiSpam.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import asyncio
import datetime
import re
from asyncio import CancelledError

import emoji
from asyncio.base_futures import CancelledError

import time
from collections import deque
Expand Down Expand Up @@ -323,7 +323,7 @@ async def censor_detector(self):
for b in buckets:
t = b["TYPE"]
if t == "censored":
msg_time = snowflake_time(message.id).time()
msg_time = int(snowflake_time(message.id).timestamp()) *1000
bucket = self.get_bucket(message.guild.id, f"censored:{count}", b, message.author.id)
if bucket is not None and await bucket.check(message.author.id, msg_time, 1, f"{message.channel.id}-{message.id}"):
count = await bucket.count(message.author.id, msg_time, expire=False)
Expand Down
2 changes: 1 addition & 1 deletion GearBot/Cogs/Emoji.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def cog_unload(self):
Pages.unregister("emoji")

async def cog_check (self, ctx):
return Permissioncheckers.check_permission(ctx.command, ctx.guild, ctx.author) or ctx.channel.permissions_for(ctx.author).manage_emojis
return hasattr(ctx.author, '_roles') and Permissioncheckers.check_permission(ctx.command, ctx.guild, ctx.author) or ctx.channel.permissions_for(ctx.author).manage_emojis

@commands.group(aliases=["emote"])
@commands.guild_only()
Expand Down
8 changes: 4 additions & 4 deletions GearBot/Cogs/ModLog.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ async def on_raw_message_delete(self, data: RawMessageDeleteEvent):
return
channel = self.bot.get_channel(message.channel)
name = Utils.clean_user(user) if hasUser else str(message.author)
time = Utils.to_pretty_time((datetime.datetime.utcnow() - snowflake_time(data.message_id)).total_seconds(), guild.id)
_time = Utils.to_pretty_time((datetime.datetime.utcnow() - snowflake_time(data.message_id)).total_seconds(), guild.id)
with_id = Configuration.get_var(guild.id, "MESSAGE_LOGS", "MESSAGE_ID")
GearbotLogging.log_key(guild.id, 'message_removed_with_id' if with_id else 'message_removed', name=name, user_id=user.id if hasUser else 'WEBHOOK', channel=channel.mention, message_id=data.message_id, time=time.strip())
GearbotLogging.log_key(guild.id, 'message_removed_with_id' if with_id else 'message_removed', name=name, user_id=user.id if hasUser else 'WEBHOOK', channel=channel.mention, message_id=data.message_id, time=_time.strip())
type_string = None
if message.type is not None:
if message.type == MessageType.new_member.value:
Expand Down Expand Up @@ -185,9 +185,9 @@ async def on_raw_message_edit(self, event: RawMessageUpdateEvent):
if after is None or after == "":
after = f"<{Translator.translate('no_content', channel.guild.id)}>"
if hasUser and user.id not in Configuration.get_var(channel.guild.id, "MESSAGE_LOGS", "IGNORED_USERS") and user.id != channel.guild.me.id:
time = Utils.to_pretty_time((datetime.datetime.utcnow() - snowflake_time(message.messageid)).total_seconds(), channel.guild.id)
_time = Utils.to_pretty_time((datetime.datetime.utcnow() - snowflake_time(message.messageid)).total_seconds(), channel.guild.id)
with_id = Configuration.get_var(channel.guild.id, "MESSAGE_LOGS", "MESSAGE_ID")
GearbotLogging.log_key(channel.guild.id, 'edit_logging_with_id' if with_id else 'edit_logging', user=Utils.clean_user(user), user_id=user.id, channel=channel.mention, message_id=message.messageid, time=time)
GearbotLogging.log_key(channel.guild.id, 'edit_logging_with_id' if with_id else 'edit_logging', user=Utils.clean_user(user), user_id=user.id, channel=channel.mention, message_id=message.messageid, time=_time.strip())
if Configuration.get_var(channel.guild.id, "MESSAGE_LOGS", "EMBED"):
embed = discord.Embed()
embed.set_author(name=user if hasUser else message.author,
Expand Down
4 changes: 2 additions & 2 deletions GearBot/Cogs/ServerAdmin.py
Original file line number Diff line number Diff line change
Expand Up @@ -1436,8 +1436,8 @@ async def set(self, ctx, type: SpamType, amount: RangedInt(3, 150), seconds: Ran
await ctx.send(f"{Emoji.get_chat_emoji('YES')} {Translator.translate('anti_spam_updated', ctx)}", embed=self.get_anti_spam_embed(ctx))


@anti_spam.command()
async def disable(self, ctx, type: SpamType):
@anti_spam.command("disable")
async def anti_spam_disable(self, ctx, type: SpamType):
existing = Configuration.get_var(ctx.guild.id, "ANTI_SPAM", "BUCKETS")
for i in range(0, len(existing)):
if existing[i]["TYPE"] == type:
Expand Down
2 changes: 1 addition & 1 deletion GearBot/GearBot.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import discord.http

discord.http.Route.BASE = 'http://http-proxy/api/v6'
# discord.http.Route.BASE = 'http://http-proxy/api/v6'

import os
from argparse import ArgumentParser
Expand Down
2 changes: 1 addition & 1 deletion GearBot/Util/Converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,6 @@ async def convert(self, ctx, argument):
class AntiSpamPunishment(Converter):
async def convert(self, ctx, argument):
if argument not in anti_spam_punishments:
raise TranslatedBadArgument('invalid_anti_spam_punisment', ctx, types=",".join(anti_spam_punishments))
raise TranslatedBadArgument('invalid_anti_spam_punishment', ctx, types=",".join(anti_spam_punishments))
return argument

2 changes: 1 addition & 1 deletion GearBot/Util/GearbotLogging.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"invite_censor_fail_edit": "WARNING",
"invite_censor_forbidden": "WARNING",
"invite_censor_forbidden_edit": "WARNING",
"censored_message_failed_content": "WARNING"
"censored_message_failed_content": "WARNING",
"censored_message_failed_content_edit": "WARNING"
},
"censored": {
Expand Down
8 changes: 4 additions & 4 deletions lang/en_US.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,16 +104,16 @@
"lang_changed": "Language has been set to {lang} ({lang_name}).",
"lang_unknown": "Sorry, I don't know that language yet.",
"mute_negative_denied": "How do you expect me to mute for {duration}? I'm not a time traveler!",
"message_removed": "Message by {name} (`{user_id}`) in {channel} has been removed. ({time} after being send)",
"message_removed_with_id": "Message `{message_id}` by {name} (`{user_id}`) in {channel} has been removed. ({time} after being send)",
"message_removed": "Message by {name} (`{user_id}`) in {channel} has been removed. ({time} after being sent)",
"message_removed_with_id": "Message `{message_id}` by {name} (`{user_id}`) in {channel} has been removed. ({time} after being sent)",
"no_content": "no content",
"no_content_embed": "*Empty message*.",
"sent_in": "Sent in {channel}",
"content": "**Content**: {content}",
"before": "Before",
"after": "After",
"edit_logging": "Message by {user} (`{user_id}`) in {channel} has been edited ({time} after being send).",
"edit_logging_with_id": "Message `{message_id}` by {user} (`{user_id}`) in {channel} has been edited ({time} after being send).",
"edit_logging": "Message by {user} (`{user_id}`) in {channel} has been edited ({time} after being sent).",
"edit_logging_with_id": "Message `{message_id}` by {user} (`{user_id}`) in {channel} has been edited ({time} after being sent).",
"days": "{amount, plural, one {1 day} other {# days}}",
"hours": "{hours, plural, one {1 hour} other {# hours}}, {minutes, plural, one {1 minute} other {# minutes}}",
"join_logging": "{user} (`{user_id}`) has joined, account created {age} ago.",
Expand Down

0 comments on commit 4f70bd8

Please sign in to comment.