OctoBot-Channels 1.3.11
OctoBot channels package.
With python3 : pip install OctoBot-Channels
Example
from octobot_channels import Consumer, Producer
from octobot_channels.channels import Channels, Channel
from octobot_channels.util import create_channel_instance
class AwesomeProducer(Producer):
pass
class AwesomeConsumer(Consumer):
pass
class AwesomeChannel(Channel):
PRODUCER_CLASS = MyAwesomeProducer
CONSUMER_CLASS = MyAwesomeConsumer
async def callback(data):
print("Consumer called !")
print("Received : " + data)
# Creates the channel
await create_channel_instance(MyChannel, Channels)
# Add a new consumer to the channel
await Channels.get_chan("Awesome").new_consumer(callback)
# Creates a producer that send data to the consumer through the channel
producer = TestProducer(Channels.get_chan("Awesome"))
await producer.run()
await producer.send("test")
# Stops the channel with all its producers and consumers
# await Channels.get_chan("Awesome").stop()