本文整理汇总了Python中bot.Bot.connect方法的典型用法代码示例。如果您正苦于以下问题:Python Bot.connect方法的具体用法?Python Bot.connect怎么用?Python Bot.connect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bot.Bot
的用法示例。
在下文中一共展示了Bot.connect方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: onSourceRowChanged
# 需要导入模块: from bot import Bot [as 别名]
# 或者: from bot.Bot import connect [as 别名]
def onSourceRowChanged(self, sourceModel, sourcePath, sourceIter):
# get needed values from source model
try:
sourceRow = sourceModel[sourceIter]
sourceRowName = sourceRow[SettingModel.COLUMN_NAME]
except ValueError:
return
# update reference to bots-row
if sourceRow.parent == None and sourceRowName == SettingModel.ROW_BOTS:
self.botsRowReference = gtk.TreeRowReference(sourceModel, sourceRow.path)
# check that the changed row is a bot row, ignore others
if sourceRow.parent != None and self.botsRowReference != None and sourceRow.parent.path == self.botsRowReference.get_path():
bot = None
# try to find an existing bot
for row in self:
if sourceRow.path == row[self.COLUMN_SOURCEROWREFERENCE].get_path():
bot = row[self.COLUMN_BOTOBJECT]
break
# if bot was found, update it
if bot:
if bot.getName() != sourceRowName:
raise NotImplementedError('Changing bot name is not implemented')
# if bot was not found, create it
else:
bot = Bot(sourceRowName, self.sourceModel)
bot.connect('notify::apiAccessible', self.onBotPropertyChanged)
bot.connect('notify::isRunning', self.onBotPropertyChanged)
sourceRef = gtk.TreeRowReference(sourceModel, sourceRow.path)
self.append((bot, sourceRef))
示例2: add_bot
# 需要导入模块: from bot import Bot [as 别名]
# 或者: from bot.Bot import connect [as 别名]
def add_bot(self, name):
bot = Bot(self)
bot.name = name
self.bots.append(bot)
if self.running:
bot.connect(self.host, self.port)
return bot
示例3: Bot
# 需要导入模块: from bot import Bot [as 别名]
# 或者: from bot.Bot import connect [as 别名]
from bot import Bot
bot = Bot("_test.json")
bot.connect()
示例4: chat
# 需要导入模块: from bot import Bot [as 别名]
# 或者: from bot.Bot import connect [as 别名]
def chat(message):
b = Bot()
a = b.connect()
rep = b.message(a, message)
return HttpResponse(rep)
示例5: quit
# 需要导入模块: from bot import Bot [as 别名]
# 或者: from bot.Bot import connect [as 别名]
EPOLLFLAGS = select.EPOLLIN | select.EPOLLERR | select.EPOLLHUP
keep_going = True
def quit(signum, frame):
global keep_going
keep_going = False
for s in [signal.SIGTERM, signal.SIGINT]:
signal.signal(s, quit)
signal.siginterrupt(s, False)
fds = {}
for c in config.bots:
if not c.autoconnect:
continue
bot = Bot(c)
fd = bot.connect()
fds[fd] = bot
epoll.register(fd, EPOLLFLAGS)
try:
while keep_going:
try:
results = epoll.poll(config.EPOLL_TIMEOUT)
except IOError as e:
if e.errno == errno.EINTR and not keep_going:
break
raise
flags = dict(results)
ts = time.time()
for fd, bot in fds.items():
if flags.get(fd, 0) & select.EPOLLIN == select.EPOLLIN:
示例6: add_bot
# 需要导入模块: from bot import Bot [as 别名]
# 或者: from bot.Bot import connect [as 别名]
def add_bot(self):
bot = Bot(self, self.token)
self.bots.append(bot)
if self.running:
bot.connect(self.host, self.port)
return bot
示例7: in
# 需要导入模块: from bot import Bot [as 别名]
# 或者: from bot.Bot import connect [as 别名]
elif o in ("-s", "--speak"):
channels.append(VoiceChannel())
elif o in ("-l", "--learn"):
learn=True
elif o in ("-m", "--mute"):
mute=True
elif o in ("-v", "--verbose"):
verbose=True
elif o in ("-d", "--debug"):
debug=True
else:
assert False, "unhandled option"
if not channels:
usage()
raise ValueError("No channel selected")
b=Bot(name)
b.conf["learn"]=learn
b.conf["mute"]=mute
if verbose:
b.conf["debug_verbosity"]=7
b.conf["error_verbosity"]=7
else:
b.conf["debug_verbosity"]=1
b.conf["error_verbosity"]=3
if not debug:
b.conf["debug_verbosity"]=0
for c in channels:
b.connect(c)
c.start()
示例8: main
# 需要导入模块: from bot import Bot [as 别名]
# 或者: from bot.Bot import connect [as 别名]
def main():
kagami = Bot("setup.cfg")
kagami.connect()