本文整理汇总了Python中bus.Bus.notify方法的典型用法代码示例。如果您正苦于以下问题:Python Bus.notify方法的具体用法?Python Bus.notify怎么用?Python Bus.notify使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bus.Bus
的用法示例。
在下文中一共展示了Bus.notify方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Bus
# 需要导入模块: from bus import Bus [as 别名]
# 或者: from bus.Bus import notify [as 别名]
from event import Event
from bus import Bus
from listener import WeatherBot
# 1- Register listeners on the bus
bus = Bus()
bus.register(WeatherBot(), Event.Types.message_created_event)
# 2- Let's create some events on the bus and see if our listeners pick them up
for i in range(4):
if i % 2 == 0:
print "throwing message_created_event"
bus.notify(Event(Event.Types.message_created_event, {"room_id":1, "data": "pyro weather 94301", "user_id": 123}))
else:
print "throwing user_joins_room"
bus.notify(Event(Event.Types.user_joins_room, {}))
示例2: Bus
# 需要导入模块: from bus import Bus [as 别名]
# 或者: from bus.Bus import notify [as 别名]
# pylint: disable=I0011,C0103
from event import Event
from bus import Bus
from listener import WeatherBot
# 1- Register listeners on the bus
bot_name = 'pyro'
zipcode = 94040
bus = Bus()
bus.register(WeatherBot(bot_name), Event.Types.message_created_event)
# 2- Let's create some events on the bus and see if our listeners pick them up
for i in range(4):
if i % 2 == 0:
print "throwing message_created_event"
bus.notify(Event(Event.Types.message_created_event, {"room_id":1, "data": "{} weather {}".format(bot_name, zipcode), "user_id": 123}))
else:
print "throwing user_joins_room"
bus.notify(Event(Event.Types.user_joins_room, {}))
示例3: Bus
# 需要导入模块: from bus import Bus [as 别名]
# 或者: from bus.Bus import notify [as 别名]
from event import Event
from bus import Bus
from listener import SparkleBot
import os
import re
import urllib
import urllib2
from weather_api import WeatherAPI
# 1- Register listeners on the bus
bot_name = 'Pyro'
zipcode = 94040
bus = Bus()
bus.register(SparkleBot(bot_name, bus=bus, user_id=8), Event.Types.message_created_event)
# 2- Let's create some events on the bus and see if our listeners pick them up
num = 4
for i in range(num):
if i % num == 0:
print "throwing message_created_event - weather"
bus.notify(Event(Event.Types.message_created_event, {"room_id":1, "data": "{} weather {}".format(bot_name, zipcode), "user_id": 2, "user_name": "Anony Mouse"}))
elif i % num == 1:
print "throwing message_created_event - help"
bus.notify(Event(Event.Types.message_created_event, {"room_id":1, "data": "{} help".format(bot_name), "user_id": 2, "user_name": "Anony Mouse"}))
elif i % num == 2:
print "throwing message_created_event - story"
bus.notify(Event(Event.Types.message_created_event, {"room_id":1, "data": "{} story".format(bot_name), "user_id": 2, "user_name": "Anony Mouse"}))
else:
print "throwing user_joins_room_event"
bus.notify(Event(Event.Types.user_joins_room_event, {}))