本文整理汇总了Python中bot.Bot.on方法的典型用法代码示例。如果您正苦于以下问题:Python Bot.on方法的具体用法?Python Bot.on怎么用?Python Bot.on使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bot.Bot
的用法示例。
在下文中一共展示了Bot.on方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Bot
# 需要导入模块: from bot import Bot [as 别名]
# 或者: from bot.Bot import on [as 别名]
from bot import Bot
from settings import AUTH, USERID, ROOMID
bot = Bot(AUTH, USERID, ROOMID)
#bot.debug = True
def speak(data):
if data['userid'] == '4deadb0f4fe7d013dc0555f1':
if data['text'] == '/up':
bot.addDj()
elif data['text'] == '/down':
bot.remDj()
elif data['text'] == '/skip':
bot.stopSong()
elif data['text'] == '/snag':
bot.snag()
elif data['text'] == '/bop':
bot.bop()
elif data['text'] == '/playlist':
def clb(data): print data
bot.playlistAll(clb)
def pmmed(data):
print data
bot.on('speak', speak)
bot.on('pmmed', pmmed)
bot.start()
示例2: Bot
# 需要导入模块: from bot import Bot [as 别名]
# 或者: from bot.Bot import on [as 别名]
bot = Bot(AUTH, USERID, ROOMID)
theUsersList = { }
def roomChanged(data):
global theUsersList
# Reset the users list
theUsersList = {}
users = data['users']
for user in users:
theUsersList[user['userid']] = user
def registered(data):
global theUsersList
user = data['user'][0]
theUsersList[user['userid']] = user
def deregistered(data):
global theUsersList
user = data['user'][0]
del theUsersList[user['userid']]
bot.on('roomChanged', roomChanged)
bot.on('registered', registered)
bot.on('deregistered', deregistered)
bot.start()
示例3: Bot
# 需要导入模块: from bot import Bot [as 别名]
# 或者: from bot.Bot import on [as 别名]
#
# Each time a song starts, the bot vote up.
# WARNING: Turntable no longer allows bots that autobop. This script is provided for educational purposes only.
# For more information, visit http://faq.turntable.fm/customer/portal/articles/258935
#
from bot import Bot
AUTH = "auth+live+xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
USERID = "xxxxxxxxxxxxxxxxxxxxxxxx"
ROOMID = "xxxxxxxxxxxxxxxxxxxxxxxx"
bot = Bot(AUTH, USERID, ROOMID)
def autobop(data):
bot.bop()
bot.on("newsong", autobop)
bot.start()
示例4: Bot
# 需要导入模块: from bot import Bot [as 别名]
# 或者: from bot.Bot import on [as 别名]
#
# Auto boot people on a blacklist.
#
from bot import Bot
AUTH = 'auth+live+xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
USERID = 'xxxxxxxxxxxxxxxxxxxxxxxx'
ROOMID = 'xxxxxxxxxxxxxxxxxxxxxxxx'
bot = Bot(AUTH, USERID, ROOMID)
blackList = set(['xxxxxxxxxxxxxxxxxxxxxxxx', 'xxxxxxxxxxxxxxxxxxxxxxxx'])
# Someone enter the room, make sure he's not on the blacklist.
def registered(data):
global blackList
user = data['user'][0]
if user['userid'] in blackList:
bot.boot(userId, 'You are on the blacklist.')
bot.on('registered', registered)
bot.start()