當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。