Skip to content

Commit

Permalink
Using correct user agent
Browse files Browse the repository at this point in the history
  • Loading branch information
guigoruiz1 authored and casperdcl committed Oct 28, 2024
1 parent b78efea commit 03b90e4
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions tqdm/contrib/discord.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@
from .utils_worker import MonoWorker
from ..version import __version__

__author__ = {"github.com/": ["casperdcl"]}
__author__ = {"github.com/": ["casperdcl","guigoruiz1"]}
__all__ = ["DiscordIO", "tqdm_discord", "tdrange", "tqdm", "trange"]


class DiscordIO(MonoWorker):
"""Non-blocking file-like IO using a Discord Bot."""

API = "https://discord.com/api/v10"
user_agent = f"TQDM Discord progress bar (https://tqdm.github.io, {__version__})"

def __init__(self, token, channel_id):
"""Creates a new message in the given `channel_id`."""
Expand All @@ -32,7 +33,7 @@ def message_id(self):
try:
headers = {
"Authorization": f"Bot {self.token}",
"User-Agent": f"TQDM Discord progress bar (http://github.com/tqdm/tqdm, {__version__})",
"User-Agent": self.user_agent,
}
data = {"content": "`" + self.text + "`"}
res = requests.post(
Expand Down Expand Up @@ -61,7 +62,7 @@ def write(self, s):
try:
headers = {
"Authorization": f"Bot {self.token}",
"User-Agent": f"TQDM Discord progress bar (http://github.com/tqdm/tqdm, {__version__})",
"User-Agent": self.user_agent,
}
data = {"content": "`" + s + "`"}
future = self.submit(
Expand All @@ -80,7 +81,7 @@ def delete(self):
try:
headers = {
"Authorization": f"Bot {self.token}",
"User-Agent": f"TQDM Discord progress bar (http://github.com/tqdm/tqdm, {__version__})",
"User-Agent": self.user_agent,
}
future = self.submit(
requests.delete,
Expand Down

0 comments on commit 03b90e4

Please sign in to comment.