Added telegram

This commit is contained in:
itdoginfo 2025-02-09 00:32:47 +03:00
parent 679b1bc98d
commit 024b2975f3
No known key found for this signature in database
GPG key ID: 4D49CCAC75E438EA

View file

@ -15,6 +15,7 @@ AS_META = '32934'
AS_TWITTER = '13414'
META = 'meta.lst'
TWITTER = 'twitter.lst'
TELEGRAM = 'telegram.lst'
# From https://iplist.opencck.org/
DISCORD_VOICE_V4='https://iplist.opencck.org/?format=text&data=cidr4&site=discord.gg&site=discord.media'
@ -22,6 +23,8 @@ DISCORD_VOICE_V6='https://iplist.opencck.org/?format=text&data=cidr6&site=discor
DISCORD = 'discord.lst'
TELEGRAM_CIDR_URL = 'https://core.telegram.org/resources/cidr.txt'
subnet_list = []
def subnet_summarization(subnet_list):
@ -76,6 +79,15 @@ def download_ready_subnets(url_v4, url_v6):
return ipv4_subnets, ipv6_subnets
def download_ready_split_subnets(url):
req = urllib.request.Request(url)
with urllib.request.urlopen(req) as response:
subnets = response.read().decode('utf-8').splitlines()
ipv4_subnets = [cidr for cidr in subnets if isinstance(ipaddress.ip_network(cidr, strict=False), ipaddress.IPv4Network)]
ipv6_subnets = [cidr for cidr in subnets if isinstance(ipaddress.ip_network(cidr, strict=False), ipaddress.IPv6Network)]
return ipv4_subnets, ipv6_subnets
def write_subnets_to_file(subnets, filename):
with open(filename, 'w') as file:
@ -111,6 +123,11 @@ if __name__ == '__main__':
write_subnets_to_file(ipv4_discord, f'{IPv4_DIR}/{DISCORD}')
write_subnets_to_file(ipv6_discord, f'{IPv6_DIR}/{DISCORD}')
# Telegram
ipv4_telegram, ipv6_telegram = download_ready_split_subnets(TELEGRAM_CIDR_URL)
write_subnets_to_file(ipv4_telegram, f'{IPv4_DIR}/{TELEGRAM}')
write_subnets_to_file(ipv6_telegram, f'{IPv6_DIR}/{TELEGRAM}')
# Legacy name
copy_file_legacy(f'{IPv4_DIR}/{META}')
copy_file_legacy(f'{IPv6_DIR}/{META}')