diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a9f60f6 --- /dev/null +++ b/.gitignore @@ -0,0 +1,42 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +# C extensions +*.so +# Distribution / packaging +bin/ +build/ +develop-eggs/ +dist/ +eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +*.egg-info/ +.installed.cfg +*.egg +# Installer logs +pip-log.txt +pip-delete-this-directory.txt +# Unit test / coverage reports +.tox/ +.coverage +.cache +nosetests.xml +coverage.xml +# Translations +*.mo +# Mr Developer +.mr.developer.cfg +.project +.pydevproject +# Rope +.ropeproject +# Django stuff: +*.log +*.pot +# Sphinx documentation +docs/_build/ +config.json \ No newline at end of file diff --git a/.idea/Telegram-IP-CALC.iml b/.idea/Telegram-IP-CALC.iml index d0876a7..1432034 100644 --- a/.idea/Telegram-IP-CALC.iml +++ b/.idea/Telegram-IP-CALC.iml @@ -1,8 +1,10 @@ - - + + + + \ No newline at end of file diff --git a/.idea/copyright/SantaSpeen.xml b/.idea/copyright/SantaSpeen.xml new file mode 100644 index 0000000..d0a368b --- /dev/null +++ b/.idea/copyright/SantaSpeen.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index dc9ea49..ffe54b8 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,4 +1,4 @@ - + \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 35f26e0..827fdb2 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -5,8 +5,14 @@ + + + + - + + + - { - "keyToString": { - "ASKED_SHARE_PROJECT_CONFIGURATION_FILES": "true", - "RunOnceActivity.OpenProjectViewOnStart": "true", - "RunOnceActivity.ShowReadmeOnStart": "true", - "WebServerToolWindowFactoryState": "false", - "last_opened_file_path": "C:/Users/truno/Documents/GitHub/Telegram-IP-CALC", - "node.js.detected.package.eslint": "true", - "node.js.detected.package.tslint": "true", - "node.js.selected.package.eslint": "(autodetect)", - "node.js.selected.package.tslint": "(autodetect)", - "settings.editor.selected.configurable": "proofread" + +}]]> - - - - - file://$PROJECT_DIR$/main.py - 52 - - - - diff --git a/LICENSE b/LICENSE index fd4b0aa..e9b1e86 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,7 @@ MIT License Copyright (c) 2022 Marsh232 +Copyright (c) 2022 SantaSpeen Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 1a74cce..d433825 100644 --- a/README.md +++ b/README.md @@ -1 +1,4 @@ -# Telegram-IP-CALC \ No newline at end of file +# Telegram-IP-CALC + +Калькулятор для вычисления IP сетей. \ +Бот в телеграм: diff --git a/config.py b/config.py deleted file mode 100644 index a23597f..0000000 --- a/config.py +++ /dev/null @@ -1,2 +0,0 @@ - -TOKEN = '5631324818:AAEcOp7ZPzeSQReLk7rwnAT89n76ld05Jko' # bot token \ No newline at end of file diff --git a/main.py b/main.py index e4f4f0e..0b97ed3 100644 --- a/main.py +++ b/main.py @@ -1,28 +1,22 @@ -import config -import telebot import ipaddress -bot = telebot.TeleBot(config.TOKEN) -@bot.message_handler(commands=['start']) -def start(message): - bot.send_message(message.chat.id, 'Привет') def main(ip): - list_ip = ip.split('/') # Разделяет вводимый ip на часть с маской, и без - print('Ваш ip адрес:', ip) # Выводит например "Ваш ip адрес: 192.168.10.128/24" + list_ip = ip.split('/') # Разделяет вводимый ip на часть с маской, и без + print('Ваш ip адрес:', ip) # Выводит например "Ваш ip адрес: 192.168.10.128/24" - net = ipaddress.ip_network(ip, strict=False) # В функцию кладётся сетевая часть ip, без хостовой части - print('Маска:', net.netmask, '=', list_ip[1], '\n') # Выводит маску - print('Network:', net) # Выводит сеть - print('Broadcast:', net.broadcast_address) # Выводит broad + net = ipaddress.ip_network(ip, strict=False) # В функцию кладётся сетевая часть ip, без хостовой части + print('Маска:', net.netmask, '=', list_ip[1], '\n') # Выводит маску + print('Network:', net) # Выводит сеть + print('Broadcast:', net.broadcast_address) # Выводит broad print('HostMin:', net[1]) print('HostMax:', net[-2]) - print('Hosts:', len(list(net.hosts()))) # Выводит кол-во хостовых ip + print('Hosts:', len(list(net.hosts()))) # Выводит кол-во хостовых ip count = 0 for n_ip in net.hosts(): count += 1 if str(n_ip) == list_ip[0]: - print('№ в сети:', count) # Выводит какой ip по счёту в сети + print('№ в сети:', count) # Выводит какой ip по счёту в сети break @@ -45,9 +39,9 @@ def subnets(ip, prefix): if __name__ == '__main__': - bot.polling(none_stop=True) - addr = input('Введите ip: ') # Пользователь вводит ip + addr = input('Введите ip: ') # Пользователь вводит ip main(addr) + exit(0) # Тут должна быть кнопка типа "Подсети" new_prefix = input('\nВведите префикс: ') - subnets(addr, new_prefix) \ No newline at end of file + subnets(addr, new_prefix)