Skip to content

Commit

Permalink
some renames
Browse files Browse the repository at this point in the history
  • Loading branch information
kesha1225 committed Apr 9, 2020
1 parent ae0b21c commit f3400eb
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 21 deletions.
8 changes: 4 additions & 4 deletions examples/bots/clones_bot_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@
create many bots with the same functionality
"""

from vkwave.bots.easy import SimpleLongPollGroupBot, TaskManager, ClonesBot
from vkwave.bots.easy import SimpleLongPollBot, TaskManager, ClonesBot


bot = SimpleLongPollGroupBot(tokens=["Bot0TOKEN"], group_id=444, )
bot = SimpleLongPollBot(tokens=["Bot0TOKEN"], group_id=444, )


@bot.message_handler(bot.text_filter("123"))
async def simple(event: bot.SimpleEvent):
async def simple(event: bot.SimpleBotEvent):
await event.answer("HELLO")


clones = ClonesBot(bot, SimpleLongPollGroupBot("Bot1TOKEN", 192868628), SimpleLongPollGroupBot("Bot2TOKEN", 172702125))
clones = ClonesBot(bot, SimpleLongPollBot("Bot1TOKEN", 192868628), SimpleLongPollBot("Bot2TOKEN", 172702125))

clones.run_all_bots()

Expand Down
4 changes: 2 additions & 2 deletions examples/bots/hello_world_bot.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from vkwave.bots.easy import SimpleLongPollGroupBot
from vkwave.bots.easy import SimpleLongPollBot

bot = SimpleLongPollGroupBot(tokens="MyToken", group_id=123456789)
bot = SimpleLongPollBot(tokens="MyToken", group_id=123456789)


@bot.message_handler()
Expand Down
8 changes: 4 additions & 4 deletions examples/bots/simple_bot_example.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
from vkwave.bots.easy import SimpleLongPollGroupBot, TaskManager
from vkwave.bots.easy import SimpleLongPollBot, TaskManager


bot = SimpleLongPollGroupBot(tokens="MyToken", group_id=123456789)
bot = SimpleLongPollBot(tokens="MyToken", group_id=123456789)

# or if you want do a lot of requests without 'to many requests' errors
# bot = SimpleLongPollBot(tokens=["MyToken1", "MyToken2", "MyToken3"], group_id=123456789)


@bot.message_handler(bot.text_filter("hello"))
async def simple(event: bot.SimpleEvent):
async def simple(event: bot.SimpleBotEvent):
await event.answer("hello from vkwave!")


@bot.message_handler(bot.command_filter(commands=["start"]))
async def start(event: bot.SimpleEvent):
async def start(event: bot.SimpleBotEvent):
user_data = (
await bot.api_context.users.get(user_ids=event.object.object.message.peer_id)
).response[0]
Expand Down
6 changes: 3 additions & 3 deletions examples/bots/vkscript_example.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from vkwave.api.methods import APIOptionsRequestContext
from vkwave.bots.easy import SimpleLongPollGroupBot, TaskManager
from vkwave.bots.easy import SimpleLongPollBot, TaskManager
from vkwave.vkscript import execute
from vkwave.types.responses import ExecuteResponse

bot = SimpleLongPollGroupBot(
bot = SimpleLongPollBot(
tokens=["123"],
group_id=456,
)
Expand All @@ -24,7 +24,7 @@ def get_subs_names(api: APIOptionsRequestContext, group_id: int):


@bot.message_handler(bot.text_filter("follow"))
async def simple(event: bot.SimpleEvent):
async def simple(event: bot.SimpleBotEvent):
"""
Get name of each subscriber
"""
Expand Down
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

```python
from vkwave.bots.easy.easy_bot import SimpleLongPollGroupBot
from vkwave.bots.easy.easy_bot import SimpleLongPollBot

bot = SimpleLongPollBot(tokens="MyToken", group_id=123456789)

Expand Down
2 changes: 1 addition & 1 deletion vkwave/bots/easy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
from .easy_bot import SimpleLongPollGroupBot, ClonesBot
from .easy_bot import SimpleLongPollBot, ClonesBot
from .task_manager import TaskManager
12 changes: 6 additions & 6 deletions vkwave/bots/easy/easy_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def create_api_session_aiohttp(token: str) -> _APIContextManager:
return _APIContextManager(token)


class SimpleEvent(BotEvent):
class SimpleBotEvent(BotEvent):
def __init__(self, event: BotEvent):
super().__init__(event.object, event.api_ctx)

Expand Down Expand Up @@ -88,11 +88,11 @@ async def answer(
)


class SimpleLongPollGroupBot:
class SimpleLongPollBot:
def __init__(
self, tokens: typing.Union[str, typing.List[str]], group_id: int,
):
self.SimpleEvent = SimpleEvent
self.SimpleBotEvent = SimpleBotEvent
self.api_session = create_api_session_aiohttp(tokens)
self.api_context = self.api_session.api.get_context()
self._lp = BotLongpoll(self.api_context, BotLongpollData(group_id))
Expand All @@ -115,7 +115,7 @@ def __init__(self, func: typing.Callable[[BaseEvent], typing.Awaitable[typing.An
self.func = func

async def execute(self, event: BotEvent) -> typing.Any:
new_event = SimpleEvent(event)
new_event = SimpleBotEvent(event)
return await self.func(new_event)

def message_handler(self, *filters: BaseFilter):
Expand Down Expand Up @@ -145,10 +145,10 @@ class ClonesBot:
Create many bots with the same functionality
"""

def __init__(self, base_bot: SimpleLongPollGroupBot, *clones: SimpleLongPollGroupBot):
def __init__(self, base_bot: SimpleLongPollBot, *clones: SimpleLongPollBot):
self.base_bot = base_bot
self.router = self.base_bot.router
self.clones: typing.Tuple[SimpleLongPollGroupBot] = clones
self.clones: typing.Tuple[SimpleLongPollBot] = clones

def run_all_bots(self, loop: typing.Optional[asyncio.AbstractEventLoop] = None):
loop = loop or asyncio.get_event_loop()
Expand Down

0 comments on commit f3400eb

Please sign in to comment.