当前位置: 首页>>代码示例>>Python>>正文


Python Bus.notify方法代码示例

本文整理汇总了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, {}))
开发者ID:phyous,项目名称:python-bus,代码行数:19,代码来源:main.py

示例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, {}))
开发者ID:nija,项目名称:python-bus-poc,代码行数:22,代码来源:main.py

示例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, {}))
开发者ID:nija,项目名称:hb-chatty,代码行数:32,代码来源:bot_main.py


注:本文中的bus.Bus.notify方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。