J'aurais ptet mieux fait de faire un UML finallement...

This commit is contained in:
raspbeguy 2016-06-01 01:28:18 +02:00
parent 3fe94fb24c
commit 557ec8bebd
1 changed files with 38 additions and 7 deletions

View File

@ -3,6 +3,25 @@
import os
import subprocess
class Channel(object):
"""Channel class"""
def __init__(self, name, network, nick, extensions=None):
self.__name = name
self.__nick = nick
self.__in = open("%s/irc/%s/%s/in" % (os.environ["HOME"], network, name), "w", 1)
self.__out = open("%s/irc/%s/%s/out" % (os.environ["HOME"], network, name), "r")
self.__exts = extentions
self.__mode = None
def message(self, message):
self.__in.write(message + "\n")
def action(self, action):
message("/j %s" % action)
class Sexiibot(object):
"""Core sexiibot class"""
@ -13,15 +32,13 @@ class Sexiibot(object):
self.__server = None
self.__port = port
self.__ssl = ssl
self.__channel = channel
self.__channels = channels
self.__nick = nick
self.__realname = realname
else:
self.__realname = realname
self.__extensions = extensions
self.__mode = None
self.__servfifo = None
self.__chanfifo = None
self.__in = None
self.__out = None
self.__iipath = iipath
sekf.__iiproc = None
@ -33,8 +50,22 @@ class Sexiibot(object):
print("FIFO for that server already exist.")
print("Please clean the irc folder and try again.")
sys.exit(1)
cmd = [iipath, "-s", self.__server, "-n", self.__nick, "-f", self.__realnamei]
if self.__port is None:
if self.__ssl:
self.__port = 6697
else:
self.__port = 6667
cmd = [iipath, "-s", self.__server, "-p", self.__port, "-n", self.__nick, "-f", self.__realname]
if self.__ssl:
cmd += ["-e", "ssl"]
self.__iiproc = subprocess.Popen(cmd) # self.__iiproc.terminate() later to stop
self.__in = open("%s/irc/%s/in" % (os.environ["HOME"], self.__server), "w", 1)
def messageServer(self, message):
self.__in.write(message + "\n")
def join(self, channel):
messageServer("/j %s" % channel)
def messageChannel(self, channel, message):
self.__channels[channel].message(message)