update
This commit is contained in:
parent
ca5938bddb
commit
0cca756b94
7
bash/kill_switch_off.sh
Normal file
7
bash/kill_switch_off.sh
Normal file
|
@ -0,0 +1,7 @@
|
|||
#!/bin/bash
|
||||
|
||||
echo "y" | sudo ufw enable
|
||||
sudo ufw default deny incoming
|
||||
sudo ufw default allow outgoing
|
||||
sudo ufw enable
|
||||
notify-send 'Kill-switch OFF' 'Maybe, maybe not, or maybe fuck off' --icon=dialog-information
|
8
bash/kill_switch_on.sh
Normal file
8
bash/kill_switch_on.sh
Normal file
|
@ -0,0 +1,8 @@
|
|||
#!/bin/bash
|
||||
|
||||
echo "y" | sudo ufw enable
|
||||
sudo ufw default deny incoming
|
||||
sudo ufw default deny outgoing
|
||||
sudo ufw allow out on tun0 from any to any
|
||||
sudo ufw enable
|
||||
notify-send 'Kill-switch ON' 'Maybe, maybe not, or maybe fuck off' --icon=dialog-information
|
106
other/bot-for-navalnycom.py
Normal file
106
other/bot-for-navalnycom.py
Normal file
|
@ -0,0 +1,106 @@
|
|||
from aiohttp import ClientSession
|
||||
from logging import basicConfig, DEBUG
|
||||
|
||||
from aiogram import executor
|
||||
from aiogram import Bot, Dispatcher
|
||||
from aiogram.types import ParseMode
|
||||
from aiogram.types import Message, CallbackQuery
|
||||
from aiogram.types import InlineKeyboardMarkup, InlineKeyboardButton
|
||||
from aiogram.dispatcher.filters import CommandStart
|
||||
|
||||
|
||||
API_URL = "https://free.navalny.com/api/v1/maps/counters/"
|
||||
|
||||
BOT_TOKEN = "token"
|
||||
BOT_OWNER = [id]
|
||||
|
||||
bot = Bot(token=BOT_TOKEN, parse_mode=ParseMode.HTML)
|
||||
dp = Dispatcher(bot)
|
||||
|
||||
|
||||
async def on_startup_notify(dp: Dispatcher):
|
||||
for i in BOT_OWNER:
|
||||
await bot.send_message(i, "started.")
|
||||
|
||||
|
||||
def create_session():
|
||||
"""
|
||||
Создание новой сессии
|
||||
"""
|
||||
return ClientSession(
|
||||
headers={
|
||||
"User-Agent": "bot"
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
|
||||
async def get_count():
|
||||
|
||||
session = create_session()
|
||||
|
||||
response = await session.get(API_URL)
|
||||
query = await response.json()
|
||||
await session.close()
|
||||
|
||||
return int(query["persons"])
|
||||
|
||||
|
||||
def get_keyboard():
|
||||
|
||||
markup = InlineKeyboardMarkup()
|
||||
|
||||
markup.add(
|
||||
InlineKeyboardButton(
|
||||
text="Обновить", callback_data="update_info"
|
||||
)
|
||||
)
|
||||
|
||||
return markup
|
||||
|
||||
|
||||
|
||||
@dp.message_handler(CommandStart())
|
||||
async def check_count_of_members(message: Message):
|
||||
|
||||
count = await get_count()
|
||||
|
||||
await message.reply(
|
||||
text=(
|
||||
f"Количество участников акции: <b>{count}</b>"
|
||||
),
|
||||
reply_markup=get_keyboard()
|
||||
)
|
||||
|
||||
|
||||
|
||||
@dp.callback_query_handler(text="update_info")
|
||||
async def update_info(call: CallbackQuery):
|
||||
|
||||
message = call.message
|
||||
|
||||
new_count = await get_count()
|
||||
old_count = int(message.text.split()[3])
|
||||
|
||||
if old_count == new_count:
|
||||
return await call.answer(
|
||||
text=(
|
||||
"Количество участников не изменилось"
|
||||
),
|
||||
show_alert=True
|
||||
)
|
||||
|
||||
await message.edit_text(
|
||||
text=(
|
||||
f"Количество участников акции: <b>{new_count}</b>"
|
||||
f"\nСтало больше на: {new_count - old_count}"
|
||||
),
|
||||
reply_markup=get_keyboard()
|
||||
)
|
||||
|
||||
await call.answer()
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
executor.start_polling(dp, on_startup=on_startup_notify)
|
23
other/count-tests.py
Normal file
23
other/count-tests.py
Normal file
|
@ -0,0 +1,23 @@
|
|||
##################################### Первый способ:
|
||||
|
||||
A = [10, 10, 23, 10, 123, 66, 78, 123]
|
||||
counter = {}
|
||||
|
||||
for elem in A:
|
||||
counter[elem] = counter.get(elem, 0) + 1
|
||||
|
||||
doubles = {element: count for element, count in counter.items() if count > 1}
|
||||
|
||||
print(doubles)
|
||||
|
||||
##################################### Второй способ:
|
||||
|
||||
from collections import Counter
|
||||
counter = Counter(A)
|
||||
|
||||
##################################### Третий способ:
|
||||
|
||||
from collections import defaultdict
|
||||
counter = defaultdict(int)
|
||||
for elem in A:
|
||||
counter[elem] += 1
|
29
other/main.py
Normal file
29
other/main.py
Normal file
|
@ -0,0 +1,29 @@
|
|||
unique = []
|
||||
text = "Вышел зайчик зайчик на крыльцо на крыльцо"
|
||||
|
||||
|
||||
words = text.split(' ') # старый
|
||||
newords = [] #
|
||||
|
||||
|
||||
|
||||
count = 0
|
||||
print('\nStart words list:\n', words, '\n')
|
||||
|
||||
|
||||
for w in words:
|
||||
if w in unique and len(w) > 4:
|
||||
count += 1
|
||||
#print(f'Слово {w} повторяется, позиция:', words.index(w))
|
||||
ind = words.index(w)
|
||||
print(f'Clone: {w} / index:', ind)
|
||||
#newords.insert(ind, count)
|
||||
newords.append(count)
|
||||
|
||||
|
||||
|
||||
else:
|
||||
unique.append(w)
|
||||
newords.append(w)
|
||||
|
||||
print('\nNew words list:\n', newords, '\n')
|
Reference in a new issue