1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-27 13:34:28 +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 telegrambot
import discordbot import discordbot
discord_users_pipe = multiprocessing.Pipe() discord_telegram_pipe = multiprocessing.Pipe()
discord = multiprocessing.Process(target=discordbot.process, args=(discord_telegram_pipe[0],), daemon=True)
discord = multiprocessing.Process(target=discordbot.process, args=(discord_users_pipe[0],)) telegram = multiprocessing.Process(target=telegrambot.process, args=(discord_telegram_pipe[1],), daemon=True)
telegram = multiprocessing.Process(target=telegrambot.process, args=(discord_users_pipe[1],))
if __name__ == "__main__": if __name__ == "__main__":
discord.start() discord.start()
telegram.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 db
import errors import errors
import youtube_dl import youtube_dl
import os
# Init the event loop # Init the event loop
import asyncio import asyncio
@ -56,12 +57,6 @@ class Video:
self.channel = channel self.channel = channel
return self 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): def create_embed(self):
embed = discord.Embed(type="rich", embed = discord.Embed(type="rich",
title=self.info.get("title"), title=self.info.get("title"),
@ -115,7 +110,7 @@ async def on_error(event, *args, **kwargs):
type, exception, traceback = sys.exc_info() type, exception, traceback = sys.exc_info()
try: try:
await client.send_message(client.get_channel("368447084518572034"), f"☢️ ERRORE CRITICO NELL'EVENTO `{event}`\n" 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"Dettagli dell'errore:\n"
f"```python\n" f"```python\n"
f"{repr(exception)}\n" f"{repr(exception)}\n"
@ -126,7 +121,8 @@ async def on_error(event, *args, **kwargs):
except Exception as e: except Exception as e:
print("ERRORE CRITICO PIU' CRITICO:\n" + repr(e) + "\n" + repr(sys.exc_info())) print("ERRORE CRITICO PIU' CRITICO:\n" + repr(e) + "\n" + repr(sys.exc_info()))
loop.stop() loop.stop()
sys.exit(1) os._exit(1)
pass
@client.event @client.event

View file

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