-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated to 4.1.0; Fixed bug in commands; Improved backends's public A…
…PI (#48) * Updated to 4.1.0; Fixed bug in commands; Improved backends's public API * Made 'resolve_screen_name' public * Changed commend in stream.py
- Loading branch information
1 parent
adf92b5
commit 8c3ac1d
Showing
11 changed files
with
214 additions
and
68 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,41 @@ | ||
import asyncio | ||
from kutana import Plugin, Attachment, get_path | ||
|
||
|
||
# This example shows how to access existing backend instance and perform | ||
# some actions outside of handlers. | ||
|
||
|
||
plugin = Plugin(name="Stream", description="Send images to subscribers") | ||
|
||
|
||
subscribers = [] | ||
|
||
|
||
async def bg_loop(vk): | ||
while True: | ||
with open(get_path(__file__, "assets/pizza.png"), "rb") as fh: | ||
temp_a = Attachment.new(fh.read(), "pizza.png") | ||
|
||
a = await vk.upload_attachment(temp_a, peer_id=None) | ||
|
||
for sub in subscribers: | ||
await vk.send_message(sub, "", a) | ||
|
||
await asyncio.sleep(5) | ||
|
||
@plugin.on_start() | ||
async def _(app): | ||
vk = app.get_backends()[0] | ||
asyncio.ensure_future(bg_loop(vk)) | ||
|
||
@plugin.on_commands(["stream sub"]) | ||
async def _(msg, ctx): | ||
subscribers.append(msg.receiver_id) | ||
await ctx.reply("OK") | ||
|
||
|
||
@plugin.on_commands(["stream unsub"]) | ||
async def _(msg, ctx): | ||
subscribers.remove(msg.receiver_id) | ||
await ctx.reply("OK") |
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
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 |
---|---|---|
|
@@ -8,7 +8,7 @@ | |
import setuptools | ||
|
||
|
||
VERSION = "4.0.0" | ||
VERSION = "4.1.0" | ||
|
||
|
||
with open("README.md", "r") as fh: | ||
|
Oops, something went wrong.