This repository has been archived by the owner on Feb 3, 2019. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2c40ba6
commit d8c204c
Showing
5 changed files
with
32 additions
and
2 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
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 |
---|---|---|
@@ -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) |
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