src package

Submodules

src.app module

src.app.main()[source]

Start bot in webhook mode.

Bot’s main entry point.

src.app.on_startup(webhook_path=None, *args)[source]

Prepare bot before starting.

Set webhook and run background tasks.

src.bot module

class src.bot.DispatcherManual(bot, loop=None, storage: Optional[aiogram.dispatcher.storage.BaseStorage] = None, run_tasks_by_default: bool = False, throttling_rate_limit=0.1, no_throttle_error=False, filters_factory=None)[source]

Bases: aiogram.dispatcher.dispatcher.Dispatcher

Dispatcher with user availability in database check.

process_update(update: aiogram.types.update.Update)[source]

Process update object with user availability in database check.

If bot doesn’t know the user, it pretends they sent /start message.

class src.bot.IncomingHistoryMiddleware[source]

Bases: aiogram.dispatcher.middlewares.BaseMiddleware

Middleware for storing incoming history.

trigger(action, args)[source]

Save incoming data in the database.

class src.bot.TellerBot(token: String, loop: Union[asyncio.base_events.BaseEventLoop, asyncio.events.AbstractEventLoop, None] = None, connections_limit: Optional[Integer] = None, proxy: Optional[String] = None, proxy_auth: Optional[aiohttp.helpers.BasicAuth] = None, validate_token: Optional[Boolean] = True, parse_mode: Optional[String] = None, timeout: Union[Integer, Float, aiohttp.client.ClientTimeout, None] = None)[source]

Bases: aiogram.bot.bot.Bot

Custom bot class.

request(method, data=None, *args, **kwargs)[source]

Make a request and save it in the database.

src.bot.private_handler(*args, **kwargs)[source]

Register handler only for private message.

src.bot.setup()[source]

Set API token from config to bot and setup dispatcher.

src.bot.state_handler(state)[source]

Associate state with decorated handler.

src.database module

class src.database.MongoStorage[source]

Bases: aiogram.dispatcher.storage.BaseStorage

MongoDB asynchronous storage for FSM using motor.

close()[source]

Disconnect from MongoDB.

finish(user: int, **kwargs)[source]

Finish conversation with user.

get_data(user: int, **kwargs) → Dict[KT, VT][source]

Get state data of user with Telegram ID user.

get_state(user: int, **kwargs) → Optional[str][source]

Get current state of user with Telegram ID user.

reset_state(user: int, with_data: bool = True, **kwargs)[source]

Reset state for user with Telegram ID user.

set_data(user: int, data: Optional[Dict[KT, VT]] = None, **kwargs) → None[source]

Set state data data of user with Telegram ID user.

set_state(user: int, state: Optional[str] = None, **kwargs) → None[source]

Set new state state of user with Telegram ID user.

update_data(user: int, data: Optional[Dict[KT, VT]] = None, **kwargs) → None[source]

Update data of user with Telegram ID user.

wait_closed() → None[source]

Do nothing.

Motor client does not use this method.

src.i18n module

class src.i18n.I18nMiddlewareManual(domain, path, default='en')[source]

Bases: aiogram.contrib.middlewares.i18n.I18nMiddleware

I18n middleware which gets user locale from database.

find_locales() → Dict[str, gettext.NullTranslations][source]

Load all compiled locales from path and add default fallbacks.

get_user_locale(action: str, args: Tuple[Any]) → Optional[str][source]

Get user locale by querying collection of users in database.

Return value of locale field in user’s corresponding document if it exists, otherwise return user’s Telegram language if possible.

src.money module

exception src.money.MoneyValueError[source]

Bases: Exception

Inappropriate money argument value.

src.money.gateway_currency_regexp(currency)[source]

Return regexp that ignores gateway if it isn’t specified.

src.money.money(value) → decimal.Decimal[source]

Try to return normalized money object constructed from value.

src.money.normalize(money: decimal.Decimal, exp: decimal.Decimal = Decimal('1E-8')) → decimal.Decimal[source]

Round money to exp and strip trailing zeroes.

src.notifications module

src.notifications.order_notification(order: Mapping[str, Any])[source]

Notify users about order.

Subscriptions to these notifications are managed with /subscribe or /unsubscribe commands of start_menu handlers.

src.notifications.run_loop()[source]

Notify order creators about expired orders in infinite loop.

src.states module

class src.states.Escrow[source]

Bases: aiogram.dispatcher.filters.state.StatesGroup

States of user during escrow exchange.

States are uncontrollable by users and are only used to determine what action user is required to perform. Because there are two parties in escrow exchange and steps are dependant on which currencies are used, states do not define full steps of exchange.

amount = <State 'Escrow:amount'>

Send sum in any of the currencies.

bank = <State 'Escrow:bank'>

Choose escrow initiator’s bank from listed.

fee = <State 'Escrow:fee'>

Agree or disagree to pay fee.

full_card = <State 'Escrow:full_card'>

Send fiat receiver’s full card number to fiat sender.

name = <State 'Escrow:name'>

Send fiat sender’s name on card. Required to verify fiat transfer.

receive_address = <State 'Escrow:receive_address'>

Send escrow asset receiver’s address in blockchain.

receive_card_number = <State 'Escrow:receive_card_number'>

Send first and last 4 digits of fiat receiver’s card number.

send_address = <State 'Escrow:send_address'>

Escrow asset sender’s address in blockchain.

send_card_number = <State 'Escrow:send_card_number'>

Send first and last 4 digits of fiat sender’s card number.

class src.states.OrderCreation[source]

Bases: aiogram.dispatcher.filters.state.StatesGroup

Steps of order creation.

States represent values user is required to send. They are in order and skippable unless otherwise specified.

amount = <State 'OrderCreation:amount'>

Sum in any of the currencies.

buy = <State 'OrderCreation:buy'>

Currency user wants to buy (unskippable).

buy_gateway = <State 'OrderCreation:buy_gateway'>

Gateway of buy currency (unskippable).

comments = <State 'OrderCreation:comments'>

Any additional comments.

duration = <State 'OrderCreation:duration'>

Duration in days.

location = <State 'OrderCreation:location'>

Location object or location name.

payment_system = <State 'OrderCreation:payment_system'>

Cashless payment system.

price = <State 'OrderCreation:price'>

Price in one of the currencies.

sell = <State 'OrderCreation:sell'>

Currency user wants to sell (unskippable).

sell_gateway = <State 'OrderCreation:sell_gateway'>

Gateway of sell currency (unskippable).

set_order = <State 'OrderCreation:set_order'>

Finish order creation by skipping comments state.

src.states.asking_support = <State '@:asking_support'>

Ask support a question.

src.states.cashback_address = <State '@:cashback_address'>

Send new value of chosen order’s field during editing.

src.states.field_editing = <State '@:field_editing'>

Send new value of chosen order’s field during editing.

src.whitelist module

Whitelists for orders.

src.whitelist.currency_keyboard(currency_type: str) → aiogram.types.reply_keyboard.ReplyKeyboardMarkup[source]

Get keyboard with currencies from whitelists.

src.whitelist.gateway_keyboard(currency: str, currency_type: str) → aiogram.types.reply_keyboard.ReplyKeyboardMarkup[source]

Get keyboard with gateways of currency from whitelist.

Module contents