Skip to content
This repository has been archived by the owner on Feb 3, 2019. It is now read-only.

Commit

Permalink
minor fixes; new plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelkryukov committed May 19, 2018
1 parent 2c40ba6 commit d8c204c
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -7,6 +7,7 @@ Version dedicated to performance updates, removing and unifying plugins.
- Added `content_namer.py`.
- Added `content_statistics.py`
- Added `games_anagrams.py`
- Added `control_friends.py`
- Added `order` field to plugins.
- Added highly optimized plugin `storage.py`.
- Added code for generation `PLUGINS.md` (`plugin/__init__.py` -> `save_doc`, should be used around adding class to `__all__`).
Expand Down
1 change: 1 addition & 0 deletions bot.py
Expand Up @@ -225,6 +225,7 @@ async def longpoll_processor(self):

except (asyncio.TimeoutError, aiohttp.ServerDisconnectedError):
self.logger.warning("Long polling server doesn't respond. Changing server.")

await asyncio.sleep(0.5)

await self.init_long_polling(pack)
Expand Down
28 changes: 28 additions & 0 deletions plugins/control/control_friends.py
@@ -0,0 +1,28 @@
import asyncio

from handler.base_plugin import BasePlugin


class FriendsPlugin(BasePlugin):
__slots__ = ("accepter",)

def __init__(self):
"""Accepts friend requests once in a minute."""
super().__init__()

def initiate(self):
async def runner():
while True:
await asyncio.sleep(5)
await self.accept_friends()

self.accepter = asyncio.ensure_future(runner())

async def accept_friends(self):
requests = await self.api.friends.getRequests()

if not request:
return

for user_id in requests["items"]:
await self.api.friends.add(user_id=user_id)
1 change: 1 addition & 0 deletions settings.py
Expand Up @@ -32,6 +32,7 @@ class BotSettings(BaseSettings):
GraffitiPlugin(),
QuoteDoerPlugin(),
WikiPlugin(),
AnagramsPlugin(),
MembersPlugin(),
PairPlugin(),
WhoIsPlugin(),
Expand Down
3 changes: 1 addition & 2 deletions utils/api.py
Expand Up @@ -417,10 +417,9 @@ async def execute_queue(self):

await asyncio.sleep(0.25)

if result:
else:
break


for task in current_tasks:
if task.done() or task.cancelled():
continue
Expand Down

0 comments on commit d8c204c

Please sign in to comment.