mirror of
https://github.com/Marsh232/Telegram-IP-CALC.git
synced 2025-07-01 23:35:56 +00:00
commit
fd7e865b1a
8
.idea/Telegram-IP-CALC.iml
generated
Normal file
8
.idea/Telegram-IP-CALC.iml
generated
Normal file
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="PYTHON_MODULE" version="4">
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$" />
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
6
.idea/inspectionProfiles/profiles_settings.xml
generated
Normal file
6
.idea/inspectionProfiles/profiles_settings.xml
generated
Normal file
@ -0,0 +1,6 @@
|
||||
<component name="InspectionProjectProfileManager">
|
||||
<settings>
|
||||
<option name="USE_PROJECT_PROFILE" value="false" />
|
||||
<version value="1.0" />
|
||||
</settings>
|
||||
</component>
|
4
.idea/misc.xml
generated
Normal file
4
.idea/misc.xml
generated
Normal file
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.10" project-jdk-type="Python SDK" />
|
||||
</project>
|
8
.idea/modules.xml
generated
Normal file
8
.idea/modules.xml
generated
Normal file
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/Telegram-IP-CALC.iml" filepath="$PROJECT_DIR$/.idea/Telegram-IP-CALC.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
6
.idea/vcs.xml
generated
Normal file
6
.idea/vcs.xml
generated
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
201
.idea/workspace.xml
generated
Normal file
201
.idea/workspace.xml
generated
Normal file
@ -0,0 +1,201 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="AutoImportSettings">
|
||||
<option name="autoReloadType" value="SELECTIVE" />
|
||||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="56d3644b-12ed-4137-967a-9e3a3c12d93b" name="Changes" comment="Начал добовлять в телеграм 2">
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/config.py" beforeDir="false" afterPath="$PROJECT_DIR$/config.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.py" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
||||
<option name="LAST_RESOLUTION" value="IGNORE" />
|
||||
</component>
|
||||
<component name="FileTemplateManagerImpl">
|
||||
<option name="RECENT_TEMPLATES">
|
||||
<list>
|
||||
<option value="Python Script" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="Git.Settings">
|
||||
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
|
||||
</component>
|
||||
<component name="MarkdownSettingsMigration">
|
||||
<option name="stateVersion" value="1" />
|
||||
</component>
|
||||
<component name="ProjectId" id="2EOuFVd4WxG1srr507g2zfLzFMd" />
|
||||
<component name="ProjectLevelVcsManager" settingsEditedManually="true">
|
||||
<ConfirmationsSetting value="2" id="Add" />
|
||||
</component>
|
||||
<component name="ProjectViewState">
|
||||
<option name="hideEmptyMiddlePackages" value="true" />
|
||||
<option name="showLibraryContents" value="true" />
|
||||
</component>
|
||||
<component name="PropertiesComponent">{
|
||||
"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"
|
||||
}
|
||||
}</component>
|
||||
<component name="RunManager" selected="Python.main">
|
||||
<configuration name="main (2)" type="PythonConfigurationType" factoryName="Python" nameIsGenerated="true">
|
||||
<option name="INTERPRETER_OPTIONS" value="" />
|
||||
<option name="PARENT_ENVS" value="true" />
|
||||
<envs>
|
||||
<env name="PYTHONUNBUFFERED" value="1" />
|
||||
</envs>
|
||||
<option name="SDK_HOME" value="C:\Users\truno\AppData\Local\Programs\Python\Python310\python.exe" />
|
||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
|
||||
<option name="IS_MODULE_SDK" value="false" />
|
||||
<option name="ADD_CONTENT_ROOTS" value="true" />
|
||||
<option name="ADD_SOURCE_ROOTS" value="true" />
|
||||
<module name="" />
|
||||
<EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
|
||||
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/main.py" />
|
||||
<option name="PARAMETERS" value="" />
|
||||
<option name="SHOW_COMMAND_LINE" value="true" />
|
||||
<option name="EMULATE_TERMINAL" value="false" />
|
||||
<option name="MODULE_MODE" value="false" />
|
||||
<option name="REDIRECT_INPUT" value="false" />
|
||||
<option name="INPUT_FILE" value="" />
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
<configuration name="main" type="PythonConfigurationType" factoryName="Python" nameIsGenerated="true">
|
||||
<module name="Telegram-IP-CALC" />
|
||||
<option name="INTERPRETER_OPTIONS" value="" />
|
||||
<option name="PARENT_ENVS" value="true" />
|
||||
<envs>
|
||||
<env name="PYTHONUNBUFFERED" value="1" />
|
||||
</envs>
|
||||
<option name="SDK_HOME" value="C:\Users\truno\AppData\Local\Programs\Python\Python310\python.exe" />
|
||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
|
||||
<option name="IS_MODULE_SDK" value="false" />
|
||||
<option name="ADD_CONTENT_ROOTS" value="true" />
|
||||
<option name="ADD_SOURCE_ROOTS" value="true" />
|
||||
<EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
|
||||
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/main.py" />
|
||||
<option name="PARAMETERS" value="" />
|
||||
<option name="SHOW_COMMAND_LINE" value="false" />
|
||||
<option name="EMULATE_TERMINAL" value="true" />
|
||||
<option name="MODULE_MODE" value="false" />
|
||||
<option name="REDIRECT_INPUT" value="false" />
|
||||
<option name="INPUT_FILE" value="" />
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
<list>
|
||||
<item itemvalue="Python.main" />
|
||||
<item itemvalue="Python.main (2)" />
|
||||
</list>
|
||||
</component>
|
||||
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
|
||||
<component name="TaskManager">
|
||||
<task active="true" id="Default" summary="Default task">
|
||||
<changelist id="56d3644b-12ed-4137-967a-9e3a3c12d93b" name="Changes" comment="" />
|
||||
<created>1662478847997</created>
|
||||
<option name="number" value="Default" />
|
||||
<option name="presentableId" value="Default" />
|
||||
<updated>1662478847997</updated>
|
||||
<workItem from="1662478877356" duration="1804000" />
|
||||
<workItem from="1662485900255" duration="690000" />
|
||||
<workItem from="1662496666820" duration="3601000" />
|
||||
<workItem from="1662542574124" duration="3363000" />
|
||||
<workItem from="1662648763510" duration="5935000" />
|
||||
<workItem from="1662886058001" duration="5482000" />
|
||||
<workItem from="1662931348193" duration="2714000" />
|
||||
<workItem from="1662934797487" duration="309000" />
|
||||
</task>
|
||||
<task id="LOCAL-00001" summary="Add basic output">
|
||||
<created>1662545492088</created>
|
||||
<option name="number" value="00001" />
|
||||
<option name="presentableId" value="LOCAL-00001" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1662545492088</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00002" summary="hz">
|
||||
<created>1662545590298</created>
|
||||
<option name="number" value="00002" />
|
||||
<option name="presentableId" value="LOCAL-00002" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1662545590298</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00003" summary="add func subnets">
|
||||
<created>1662661462393</created>
|
||||
<option name="number" value="00003" />
|
||||
<option name="presentableId" value="LOCAL-00003" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1662661462393</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00004" summary="Add subnets">
|
||||
<created>1662887439537</created>
|
||||
<option name="number" value="00004" />
|
||||
<option name="presentableId" value="LOCAL-00004" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1662887439537</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00005" summary="Начал добовлять в телеграм">
|
||||
<created>1662898384606</created>
|
||||
<option name="number" value="00005" />
|
||||
<option name="presentableId" value="LOCAL-00005" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1662898384606</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00006" summary="Начал добовлять в телеграм 2">
|
||||
<created>1662934101339</created>
|
||||
<option name="number" value="00006" />
|
||||
<option name="presentableId" value="LOCAL-00006" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1662934101339</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="7" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="TypeScriptGeneratedFilesManager">
|
||||
<option name="version" value="3" />
|
||||
</component>
|
||||
<component name="Vcs.Log.Tabs.Properties">
|
||||
<option name="TAB_STATES">
|
||||
<map>
|
||||
<entry key="MAIN">
|
||||
<value>
|
||||
<State />
|
||||
</value>
|
||||
</entry>
|
||||
</map>
|
||||
</option>
|
||||
</component>
|
||||
<component name="VcsManagerConfiguration">
|
||||
<MESSAGE value="Add basic output" />
|
||||
<MESSAGE value="hz" />
|
||||
<MESSAGE value="add func subnets" />
|
||||
<MESSAGE value="Add subnets" />
|
||||
<MESSAGE value="Начал добовлять в телеграм" />
|
||||
<MESSAGE value="Начал добовлять в телеграм 2" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="Начал добовлять в телеграм 2" />
|
||||
</component>
|
||||
<component name="XDebuggerManager">
|
||||
<breakpoint-manager>
|
||||
<breakpoints>
|
||||
<line-breakpoint enabled="true" suspend="THREAD" type="python-line">
|
||||
<url>file://$PROJECT_DIR$/main.py</url>
|
||||
<line>52</line>
|
||||
<option name="timeStamp" value="1" />
|
||||
</line-breakpoint>
|
||||
</breakpoints>
|
||||
</breakpoint-manager>
|
||||
</component>
|
||||
<component name="com.intellij.coverage.CoverageDataManagerImpl">
|
||||
<SUITE FILE_PATH="coverage/Telegram_IP_CALC$main.coverage" NAME="main Coverage Results" MODIFIED="1662935064255" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
|
||||
</component>
|
||||
</project>
|
2
config.py
Normal file
2
config.py
Normal file
@ -0,0 +1,2 @@
|
||||
|
||||
TOKEN = '5631324818:AAEcOp7ZPzeSQReLk7rwnAT89n76ld05Jko' # bot token
|
56
main.py
56
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)
|
||||
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)
|
Loading…
x
Reference in New Issue
Block a user