Skip to content

Commit 1e5955c

Browse files
Merge pull request #127 from MasterCruelty/develop
🚀 Add /passport command
2 parents 6fc98f7 + d438672 commit 1e5955c

File tree

4 files changed

+36
-2
lines changed

4 files changed

+36
-2
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,8 @@ Le spiegazioni sono in Italiano, ma volendo si possono tradurre in qualsiasi lin
9999
* [Dog ceo api](https://dog.ceo/api/breeds/image/random)
100100
* [Random fox api](https://randomfox.ca/floof/)
101101
* [Free LaTeX api](https://latex.codecogs.com)
102-
* [Free api for random images](https://source.unsplash.com)
102+
* [Free api per immagini randomiche](https://source.unsplash.com)
103+
* [Sito web di Passport Index(scraping)](https://www.passportindex.org/)
103104

104105
# **[ENG]**
105106

@@ -182,3 +183,4 @@ This json file is only in Italian, but you can translate it in every languages b
182183
* [Random fox api](https://randomfox.ca/floof/)
183184
* [Free LaTeX api](https://latex.codecogs.com)
184185
* [Free api for random images](https://source.unsplash.com)
186+
* [Passport Index Web Site(scraping)](https://www.passportindex.org/)

help.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,5 +52,6 @@
5252
"animali": "**/cat ** => foto di un gatto.\n**/dog ** => foto di un cane.\n**/fox ** => foto di una volpe.\n**/rabbit ** => foto di un coniglio.\n**/bird ** => foto di un volatile.\n",
5353
"video": "**/yt url ** => restituisce il video scaricato da youtube.\n",
5454
"latex": "** /latex 'expression' ** => restituisce il LaTeX compilato.\n",
55-
"default": "Cerca un comando in particolare come ad esempio:\n /helprob wiki\n__Comandi: wiki, lyrics, covid, vaccine, weather, urban, poll, reminder, tper, atm, treni, kart, trivial, stats, terremoti, ral, animali, video e mappe.\n\ncomandi admin: **playlotto, getmessage, openai e pingrob.**\nVuoi usarli? Diventa un utente premium! Contatta @MasterCruelty__"
55+
"passaporti": "** /passport 'nation' ** => restituisce info basilari sul passaporto selezionato.\n",
56+
"default": "Cerca un comando in particolare come ad esempio:\n /helprob wiki\n__Comandi: wiki, lyrics, covid, vaccine, weather, urban, poll, reminder, tper, atm, treni, kart, trivial, stats, terremoti, ral, animali, video, latex, passaporti e mappe.\n\ncomandi admin: **playlotto, getmessage, openai e pingrob.**\nVuoi usarli? Diventa un utente premium! Contatta @MasterCruelty__"
5657
}

modules/passport.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
from utils.get_config import sendMessage,sendPhoto
2+
from pyrogram import Client,errors
3+
import requests
4+
from bs4 import BeautifulSoup
5+
import re
6+
7+
"""
8+
scapring di passportindex per ottenere info principali sulla potenza di un passaporto
9+
"""
10+
def get_passport_info(query,client,message):
11+
query = query.replace(" ","-")
12+
url = "https://passportindex.org/passport/" + query.lower() + "/"
13+
resp = requests.get(url)
14+
zuppa = BeautifulSoup(resp.text,"html.parser")
15+
tags = zuppa.find_all("div",attrs={"class":"hidden-sm hidden-lg hidden-md col-xs-8 text-left psprt-dashboard-info"})
16+
result = [tag.getText() for tag in tags if tag.getText() != ""]
17+
#estrapolo la stringa dal result
18+
result = ''.join(result).strip()
19+
#creo il pattern e il match per la regex per formattare la stringa
20+
pattern = r'(\w[\w\s-]+?)\s+(\d+[\d\s%]*)'
21+
matches = re.findall(pattern, result)
22+
final_string = '\n'.join(['{}: {}'.format(key.strip(), value.strip()) for key, value in matches])
23+
final_string = final_string.replace("Visa-free","Visa-free: ")
24+
try:
25+
imgtag = zuppa.find("div",attrs={"class": "psprt-dashboard-cover"}).find('img')
26+
except:
27+
return sendMessage(client,message,"__404: not found.__")
28+
img_url = imgtag['src']
29+
return sendPhoto(client,message,img_url,final_string)

utils/controller.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import modules.animals
2020
import modules.videodl
2121
import modules.latex
22+
import modules.passport
2223
import utils.dbfunctions as udb
2324
import utils.sysfunctions as usys
2425
import utils.get_config as ugc
@@ -60,6 +61,7 @@
6061
'/bird' : modules.animals.get_bird,
6162
'/yt' : modules.videodl.youtube_dl,
6263
'/latex' : modules.latex.get_latex,
64+
'/passport' : modules.passport.get_passport_info,
6365
'/helprob' : usys.help}
6466

6567
dictionary_admin = {'/getmessage' : usys.get_message,

0 commit comments

Comments
 (0)