-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from dotX12/dev0.2
Dev0.2 to master
- Loading branch information
Showing
109 changed files
with
1,545 additions
and
1,022 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
loguru_filter.set_level('DEBUG') | ||
loguru_filter.set_level("DEBUG") | ||
|
||
bot = Bot( | ||
apikey='algAJW9512kMWGALZIkAMWG', | ||
src_name='test_client18215', | ||
phone_number='79189998877' | ||
apikey="XXX", | ||
src_name="YYY", | ||
phone_number="PHONE", | ||
) | ||
|
||
dp = Dispatcher(bot=bot) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
@dp.message_handler(commands=['start', 'echo']) | ||
async def start_command(message: Message): | ||
@dp.message_handler(commands=["start", "echo"]) | ||
async def start_command(event: Event): | ||
""" | ||
This handler will be called when user sends | ||
`/start` or `/echo` command | ||
""" | ||
await message.answer(f'Hello, {message.message.payload.sender.name}') | ||
await event.answer(f"Hello, {event.message.payload.sender.name}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
@dp.message_handler() | ||
async def start_switch(message: Message): | ||
await message.answer(f'Hello, {message.message.payload.sender.name},' | ||
f' text: {message.message.payload.text}') | ||
async def start_switch(event: Event): | ||
await event.answer( | ||
f"Hello, {event.message.payload.sender.name}," | ||
f" text: {event.message.payload.text}" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
@dp.message_handler(state=RegisterStates.birthday) | ||
async def register_age(message: Message, state: FSMContext): | ||
await state.set_data(birthday=message.text) | ||
await message.answer(f'Thanks for sending you birthday!\n' | ||
f'Send you email address') | ||
async def register_age(event: Event, state: FSMContext): | ||
await state.set_data(birthday=event.text) | ||
await event.answer(f"Thanks for sending you birthday!\n" f"Send you email address") | ||
await state.set_state(RegisterStates.email) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
@dp.message_handler(commands=['register'], state='*') | ||
async def register_name(message: Message, state: FSMContext): | ||
await message.answer(f'Hi, {message.sender_name}! send your date of birth') | ||
@dp.message_handler(commands=["register"], state="*") | ||
async def register_name(event: Event, state: FSMContext): | ||
await event.answer(f"Hi, {event.sender_name}! send your date of birth") | ||
await state.set_state(RegisterStates.birthday) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
from waio.states import State, StatesGroup | ||
|
||
|
||
class RegisterStates(StatesGroup): | ||
birthday = State() | ||
email = State() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
from waio.rules import ABCRule | ||
from waio.types import Event | ||
|
||
|
||
class StaticLongMessageRule(ABCRule): | ||
async def check(self, message: Message) -> bool: | ||
return len(message.text) > 200 | ||
async def check(self, event: Event) -> bool: | ||
return len(event.text) > 200 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
from waio.rules import ABCRule | ||
from waio.types import Event | ||
|
||
|
||
class DynamicLongMessageRule(ABCRule): | ||
def __init__(self, len_message: int): | ||
self.len_message = len_message | ||
|
||
async def check(self, message: Message) -> bool: | ||
return len(message.text) > self.len_message | ||
|
||
async def check(self, event: Event) -> bool: | ||
return len(event.text) > self.len_message |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
@dp.message_handler(text_equals=['foo', 'bar']) | ||
async def start_text_equals(message: Message): | ||
await message.answer(f'Filter used: [text_equals], msg: {message.text}') | ||
@dp.message_handler(text_equals=["foo", "bar"]) | ||
async def start_text_equals(event: Event): | ||
await event.answer(f"Filter used: [text_equals], msg: {event.text}") | ||
|
||
|
||
@dp.message_handler(text_contains=['ru', 'com']) | ||
async def start_text_contains(message: Message): | ||
await message.answer(f'Filter used: [text_contains], msg: {message.text}') | ||
@dp.message_handler(text_contains=["ru", "com"]) | ||
async def start_text_contains(event: Event): | ||
await event.answer(f"Filter used: [text_contains], msg: {event.text}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
from waio.rules import TextRule, ContentType | ||
from waio.types import Event | ||
|
||
|
||
@dp.message_handler( | ||
TextRule(startswith=['1111', '2222'], endswith=['x', 'y', 'z']), | ||
content_type=[ContentType.TEXT] | ||
TextRule(startswith=["1111", "2222"], endswith=["x", "y", "z"]), | ||
content_type=[ContentType.TEXT], | ||
) | ||
async def text_start_switch_without_labeler(message: Message): | ||
await message.answer(f'Filter used: [TextRule], msg: {message.text}') | ||
async def text_start_switch_without_labeler(event: Event): | ||
await event.answer(f"Filter used: [TextRule], msg: {event.text}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
dp.labeler.bind_rule('len_more', DynamicLongMessageRule) | ||
dp.labeler.bind_rule("len_more", DynamicLongMessageRule) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
from waio.rules import MessageCommandsRule | ||
|
||
@dp.message_handler(MessageCommandsRule(commands=['start', 'echo'])) | ||
async def commands_rule_without_labeler(message: Message): | ||
await message.answer( | ||
f'Filter used: [MessageCommandsRule], msg: {message.text}' | ||
) | ||
|
||
@dp.message_handler(MessageCommandsRule(commands=["start", "echo"])) | ||
async def commands_rule_without_labeler(event: Event): | ||
await event.answer(f"Filter used: [MessageCommandsRule], msg: {event.text}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
@dp.message_handler(StaticLongMessageRule()) | ||
async def foo(message: Message): | ||
... | ||
async def foo(event: Event): | ||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
@dp.message_handler(DynamicLongMessageRule(len_message=120)) | ||
async def foo(message: Message): | ||
async def foo(event: Event): | ||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
@dp.message_handler(len_more=12) | ||
async def text_len(message: Message): | ||
await message.answer(f'msg len: {len(message.text)}') | ||
async def text_len(event: Event): | ||
await event.answer(f"msg len: {len(event.text)}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,3 @@ | ||
@dp.message_handler(RussianNumberRule(), commands=["check_number"]) | ||
async def register_rule_check_number(message: Message, number_data: G_T): | ||
await message.answer( | ||
f'You are from Russia! Number data:\n' | ||
f'```{number_data}```' | ||
) | ||
async def register_rule_check_number(event: Event, number_data: G_T): | ||
await event.answer(f"You are from Russia! Number data:\n" f"```{number_data}```") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,28 @@ | ||
from re import Match | ||
|
||
from waio.types import Message | ||
from waio.types import Event | ||
|
||
|
||
async def start_commands(message: Message): | ||
await message.answer( | ||
f'Filter used: [commands and content_type:TEXT], ' | ||
f'msg: {message.message.payload.text}' | ||
async def start_commands(event: Event): | ||
await event.answer( | ||
f"Filter used: [commands and content_type:TEXT], " | ||
f"msg: {event.message.payload.text}" | ||
) | ||
|
||
|
||
async def start_photo(message: Message): | ||
await message.answer( | ||
f'Filter used: [content_type:PHOTO], ' | ||
f'url_photo: {message.message.payload.url}' | ||
async def start_photo(event: Event): | ||
await event.answer( | ||
f"Filter used: [content_type:PHOTO], " f"url_photo: {event.message.payload.url}" | ||
) | ||
|
||
|
||
async def start_regex(message: Message, regex: Match): | ||
cart_id = regex.group('cart_id') | ||
item_id = regex.group('item_id') | ||
await message.answer( | ||
f'Filter used: [regex], ' | ||
f'cart_id: {cart_id}, item_id: {item_id}' | ||
async def start_regex(event: Event, regex: Match): | ||
cart_id = regex.group("cart_id") | ||
item_id = regex.group("item_id") | ||
await event.answer( | ||
f"Filter used: [regex], " f"cart_id: {cart_id}, item_id: {item_id}" | ||
) | ||
|
||
|
||
async def start_text_equals(message: Message): | ||
await message.answer( | ||
f'Filter used: [text_equals], ' | ||
f'msg: {message.text}' | ||
) | ||
async def start_text_equals(event: Event): | ||
await event.answer(f"Filter used: [text_equals], " f"msg: {event.text}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.