本文整理汇总了Python中oyoyo.client.IRCClient.send方法的典型用法代码示例。如果您正苦于以下问题:Python IRCClient.send方法的具体用法?Python IRCClient.send怎么用?Python IRCClient.send使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类oyoyo.client.IRCClient
的用法示例。
在下文中一共展示了IRCClient.send方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from oyoyo.client import IRCClient [as 别名]
# 或者: from oyoyo.client.IRCClient import send [as 别名]
#.........这里部分代码省略.........
if self.stopping:
print("ignoring message", command, "because we're stopping")
return
# print("post_message", command, args)
# self.on_message(command, args)
# print(command, args)
args = list(args)
# for i, arg in enumerate(args):
# if arg is not None:
# args[i] = arg.decode("UTF-8", errors="replace")
def func():
# if IRC.broadcast(command, args):
# return
if self.irc_server_message(command, args):
return
name = "irc_" + command
try:
method = getattr(self, name)
except AttributeError:
self.info(" ".join([command] + args))
pass
else:
method(*args)
call_after(func)
def privmsg(self, destination, message):
helpers.msg(self.client, destination, message)
def notice(self, destination, message):
self.client.send("notice {0} :{1}".format(destination, message))
def generate_nick(self, reset=False):
if reset:
self.nick_number = 0
self.nick_number += 1
if self.nick_number == 1:
nick = LauncherSettings.get_irc_nick()
else:
nick = LauncherSettings.get_irc_nick() + str(self.nick_number)
self.my_nick = nick
return nick
def append_text(self, message):
self.message(message)
def handle_command(self, message):
if message.startswith("/"):
return self.handle_command_string(message)
else:
if not self.active_channel_name:
self.warning("no active channel")
else:
self.channel(self.active_channel_name).privmsg(message)
def handle_command_string(self, message):
message = message[1:]
parts = message.split(" ")
command = parts[0].lower()
args = parts[1:]
name = "command_" + command
try:
method = getattr(self, name)
示例2: PesterIRC
# 需要导入模块: from oyoyo.client import IRCClient [as 别名]
# 或者: from oyoyo.client.IRCClient import send [as 别名]
class PesterIRC(QtCore.QThread):
def __init__(self, config, window):
QtCore.QThread.__init__(self)
self.mainwindow = window
self.config = config
self.registeredIRC = False
self.stopIRC = None
self.NickServ = services.NickServ()
self.ChanServ = services.ChanServ()
def IRCConnect(self):
server = self.config.server()
port = self.config.port()
self.cli = IRCClient(PesterHandler, host=server, port=int(port), nick=self.mainwindow.profile().handle, real_name='pcc31', blocking=True, timeout=120)
self.cli.command_handler.parent = self
self.cli.command_handler.mainwindow = self.mainwindow
self.cli.connect()
self.conn = self.cli.conn()
def run(self):
try:
self.IRCConnect()
except socket.error as se:
self.stopIRC = se
return
while 1:
res = True
try:
logging.debug("updateIRC()")
res = self.updateIRC()
except socket.timeout as se:
logging.debug("timeout in thread %s" % (self))
self.cli.close()
self.stopIRC = se
return
except socket.error as se:
if self.registeredIRC:
self.stopIRC = None
else:
self.stopIRC = se
logging.debug("socket error, exiting thread")
return
else:
if not res:
logging.debug("false Yield: %s, returning" % res)
return
def setConnected(self):
self.registeredIRC = True
self.connected.emit()
def setConnectionBroken(self):
logging.debug("setconnection broken")
self.reconnectIRC()
#self.brokenConnection = True
@QtCore.pyqtSlot()
def updateIRC(self):
try:
res = next(self.conn)
except socket.timeout as se:
if self.registeredIRC:
return True
else:
raise se
except socket.error as se:
raise se
except StopIteration:
self.conn = self.cli.conn()
return True
else:
return res
@QtCore.pyqtSlot()
def reconnectIRC(self):
logging.debug("reconnectIRC() from thread %s" % (self))
self.cli.close()
@QtCore.pyqtSlot(PesterProfile)
def getMood(self, *chums):
self.cli.command_handler.getMood(*chums)
@QtCore.pyqtSlot(PesterList)
def getMoods(self, chums):
self.cli.command_handler.getMood(*chums)
@QtCore.pyqtSlot('QString', 'QString')
def sendNotice(self, text, handle):
h = str(handle)
t = str(text)
try:
helpers.notice(self.cli, h, t)
except socket.error:
self.setConnectionBroken()
@QtCore.pyqtSlot('QString', 'QString')
def sendMessage(self, text, handle):
h = str(handle)
textl = [str(text)]
def splittext(l):
if len(l[0]) > 450:
space = l[0].rfind(" ", 0,430)
if space == -1:
space = 450
elif l[0][space+1:space+5] == "</c>":
space = space+4
a = l[0][0:space+1]
b = l[0][space+1:]
#.........这里部分代码省略.........