Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed error with twitter API token #24

Merged
merged 3 commits into from
Aug 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 8 additions & 36 deletions plugins/general/bot/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,43 +53,15 @@ async def hs(self, ctx: MyContext, channel: nextcord.TextChannel = None):
await ctx.send(msg)

@commands.command(name="ping")
async def rep(self, ctx: MyContext, ip=None):
"""Get bot latency
You can also use this command to ping any other server"""
if ip is None:
m = await ctx.send("Ping...")
t = (m.created_at - ctx.message.created_at).total_seconds()
try:
p = round(self.bot.latency*1000)
except OverflowError:
p = "∞"
await m.edit(content=":ping_pong: Pong !\nBot ping: {}ms\nDiscord ping: {}ms".format(round(t*1000), p))
else:
asyncio.run_coroutine_threadsafe(
self.ping_adress(ctx, ip), asyncio.get_event_loop())

async def ping_adress(self, ctx: MyContext, ip: str):
packages = 30
wait = 0.3
async def rep(self, ctx: MyContext):
"""Get bot latency"""
m = await ctx.send("Ping...")
t = (m.created_at - ctx.message.created_at).total_seconds()
try:
try:
m = await ctx.send(f"Pinging {ip}...")
except:
m = None
t1 = time.time()
param = '-n' if system_name().lower() == 'windows' else '-c'
command = ['ping', param, str(packages), '-i', str(wait), ip]
result = system_call(command) == 0
except Exception as e:
await ctx.send("`Error:` {}".format(e))
return
if result:
t = (time.time() - t1 - wait*(packages-1))/(packages)*1000
await ctx.send(await self.bot._(ctx.channel, "general.ping-success", time=round(t, 2), ip=ip))
else:
await ctx.send(await self.bot._(ctx.channel, "general.ping-failed"))
if m is not None:
await m.delete()
p = round(self.bot.latency*1000)
except OverflowError:
p = "∞"
await m.edit(content=":ping_pong: Pong !\nBot ping: {}ms\nDiscord ping: {}ms".format(round(t*1000), p))

@commands.command(name="stats")
@commands.cooldown(2, 60, commands.BucketType.guild)
Expand Down
2 changes: 2 additions & 0 deletions plugins/rss/bot/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -965,6 +965,8 @@ async def rss_tw(self, channel: nextcord.TextChannel, name: str, date: datetime.
return await self.bot._(channel,"rss.nothing")
if 'Unknown error' in e.message:
return await self.bot._(channel,"rss.nothing")
if "The twitter.Api instance must be authenticated." in e.message:
return await self.bot._(channel,"rss.wrong-token")
if e.message[0]['code'] == 34:
return await self.bot._(channel,"rss.nothing")
raise e
Expand Down
1 change: 1 addition & 0 deletions plugins/rss/langs/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ en:
no-feed2: "This server has no rss feeds!"
no-roles: "No roles have been configured yet."
not-a-role: "This role cannot be found. Try again."
wrong-token: "Invalid twitter API token."
nothing: "I couldn't find anything on this search :confused:"
research-timeout: "The web page took too long to respond, I had to abort the process :eyes:"
roles-0: "This feed has been modified to mention roles {}"
Expand Down
1 change: 1 addition & 0 deletions plugins/rss/langs/fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ fr:
no-feed2: "Ce serveur ne possède aucun flux rss !"
no-roles: "Aucun rôle n'a été configuré pour l'instant."
not-a-role: "Ce rôle est introuvable. Réessayez :"
wrong-token: "Le token d'API Twitter n'est pas bon"
nothing: "Je n'ai rien trouvé sur cette recherche :confused:"
research-timeout: "La page web a mis trop de temps à répondre, j'ai dû interrompre le processus :eyes:"
roles-0: "Ce flux a bien été modifié pour mentionner les rôles {}"
Expand Down