J'aurais ptet mieux fait de faire un UML finallement...
This commit is contained in:
parent
3fe94fb24c
commit
557ec8bebd
|
@ -3,6 +3,25 @@
|
||||||
import os
|
import os
|
||||||
import subprocess
|
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):
|
class Sexiibot(object):
|
||||||
"""Core sexiibot class"""
|
"""Core sexiibot class"""
|
||||||
|
|
||||||
|
@ -13,15 +32,13 @@ class Sexiibot(object):
|
||||||
self.__server = None
|
self.__server = None
|
||||||
self.__port = port
|
self.__port = port
|
||||||
self.__ssl = ssl
|
self.__ssl = ssl
|
||||||
self.__channel = channel
|
self.__channels = channels
|
||||||
self.__nick = nick
|
self.__nick = nick
|
||||||
self.__realname = realname
|
self.__realname = realname
|
||||||
else:
|
else:
|
||||||
self.__realname = realname
|
self.__realname = realname
|
||||||
self.__extensions = extensions
|
self.__in = None
|
||||||
self.__mode = None
|
self.__out = None
|
||||||
self.__servfifo = None
|
|
||||||
self.__chanfifo = None
|
|
||||||
self.__iipath = iipath
|
self.__iipath = iipath
|
||||||
sekf.__iiproc = None
|
sekf.__iiproc = None
|
||||||
|
|
||||||
|
@ -33,8 +50,22 @@ class Sexiibot(object):
|
||||||
print("FIFO for that server already exist.")
|
print("FIFO for that server already exist.")
|
||||||
print("Please clean the irc folder and try again.")
|
print("Please clean the irc folder and try again.")
|
||||||
sys.exit(1)
|
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:
|
if self.__ssl:
|
||||||
cmd += ["-e", "ssl"]
|
cmd += ["-e", "ssl"]
|
||||||
self.__iiproc = subprocess.Popen(cmd) # self.__iiproc.terminate() later to stop
|
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)
|
||||||
|
|
Loading…
Reference in New Issue