2012-11-02 11:10:37 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
2014-08-30 17:15:14 +00:00
|
|
|
# Nemubot is a smart and modulable IM bot.
|
|
|
|
# Copyright (C) 2012-2014 nemunaire
|
2012-11-02 11:10:37 +00:00
|
|
|
#
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU Affero General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU Affero General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU Affero General Public License
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
import server
|
2014-08-30 17:15:14 +00:00
|
|
|
from server.socket import SocketServer
|
2012-11-02 11:10:37 +00:00
|
|
|
|
2014-08-30 17:15:14 +00:00
|
|
|
class IRCServer(SocketServer):
|
2012-11-02 11:10:37 +00:00
|
|
|
|
2014-08-30 17:15:14 +00:00
|
|
|
def __init__(self, node, nick, owner, realname):
|
|
|
|
SocketServer.__init__(self,
|
|
|
|
node["host"],
|
|
|
|
node["port"],
|
|
|
|
node["password"],
|
|
|
|
node.hasAttribute("ssl") and node["ssl"].lower() == "true")
|
2014-08-14 10:49:38 +00:00
|
|
|
|
2012-11-02 11:10:37 +00:00
|
|
|
self.nick = nick
|
|
|
|
self.owner = owner
|
|
|
|
self.realname = realname
|
2014-08-30 17:15:14 +00:00
|
|
|
self.id = "TODO"
|
|
|
|
|
|
|
|
def _open(self):
|
|
|
|
if SocketServer._open(self):
|
|
|
|
if self.password is not None:
|
|
|
|
self.write("PASS :" + self.password)
|
|
|
|
self.write("NICK :" + self.nick)
|
|
|
|
self.write("USER %s %s bla :%s" % (self.nick, self.host, self.realname))
|
2012-11-02 11:10:37 +00:00
|
|
|
return True
|
2014-08-30 17:15:14 +00:00
|
|
|
return False
|
2012-11-02 11:10:37 +00:00
|
|
|
|
2014-08-30 17:15:14 +00:00
|
|
|
def _close(self):
|
|
|
|
self.write("QUIT")
|
|
|
|
SocketServer._close(self)
|