1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-23 19:44:20 +00:00

useful commit message here

This commit is contained in:
Steffo 2017-11-15 10:48:58 +01:00
parent c5d8f50603
commit 05f342bf89
WARNING! Although there is a key with this ID in the database it does not verify this commit! This commit is SUSPICIOUS.
GPG key ID: C27544372FBB445D
3 changed files with 12 additions and 14 deletions

12
bots.py
View file

@ -2,11 +2,15 @@ import multiprocessing
import telegrambot
import discordbot
discord_users_pipe = multiprocessing.Pipe()
discord = multiprocessing.Process(target=discordbot.process, args=(discord_users_pipe[0],))
telegram = multiprocessing.Process(target=telegrambot.process, args=(discord_users_pipe[1],))
discord_telegram_pipe = multiprocessing.Pipe()
discord = multiprocessing.Process(target=discordbot.process, args=(discord_telegram_pipe[0],), daemon=True)
telegram = multiprocessing.Process(target=telegrambot.process, args=(discord_telegram_pipe[1],), daemon=True)
if __name__ == "__main__":
discord.start()
telegram.start()
while True:
if discord.exitcode is not None:
print("Restarting Discord Bot...")
discord = multiprocessing.Process(target=discordbot.process, args=(discord_telegram_pipe[0],), daemon=True)
discord.start()

View file

@ -7,6 +7,7 @@ import sys
import db
import errors
import youtube_dl
import os
# Init the event loop
import asyncio
@ -55,12 +56,6 @@ class Video:
self.enqueued = enqueued
self.channel = channel
return self
def add_to_db(self, started):
db.CVMusic.create_and_add(url=self.info["webpage_url"],
user=self.user,
enqueued=self.enqueued,
started=started)
def create_embed(self):
embed = discord.Embed(type="rich",
@ -115,7 +110,7 @@ async def on_error(event, *args, **kwargs):
type, exception, traceback = sys.exc_info()
try:
await client.send_message(client.get_channel("368447084518572034"), f"☢️ ERRORE CRITICO NELL'EVENTO `{event}`\n"
f"Il bot si è chiuso per prevenire altri errori.\n\n"
f"Il bot si è chiuso e si dovrebbe riavviare entro qualche minuto.\n\n"
f"Dettagli dell'errore:\n"
f"```python\n"
f"{repr(exception)}\n"
@ -126,7 +121,8 @@ async def on_error(event, *args, **kwargs):
except Exception as e:
print("ERRORE CRITICO PIU' CRITICO:\n" + repr(e) + "\n" + repr(sys.exc_info()))
loop.stop()
sys.exit(1)
os._exit(1)
pass
@client.event

View file

@ -10,8 +10,6 @@ from discord import Status as DiscordStatus
# Init the config reader
import configparser
= u.idle()
config = configparser.ConfigParser()
config.read("config.ini")