Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified __pycache__/config.cpython-312.pyc
Binary file not shown.
Binary file modified __pycache__/main.cpython-312.pyc
Binary file not shown.
11 changes: 11 additions & 0 deletions app.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
2024-02-12 22:56:37,219 - INFO - Start polling
2024-02-12 22:56:37,290 - INFO - Run polling for bot @ibuywork_bot id=6681002925 - 'IBuyWork'
2024-02-12 22:56:47,440 - INFO - Update id=502700407 is handled. Duration 468 ms by bot id=6681002925
2024-02-12 22:56:50,888 - INFO - Update id=502700408 is handled. Duration 156 ms by bot id=6681002925
2024-02-12 22:56:51,669 - INFO - Update id=502700409 is handled. Duration 218 ms by bot id=6681002925
2024-02-12 22:56:52,423 - INFO - Update id=502700410 is handled. Duration 141 ms by bot id=6681002925
2024-02-12 22:56:54,359 - INFO - Update id=502700411 is handled. Duration 171 ms by bot id=6681002925
2024-02-12 22:57:10,185 - INFO - Update id=502700412 is handled. Duration 266 ms by bot id=6681002925
2024-02-12 22:57:18,491 - INFO - Update id=502700413 is handled. Duration 125 ms by bot id=6681002925
2024-02-12 22:57:19,646 - INFO - Update id=502700414 is handled. Duration 93 ms by bot id=6681002925
2024-02-12 22:57:21,134 - INFO - Update id=502700415 is handled. Duration 250 ms by bot id=6681002925
2 changes: 1 addition & 1 deletion app/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from app import general_hd
from app import general_hd, upload_account2
Binary file modified app/__pycache__/__init__.cpython-312.pyc
Binary file not shown.
Binary file modified app/__pycache__/general_hd.cpython-312.pyc
Binary file not shown.
Binary file modified app/__pycache__/upload_account.cpython-312.pyc
Binary file not shown.
Binary file modified app/__pycache__/upload_account2.cpython-312.pyc
Binary file not shown.
4 changes: 0 additions & 4 deletions app/general_hd.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@







@router.callback_query(Menu_callback.filter(F.menu == 'menu'))
async def menu(call: CallbackQuery, callback_data: Menu_callback, state: FSMContext):
try:
Expand Down
Binary file modified app/posting/__pycache__/spam.cpython-312.pyc
Binary file not shown.
36 changes: 32 additions & 4 deletions app/posting/spam.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@


from data import users, chats
from config import API_ID, API_HASH, PROXY, API_TOKEN
from config import API_ID, API_HASH, API_TOKEN
from app.upload_account2 import get_random_proxy

async def join_and_send_message(client, link, text, user_id, account):
try:
Expand All @@ -27,9 +28,11 @@ async def join_and_send_message(client, link, text, user_id, account):
if status == '🟢':
await send(error=f'Спамблок: {account}', user_id=user_id)
return
except UnboundLocalError as e:
pass
except Exception as e:
if status == '🟢':
await send(error=f'Ошибка при вступлении в чат: {account}', user_id=user_id)
await send(error=f'Ошибка при вступлении в чат: {e} \n\n {account}:{link}', user_id=user_id)
return

amount = send_messages + 1
Expand All @@ -44,12 +47,36 @@ async def join_and_send_message(client, link, text, user_id, account):

try:
await client.send_message(chat.id, text)

except errors.FloodWait as e:
if status == '🟢':
await send(error=f'Спамблок: {account}', user_id=user_id)
return

except UnboundLocalError as e:
pass

except errors.SlowmodeWait as e:
if status == '🟢':
await send(error=f'SLOW_MODE: \n\n {account}:{link}', user_id=user_id)
return

except errors.UserBannedInChannel as e:
if status == '🟢':
await send(error=f'USER_BANNED_IN_CHANNEL: \n\n {account}:{link}', user_id=user_id)
chats_link = await chats.get_chats(account)
chats_link.remove(link)
await chats.update_account_chats(account, chats_link)
return

except errors.PeerIdInvalid as e:
if status == '🟢':
await send(error=f'Невозможно вступить в чат: \n\n {account}:{link}', user_id=user_id)
chats_link = await chats.get_chats(account)
chats_link.remove(link)
await chats.update_account_chats(account, chats_link)
return

except Exception as e:
if status == '🟢':
await send(error=f'Ошибка при вступлении в чат: {e} \n\n {account}:{link}', user_id=user_id)
Expand All @@ -59,7 +86,7 @@ async def join_and_send_message(client, link, text, user_id, account):
await users.update_messages(user_id, amount)
print(f"Сообщение отправлено в чат {link}")
except Exception as e:
print(f'Ошибка при отправке сообщения в чат {link}: {e}')
print(f'Ошибка при отправке сообщения в чат {link} на аккаунте {account}\n\n Ошибка:{e}')



Expand Down Expand Up @@ -101,7 +128,8 @@ async def spamming(client, user_id, text, account):
async def main(account_file, user_id, text, account):
status = (await users.user_profile(user_id))[8]
try:
async with Client(account_file, API_ID, API_HASH, proxy=PROXY) as client:
proxy = get_random_proxy()
async with Client(account_file, API_ID, API_HASH, proxy=proxy) as client:
await spamming(client, user_id, text, account)

except errors.Unauthorized as e:
Expand Down
35 changes: 31 additions & 4 deletions app/upload_account2.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import os
import os, random

from aiogram import Router, F
from aiogram.types import Message, CallbackQuery
from aiogram.fsm.state import StatesGroup, State
from aiogram.fsm.context import FSMContext

from keyboards.client import Menu_callback, k_work_menu, cancel_upl, k_menu
from data import chats, users
from config import API_ID, API_HASH, PROXY
from data import chats, users, admin
from config import API_ID, API_HASH

from pyrogram import Client, filters
from pyrogram.errors import (
Expand All @@ -31,6 +31,32 @@ class Acc(StatesGroup):





def get_random_proxy():
proxies = admin.get_proxies()
if proxies:
proxy = random.choice(proxies)
parts = proxy.split("@")
login_pass = parts[0].split(":")
login = login_pass[0]
password = login_pass[1] if len(login_pass) > 1 else ""
ip_port = parts[1].split(":")
ip = ":".join(ip_port[:-1])
port = ip_port[-1]

PROXY = {
"scheme": "socks5",
"hostname": ip,
"port": int(port),
"username": login,
"password": password
}

return PROXY



@router.callback_query(Menu_callback.filter(F.menu == 'upl_acc_method_2'))
async def update_account(call: CallbackQuery, callback_data: Menu_callback, state: FSMContext):
await state.set_state(Acc.number)
Expand All @@ -51,7 +77,8 @@ async def set_number(message: Message, state: FSMContext):

path = f"app/posting/{user_id}/{filename[:-8]}"
print('path', path)
client = Client(path, API_ID, API_HASH)
proxy = get_random_proxy()
client = Client(path, API_ID, API_HASH, proxy=proxy)
await client.connect()
try:
code = await client.send_code(phone_number)
Expand Down
Binary file modified app/work_menu/__pycache__/menu_wk.cpython-312.pyc
Binary file not shown.
25 changes: 1 addition & 24 deletions config.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from aiogram import Bot
from data.admin import get_proxy


API_TOKEN = '6708966085:AAH8DAOulSOhLHjn6rlL40_MZjcAKekWs9g'
Expand All @@ -13,26 +12,4 @@
API_HASH = '7033098f253c5266cc2311fc9a09fab9'


def parse_proxy_string():
proxy_string = get_proxy()
parts = proxy_string.split("@")
login_pass = parts[0].split(":")
login = login_pass[0]
password = login_pass[1] if len(login_pass) > 1 else ""
ip_port = parts[1].split(":")
ip = ":".join(ip_port[:-1])
port = ip_port[-1]

return (login, password, ip, port)

proxy = parse_proxy_string()

PROXY = {
"scheme": "socks5",
"hostname": proxy[2],
"port": int(proxy[3]),
"username": proxy[0],
"password": proxy[1]
}

bot = Bot(token=API_TOKEN, parse_mode='HTML')
bot = Bot(token=API_TOKEN, parse_mode='HTML')
Binary file modified data/__pycache__/admin.cpython-312.pyc
Binary file not shown.
Binary file modified data/__pycache__/chats.cpython-312.pyc
Binary file not shown.
57 changes: 35 additions & 22 deletions data/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,39 +65,52 @@ def add_proxy(proxy):
print("Соединение с SQLite закрыто")


def get_proxy():
def update_proxy(proxy):
try:
sqlite_connection = sqlite3.connect('data/base/base.db')
sqlite_connection = sqlite3.connect("data/base/base.db")
cursor = sqlite_connection.cursor()

sqlite_selection_query = "SELECT proxy FROM proxies;"
cursor.execute(sqlite_selection_query)
count = cursor.fetchone()[0]

cursor.close()
return count
sqlite_selection_query = "UPDATE proxies SET proxy=? WHERE id=1;"
cursor.execute(sqlite_selection_query, (proxy,))
sqlite_connection.commit()

except sqlite3.Error as error:
print("Ошибка при подключении к SQLite", error)
return None

print("Не удалось изменить данные из таблицы.", error)
finally:
if sqlite_connection:
sqlite_connection.close()
print("Соединение с SQLite закрыто")


def update_proxy(proxy):
try:
sqlite_connection = sqlite3.connect("data/base/base.db")
cursor = sqlite_connection.cursor()

sqlite_selection_query = "UPDATE proxies SET proxy=? WHERE id=1;"
cursor.execute(sqlite_selection_query, (proxy,))
sqlite_connection.commit()
def get_proxies():
proxies = []

try:
connection = sqlite3.connect('data/base/base.db')
cursor = connection.cursor()
cursor.execute("SELECT proxy FROM proxies WHERE id=1;")
rows = cursor.fetchall() # Получаем все строки
for row in rows:
for proxy in row[0].split('\n'):
proxy = proxy.strip()
if proxy:
proxies.append(proxy)

except sqlite3.Error as error:
print("Не удалось изменить данные из таблицы.", error)
print("Не удалось получить прокси-серверы из базы данных.", error)

finally:
if sqlite_connection:
sqlite_connection.close()
if connection:
try:
connection.close()
except sqlite3.Error as close_error:
print("Ошибка при закрытии соединения с базой данных.", close_error)
return proxies

# pro = '''K3aT1rGA:SHCTiUED@166.1.143.161:64019
# K3aT1rGA:SHCTiUED@166.1.145.76:63611
# K3aT1rGA:SHCTiUED@166.1.146.244:63169
# K3aT1rGA:SHCTiUED@166.1.147.12:63915
# K3aT1rGA:SHCTiUED@166.1.148.233:63359 '''
# update_proxy(pro)
# print(get_proxies())
Binary file modified data/base/base.db
Binary file not shown.
20 changes: 20 additions & 0 deletions data/chats.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,26 @@ async def add_account(max_id, user_id, account_name, chats):
print("Ошибка при закрытии соединения.", close_error)


async def update_account_chats(account_name, new_chats):
db = None

try:
db = await aiosqlite.connect('data/base/base.db')
serialized_chats = pickle.dumps(new_chats)
update_query = "UPDATE accounts SET chats = ? WHERE account_name = ?;"
await db.execute(update_query, (serialized_chats, account_name))
await db.commit()
print(f"Список чатов для аккаунта {account_name} успешно обновлен.")

except aiosqlite.Error as error:
print("Не удалось обновить список чатов.", error)
finally:
if db:
try:
await db.close()
except aiosqlite.Error as close_error:
print("Ошибка при закрытии соединения.", close_error)


async def get_chats(acc):
db = await aiosqlite.connect('data/base/base.db')
Expand Down
6 changes: 3 additions & 3 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@

from config import bot



async def start():
# Настройка логгера для записи в файл
logging.basicConfig(filename='app.log', level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')

dp = Dispatcher()

dp.include_routers(
Expand All @@ -31,7 +32,6 @@ async def start():
upload_account2.router,
)

logging.basicConfig(level=logging.INFO)
await bot.delete_webhook(drop_pending_updates=True)
await dp.start_polling(bot)

Expand Down