Skip to content

Commit

Permalink
naming and types fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
kesha1225 committed Apr 9, 2020
1 parent 205f523 commit b634b9b
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 16 deletions.
6 changes: 3 additions & 3 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 same functionality
"""

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


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


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


clones = ClonesBot(bot, GroupBot("Bot1TOKEN", 192868628), GroupBot("Bot2TOKEN", 172702125))
clones = ClonesBot(bot, SimpleLongPollGroupBot("Bot1TOKEN", 192868628), SimpleLongPollGroupBot("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 GroupBot
from vkwave.bots.easy import SimpleLongPollGroupBot

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


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


bot = GroupBot(tokens="MyToken", group_id=123456789)
bot = SimpleLongPollGroupBot(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)
Expand Down
4 changes: 2 additions & 2 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 GroupBot, TaskManager
from vkwave.bots.easy import SimpleLongPollGroupBot, TaskManager
from vkwave.vkscript import execute
from vkwave.types.responses import ExecuteResponse

bot = GroupBot(
bot = SimpleLongPollGroupBot(
tokens=["123"],
group_id=456,
)
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 GroupBot
from vkwave.bots.easy.easy_bot import SimpleLongPollGroupBot

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 GroupBot, ClonesBot
from .easy_bot import SimpleLongPollGroupBot, ClonesBot
from .task_manager import TaskManager
10 changes: 5 additions & 5 deletions vkwave/bots/easy/easy_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ async def answer(
)


class GroupBot:
class SimpleLongPollGroupBot:
def __init__(
self, tokens: typing.Union[str, typing.List[str]], group_id: int,
):
Expand Down Expand Up @@ -134,7 +134,7 @@ async def run(self):
await self.dispatcher.cache_potential_tokens()
await self._lp.start()

def run_forever(self, loop: asyncio.AbstractEventLoop = None):
def run_forever(self, loop: typing.Optional[asyncio.AbstractEventLoop] = None):
loop = loop or asyncio.get_event_loop()
loop.create_task(self.run())
loop.run_forever()
Expand All @@ -145,12 +145,12 @@ class ClonesBot:
Create many bots with same functionality
"""

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

def run_all_bots(self, loop: asyncio.AbstractEventLoop = None):
def run_all_bots(self, loop: typing.Optional[asyncio.AbstractEventLoop] = None):
loop = loop or asyncio.get_event_loop()
loop.create_task(self.base_bot.run())
for clone in self.clones:
Expand Down

0 comments on commit b634b9b

Please sign in to comment.