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


Python Bot.connect方法代码示例

本文整理汇总了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))
开发者ID:farthing,项目名称:Budabot,代码行数:31,代码来源:botmodel.py

示例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
开发者ID:Thoth19,项目名称:pygar,代码行数:9,代码来源:game.py

示例3: Bot

# 需要导入模块: from bot import Bot [as 别名]
# 或者: from bot.Bot import connect [as 别名]
from bot import Bot

bot = Bot("_test.json")
bot.connect()


开发者ID:ssherar,项目名称:SwingerBot,代码行数:6,代码来源:testbot.py

示例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)
开发者ID:vipul-sharma20,项目名称:chatbot,代码行数:7,代码来源:views.py

示例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:
开发者ID:jmw327,项目名称:pbot,代码行数:33,代码来源:pbot.py

示例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
开发者ID:RyanHope,项目名称:pygar,代码行数:8,代码来源:game.py

示例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()
开发者ID:kaze0mx,项目名称:madtewn,代码行数:32,代码来源:runbot.py

示例8: main

# 需要导入模块: from bot import Bot [as 别名]
# 或者: from bot.Bot import connect [as 别名]
def main():
    kagami = Bot("setup.cfg")
    kagami.connect()
开发者ID:edholland,项目名称:kagami-bot,代码行数:5,代码来源:kagami.py


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