diff --git a/.idea/Telegram-IP-CALC.iml b/.idea/Telegram-IP-CALC.iml
new file mode 100644
index 0000000..d0876a7
--- /dev/null
+++ b/.idea/Telegram-IP-CALC.iml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml
new file mode 100644
index 0000000..105ce2d
--- /dev/null
+++ b/.idea/inspectionProfiles/profiles_settings.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..dc9ea49
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..b4778dd
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..94a25f7
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
new file mode 100644
index 0000000..35f26e0
--- /dev/null
+++ b/.idea/workspace.xml
@@ -0,0 +1,201 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {
+ "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"
+ }
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1662478847997
+
+
+ 1662478847997
+
+
+
+
+
+
+
+
+
+
+ 1662545492088
+
+
+
+ 1662545492088
+
+
+ 1662545590298
+
+
+
+ 1662545590298
+
+
+ 1662661462393
+
+
+
+ 1662661462393
+
+
+ 1662887439537
+
+
+
+ 1662887439537
+
+
+ 1662898384606
+
+
+
+ 1662898384606
+
+
+ 1662934101339
+
+
+
+ 1662934101339
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ file://$PROJECT_DIR$/main.py
+ 52
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/config.py b/config.py
new file mode 100644
index 0000000..a23597f
--- /dev/null
+++ b/config.py
@@ -0,0 +1,2 @@
+
+TOKEN = '5631324818:AAEcOp7ZPzeSQReLk7rwnAT89n76ld05Jko' # bot token
\ No newline at end of file
diff --git a/main.py b/main.py
index 5715741..e4f4f0e 100644
--- a/main.py
+++ b/main.py
@@ -1,9 +1,53 @@
+import config
+import telebot
import ipaddress
-ip = input('Введите ip: ') # Пользователь вводит ip
+bot = telebot.TeleBot(config.TOKEN)
+@bot.message_handler(commands=['start'])
+def start(message):
+ bot.send_message(message.chat.id, 'Привет')
-list_ip = ip.split('/')
-ipv4 = ipaddress.ip_address(list_ip[0])
-print(ipv4)
-net = ipaddress.ip_network('192.168.10.0/24') # В функцию кладётся сетевая часть ip, без хостовой части
-print(net.netmask)
\ No newline at end of file
+def main(ip):
+ 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
+ print('HostMin:', net[1])
+ print('HostMax:', net[-2])
+ 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 по счёту в сети
+ break
+
+
+def subnets(ip, prefix):
+ subnet = ipaddress.ip_network(ip, strict=False)
+ list_subnet = list(subnet.subnets(new_prefix=int(prefix)))
+ subnet1 = ipaddress.ip_network(str(list_subnet[1]), strict=False)
+
+ print('\nМаска:', subnet1.netmask, '=', prefix)
+ print()
+
+ for i in list_subnet:
+ subnet2 = ipaddress.ip_network(i, strict=False)
+ print('Network:', subnet2)
+ print('Broadcast:', subnet2.broadcast_address)
+ print('HostMin:', subnet2[1])
+ print('HostMax:', subnet2[-2])
+ print('Hosts:', len(list((subnet2.hosts()))))
+ print()
+
+
+if __name__ == '__main__':
+ bot.polling(none_stop=True)
+ addr = input('Введите ip: ') # Пользователь вводит ip
+ main(addr)
+ # Тут должна быть кнопка типа "Подсети"
+ new_prefix = input('\nВведите префикс: ')
+ subnets(addr, new_prefix)
\ No newline at end of file