Skip to content

Commit

Permalink
Prevent roles from being mentioned via user-input (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
finlaysawyer committed Mar 22, 2021
1 parent f939895 commit e4a7e26
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## [1.2.1] - 2021-03-22

### Changed
- User commands like `ping` will now escape mentions, preventing the bot from using tagging roles.

## [1.2.0] - 2021-03-20

### Added
Expand Down Expand Up @@ -51,4 +56,5 @@
[1.0.0]: https://github.com/finlaysawyer/discord-uptime/compare/v0.0.1...v1.0.0
[1.0.1]: https://github.com/finlaysawyer/discord-uptime/compare/v1.0.0...v1.0.1
[1.1.0]: https://github.com/finlaysawyer/discord-uptime/compare/v1.0.1...v1.1.0
[1.2.0]: https://github.com/finlaysawyer/discord-uptime/compare/v1.1.1...v1.2.0
[1.2.0]: https://github.com/finlaysawyer/discord-uptime/compare/v1.1.1...v1.2.0
[1.2.1]: https://github.com/finlaysawyer/discord-uptime/compare/v1.2.0...v1.2.1
3 changes: 3 additions & 0 deletions cogs/ping.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import aiohttp
from discord.ext import commands
from discord.utils import escape_mentions
from ping3 import ping

from utils.config import get_config
Expand All @@ -21,6 +22,7 @@ async def ping(self, ctx, address: str, pings: int = 1) -> None:
:return: Delay in milliseconds or error
"""
timeout = get_config("timeout")
address = escape_mentions(address)

if ping(address, timeout=timeout) is False:
await ctx.send(f"Could not ping {address} - unknown host.")
Expand All @@ -46,6 +48,7 @@ async def http(self, ctx, address: str) -> None:
address = f"http://{address}"

timeout = get_config("timeout")
address = escape_mentions(address)

async with aiohttp.ClientSession(
timeout=aiohttp.ClientTimeout(total=timeout)
Expand Down

0 comments on commit e4a7e26

Please sign in to comment.