Skip to content
This repository was archived by the owner on May 20, 2024. It is now read-only.

Commit 33701ea

Browse files
authored
Merge pull request #70 from dark0ghost/beta
update aiogram version, clean dead code
2 parents 28768b7 + 7db1c47 commit 33701ea

25 files changed

+53
-79
lines changed

Makefile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11

2-
32
start :
4-
docker run postgres redis bot
3+
docker-compose run -d postgres redis bot

config.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,5 +69,9 @@
6969
"proxy_use": false,
7070
"wallet": {
7171
"ton": ""
72+
},
73+
"master": "",
74+
"etcherscan":{
75+
"token": ""
7276
}
7377
}

core.py

Lines changed: 23 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,48 @@
11
# This Python file uses the following encoding: utf-8
2-
import contextlib
2+
import logging
33
import os
4-
54
from typing import List
65

7-
import typing
8-
9-
import helps
106
import aiohttp
11-
import logging
12-
import filter
13-
14-
from modules.com.pastebin import Pastebin
15-
from modules import async_proxy, button, keyboard, i18n, CbApi, CryptoPrice, CheckerEmail, CatApi, IoJsonBox, db_pg, etherscan
7+
from aiogram import Bot, Dispatcher, types
168
from aiogram.contrib.fsm_storage.memory import MemoryStorage
179
from aiogram.contrib.fsm_storage.redis import RedisStorage2
18-
from aiogram import Bot, Dispatcher, types
19-
from aiosocksy.connector import ProxyConnector, ProxyClientRequest
2010
from aiogram.contrib.middlewares.logging import LoggingMiddleware
2111
from aiogram.utils.callback_data import CallbackData
12+
from aiograph import Telegraph
13+
from aiosocksy.connector import ProxyConnector, ProxyClientRequest
2214

23-
from State import States
24-
from modules.com.virustotal.Virustotal import Virustotal
25-
from modules.org.ton.TON import TON
15+
import filter
16+
import helps
17+
from modules import async_proxy, button, keyboard, i18n, ab_api, crypto_price, checker_email, cat_api, io_json_box, \
18+
db_pg, etherscan
19+
from modules.com.pastebin import pastebin
20+
from modules.com.virustotal.virustotal import Virustotal
21+
from modules.org.ton.ton import TON
2622
from modules.qrtag import QrTag
2723
from set_loop import loop
28-
from aiograph import Telegraph
24+
from state import States
2925

3026
print("build")
3127
# start set
3228
postgres = db_pg.Postgres()
3329

3430
BASE_DIR: str = (os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) + "/bot"
3531

36-
checker_mail: CheckerEmail.CheckerEmail = CheckerEmail.CheckerEmail(hostname_mail=helps.smtp_host,
37-
port=helps.smtp_port, password=helps.smtp_password,
38-
login=helps.smtp_login)
39-
32+
checker_mail: checker_email.CheckerEmail = checker_email.CheckerEmail(hostname_mail=helps.smtp_host,
33+
port=helps.smtp_port, password=helps.smtp_password,
34+
login=helps.smtp_login)
4035
checker_mail.change_len_code(new_len_code=5)
4136

4237
telegraph = Telegraph()
4338

4439
session: aiohttp.ClientSession = aiohttp.ClientSession()
4540

46-
io_json_box: IoJsonBox = IoJsonBox.IOJsonBox(session)
41+
io_json_box: io_json_box = io_json_box.IOJsonBox(session)
4742

48-
crypto_price: CryptoPrice.CryptoPrice = CryptoPrice.CryptoPrice(session)
43+
crypto_price = crypto_price.CryptoPrice(session)
4944

50-
catApi = CatApi.CatApi(session=session)
45+
catApi = cat_api.CatApi(session=session)
5146

5247
ether_api: etherscan.EtherScan = etherscan.EtherScan(api_key=helps.ether_api, session=session)
5348

@@ -56,11 +51,11 @@
5651

5752
proxy_use: str = helps.proxy_use
5853

59-
pastebin: Pastebin = Pastebin.Pastebin(token=helps.pastebian, session=session)
54+
pastebin: pastebin = pastebin.Pastebin(token=helps.pastebian, session=session)
6055

6156
ton = TON(session=session)
6257

63-
cb = CbApi.CenterBankApi(session)
58+
cb = ab_api.CenterBankApi(session)
6459

6560
logging.basicConfig(filename="log_base.log", level=logging.INFO)
6661

@@ -101,27 +96,26 @@
10196

10297

10398
# start def
104-
10599
async def setproxy() -> None:
106100
"""
107101
check proxy and add to list
108102
@return:
109103
"""
110-
proxy_list = []
104+
proxy_box = []
111105
connector = ProxyConnector()
112106
li = await proxy_class.main()
113107
for proxy in li:
114108
try:
115109
async with aiohttp.ClientSession(connector=connector, request_class=ProxyClientRequest) as session:
116110
async with session.get("https://www.telegram.org", proxy=proxy) as response:
117111
log.debug(f"{proxy} valid")
118-
proxy_list.append(proxy)
112+
proxy_box.append(proxy)
119113

120114
except Exception as e:
121115
logging.exception(e)
122116
log.info(f"warning {proxy} not valid")
123117

124-
if len(proxy_list) < 2:
118+
if len(proxy_box) < 2:
125119
log.info(f"log new rec")
126120
await setproxy()
127121

@@ -134,12 +128,9 @@ async def task():
134128
"""
135129
bind = await postgres.connect(url=helps.POSTGRES)
136130
await telegraph.create_account((await bot.get_me())["first_name"])
137-
# await postgres.make_migrate()
138131

139132

140133
# end def
141-
142-
143134
if proxy_use:
144135
bot = Bot(token=helps.token, loop=loop,
145136
parse_mode=types.ParseMode.HTML,
@@ -156,11 +147,8 @@ async def task():
156147

157148

158149
# end set
159-
160-
161150
async def shutdown(dispatcher: Dispatcher):
162151
"""
163-
164152
:param dispatcher:
165153
:return:
166154
"""

filter.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from abc import ABC
2-
31
from aiogram import types
42
from aiogram.dispatcher.filters import BoundFilter
53
import helps

handlers/inline_handlers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from aiogram.types import InlineQuery, \
66
InputTextMessageContent, InlineQueryResultArticle
77

8-
from core import dp, bot, lazy_get_text, cb as bank_api, crypto_price, proxy_class, session, Button
8+
from core import dp, bot, lazy_get_text, cb as bank_api, crypto_price, proxy_class, Button
99

1010

1111
@dp.inline_handler()

handlers/message_handler.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,13 @@
1818

1919
@dp.message_handler(commands=['start'])
2020
async def process_start_command(message: types.Message) -> None:
21-
m = message.get_args()
2221
await State.get_mail.set()
2322
await bot.send_message(message.chat.id, text=helps.mes['start'],
2423
reply_markup=keyboard.keyboard_all(lazy_get_text("отмена")))
2524

2625

2726
@dp.message_handler(commands=['language'])
2827
async def cmd_language(message: types.Message, state: FSMContext) -> None:
29-
# track('command', message.from_user, command='language')
3028
await state.set_state('wait_language')
3129
await message.reply(
3230
lazy_get_text('Choose the language in which you are more comfortable to communicate'),
@@ -38,7 +36,6 @@ async def cmd_language(message: types.Message, state: FSMContext) -> None:
3836
async def wait_language(message: types.Message, state: FSMContext, user: User) -> None:
3937
# track('command', message.from_user, command='done_language')
4038
if message.text in lang:
41-
# await user.set_language(message.text)
4239
lazy_get_text.ctx_locale.set(message.text)
4340
await message.reply(lazy_get_text('New language is: <b>English</b>'), reply_markup=types.ReplyKeyboardRemove())
4441
await state.finish()
@@ -95,7 +92,6 @@ async def buy(message: types.Message) -> None:
9592
photo_height=512, # !=0/None or picture won't be shown
9693
photo_width=512,
9794
photo_size=512,
98-
# is_flexible=1, # True If you need to set up Shipping Fee
9995
prices=price.price,
10096
start_parameter='time-machine-example',
10197
payload='HAPPY FRIDAYS COUPON')

handlers/shoping_handler.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
# This Python file uses the following encoding: utf-8
2-
from core import dp,bot
2+
from core import dp, bot
33
from aiogram import types
44

5-
65
import price
76

87

9-
108
@dp.shipping_query_handler()
119
async def shipping(shipping_query: types.ShippingQuery):
1210
await bot.answer_shipping_query(shipping_query.id, ok=True, shipping_options=price.shipping_options,
13-
error_message=f'доставка не работает!')
11+
error_message=f'доставка не работает!')

helps.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from typing import Tuple, Dict, Union, Any
1010

1111
# or config.json
12-
with open("config_pro.json", "r") as file:
12+
with open("config.json", "r") as file:
1313
file_dict: Dict[str, str] = json.loads(file.read())
1414

1515
token: str = file_dict["token"]

modules/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
from modules import IoJsonBox, CatApi, CheckerEmail, CryptoPrice
1+
from modules import io_json_box, cat_api, checker_email, crypto_price
22

3-
__all__ = [IoJsonBox.IOJsonBox, CheckerEmail.CheckerEmail, CatApi.CatApi, CryptoPrice.CryptoPrice]
3+
__all__ = [io_json_box.IOJsonBox, checker_email.CheckerEmail, cat_api.CatApi, crypto_price.CryptoPrice]
File renamed without changes.

0 commit comments

Comments
 (0)