First commit

This commit is contained in:
stef-devs 2022-06-16 20:22:48 +02:00
parent 79dea9d98e
commit 8a8eef766c
5 changed files with 169 additions and 0 deletions

BIN
ffmpeg.exe Normal file

Binary file not shown.

BIN
images/welcome.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 KiB

118
index.py
View File

@ -0,0 +1,118 @@
import psutil
import random
import pyfiglet
import socket
import threading
import datetime
import subprocess
import telebot
import time
import ast
import ffmpeg
import os
import requests
import python_weather
import asyncio
import requests
import json
from yt_dlp import YoutubeDL
from platform import system
from tqdm.auto import tqdm
from importlib.metadata import files
from dataclasses import dataclass
from jmespath import search
from telebot import types, telebot
from pytube import YouTube
from bs4 import BeautifulSoup
from gc import callbacks
API_TOKEN = '5407819601:AAEfiaw8ZNlyBHftLsJR5VAcMyv257tWHMY'
bot = telebot.TeleBot(API_TOKEN)
print("Il bot si è avviato con successo!")
#Command /start
@bot.message_handler(commands=['start'])
def send_welcome(message):
print("Triggered command START.")
#bot.send_photo(message.chat.id, photo='https://i.imgur.com/XqQZQ.jpg')
bot.reply_to(message, "😊 Benvenuto su **RetniNet**" "\n \nRetniNet è un bot privato per automatizzare e semplificare cose che facciamo quotidianamente. \n \n Creato & sviluppato da @Stef58_Official")
#Command /music
@bot.message_handler(commands=['music'])
def select_music(pm):
print("Triggered command MUSIC.")
ydl_opts = {
'format': 'bestaudio/best',
'postprocessors': [{
'key': 'FFmpegExtractAudio',
'preferredcodec': 'mp3',
'preferredquality': '192',
}],
}
sent_msg = bot.send_message(pm.chat.id, "Inserisci il link della canzone:")
bot.register_next_step_handler(sent_msg, music_step)
bot.send_message(pm.chat.id, "🎶 Stiamo scaricando la canzone attenda...")
def music_step(message):
ytdl_opts = {
'format': 'bestaudio/best',
'outtmpl': 'song.%(ext)s',
'postprocessors': [{
'key': 'FFmpegExtractAudio',
'preferredcodec': 'mp3',
'preferredquality': '192',
}],
}
url = message.text
video = url
with YoutubeDL(ytdl_opts) as ydl:
info = ydl.extract_info(url, download=False)
name = info.get('title')
id = info.get('id')
ydl.download([id])
bot.send_message(message.chat.id, "🎶" + name + " è stata scaricata con successo!")
send_music(message)
def send_music(message):
bot.send_audio(message.chat.id, audio=open('song.mp3', 'rb'))
os.remove('song.mp3')
#Command /meteo
@bot.message_handler(commands=['meteo'])
def meteo(pm):
print("Triggered command METEO.")
sent_msg = bot.send_message(pm.chat.id, "Inserisci la città:")
bot.register_next_step_handler(sent_msg, meteo_step)
def meteo_step(message):
city = message.text
response = requests.get("https://api.openweathermap.org/data/2.5/weather?q="+city+",it&APPID=dd9c01763daea0b5539db05fbfbe4cb6").json()
weather = response['weather'][0]['main']
temp = response['main']['temp']
temp = temp - 273.15
bot.send_message(message.chat.id, "🌡️ La temperatura in " + city + " è di " + str(temp) + "°C")
bot.send_message(message.chat.id, "🌧️ La condizione è " + weather)
#Command /stats
@bot.message_handler(commands=['stats'])
def uptime(message):
print("Triggered command STATS.")
cpuUsage = psutil.cpu_percent(interval=1)
ramTotal = int(psutil.virtual_memory().total/(1024*1024)) #GB
ramUsage = int(psutil.virtual_memory().used/(1024*1024)) #GB
ramFree = int(psutil.virtual_memory().free/(1024*1024)) #GB
ramUsagePercent = psutil.virtual_memory().percent
msg = '''
CPU & RAM Info
Utilizzo CPU = {} %
RAM
Totale = {} MB
Usato = {} MB
Libero = {} MB
In uso = {} %\n'''.format(cpuUsage,ramTotal,ramUsage,ramFree,ramUsagePercent)
bot.send_message(message.chat.id,msg)
bot.polling()

34
requirements.txt Normal file
View File

@ -0,0 +1,34 @@
# Automatically generated by https://github.com/damnever/pigar.
# D:\Progetti Github\RetniNet\index.py: 26
bs4 == 0.0.1
# D:\Progetti Github\RetniNet\index.py: 23
jmespath == 1.0.0
# D:\Progetti Github\RetniNet\index.py: 1
psutil == 5.9.1
# D:\Progetti Github\RetniNet\index.py: 3
pyfiglet == 0.8.post1
# D:\Progetti Github\RetniNet\index.py: 11
python_ffmpeg == 1.0.14
# D:\Progetti Github\RetniNet\index.py: 14
python_weather == 0.3.7
# D:\Progetti Github\RetniNet\index.py: 25
pytube == 12.1.0
# D:\Progetti Github\RetniNet\index.py: 13,16
requests == 2.25.1
# D:\Progetti Github\RetniNet\index.py: 24
telebot == 0.0.4
# D:\Progetti Github\RetniNet\index.py: 20
tqdm == 4.64.0
# D:\Progetti Github\RetniNet\index.py: 18
yt_dlp == 2022.5.18

17
test.py Normal file
View File

@ -0,0 +1,17 @@
import EpicGamesStoreAPI as api
api = EpicGamesStoreAPI()
namespace, slug = list(api.get_product_mapping().items())[0]
first_product = api.get_product(slug)
offers = []
for page in first_product['pages']:
if page.get('offer') is not None:
offers.append(OfferData(page['namespace'], page['offer']['id']))
offers_data = api.get_offers_data(*offers)
for offer_data in offers_data:
data = offer_data['data']['Catalog']['catalogOffer']
developer_name = ''
for custom_attribute in data['customAttributes']:
if custom_attribute['key'] == 'developerName':
developer_name = custom_attribute['value']
print('Offer ID:', data['id'], '\nDeveloper Name:', developer_name)