mirror of
https://github.com/krislamo/Flea
synced 2025-01-07 02:40:34 +00:00
Deleted settings.conf. Working State.
This commit is contained in:
parent
47dfb30496
commit
5110004ac4
@ -14,8 +14,8 @@
|
|||||||
# You should have received a copy of the GNU Affero General Public License
|
# 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/>
|
# along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||||
|
|
||||||
from core.config import *
|
import config
|
||||||
import core.irclib as irclib
|
import irclib
|
||||||
|
|
||||||
# Built-in to Python 2.7
|
# Built-in to Python 2.7
|
||||||
import __builtin__
|
import __builtin__
|
||||||
@ -85,7 +85,7 @@ def PluginsImport(log=None, plugins_folder="/plugins"):
|
|||||||
|
|
||||||
def init_connection(config_file="settings.conf"):
|
def init_connection(config_file="settings.conf"):
|
||||||
irc_conn = irclib.irc()
|
irc_conn = irclib.irc()
|
||||||
irc_conn.config = cfgParser(config_file)
|
irc_conn.config = config.cfgParser(config_file)
|
||||||
|
|
||||||
if irc_conn.config["logging"]:
|
if irc_conn.config["logging"]:
|
||||||
log = open("log.txt", 'a')
|
log = open("log.txt", 'a')
|
||||||
@ -115,7 +115,7 @@ def init_connection(config_file="settings.conf"):
|
|||||||
server = (irc_conn.config["host"], irc_conn.config["port"])
|
server = (irc_conn.config["host"], irc_conn.config["port"])
|
||||||
try:
|
try:
|
||||||
printlog("Connecting to " + server[0] + ':' + str(server[1]))
|
printlog("Connecting to " + server[0] + ':' + str(server[1]))
|
||||||
irc_conn.sock.connect(server[0], server[1])
|
irc_conn.sock.connect(server)
|
||||||
except:
|
except:
|
||||||
printlog("Connection failed.", log)
|
printlog("Connection failed.", log)
|
||||||
return (None, None)
|
return (None, None)
|
||||||
@ -128,14 +128,16 @@ def init_connection(config_file="settings.conf"):
|
|||||||
printlog("[SSL] Bits: " + str(ssl_info[2]), log)
|
printlog("[SSL] Bits: " + str(ssl_info[2]), log)
|
||||||
|
|
||||||
# Establish identity on server
|
# Establish identity on server
|
||||||
identity = (irc_conn.config["ident"], irc_conn.config["mode"], irc_conn.config["unused"], irc_conn.config["realname"])
|
identity = (irc_conn.config["ident"], irc_conn.config["mode"],
|
||||||
irc_conn.User(identity)
|
irc_conn.config["unused"], irc_conn.config["realname"])
|
||||||
|
irc_conn.User(*identity)
|
||||||
irc_conn.Nick(irc_conn.config["nick"])
|
irc_conn.Nick(irc_conn.config["nick"])
|
||||||
|
|
||||||
return (irc_conn, plugins)
|
return (irc_conn, plugins)
|
||||||
|
|
||||||
|
|
||||||
def client_loop(irc_conn, plugins, log=None):
|
def client_loop(irc_conn, plugins, log=None):
|
||||||
|
wait = None
|
||||||
if irc_conn is None:
|
if irc_conn is None:
|
||||||
print "No connection established."
|
print "No connection established."
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
@ -166,18 +168,17 @@ def client_loop(irc_conn, plugins, log=None):
|
|||||||
|
|
||||||
# Ignore empty lines
|
# Ignore empty lines
|
||||||
if len(line) > 0:
|
if len(line) > 0:
|
||||||
|
|
||||||
# Print/log line, parse it and respond
|
|
||||||
printlog(line, log)
|
printlog(line, log)
|
||||||
irc_conn.pack = irc_conn.Parser(line)
|
irc_conn.pack = irc_conn.Parser(line)
|
||||||
|
|
||||||
# Run all plugins main() function
|
# Run all plugins main() function
|
||||||
wait = ''
|
wait = None
|
||||||
if irc_conn.config["plugins"]:
|
if irc_conn.config["plugins"]:
|
||||||
for plugin in plugins:
|
if plugins is not None:
|
||||||
wait = plugin.main.main(irc_conn)
|
for plugin in plugins:
|
||||||
if wait == "QUIT":
|
wait = plugin.main.main(irc_conn)
|
||||||
break
|
if wait == "QUIT":
|
||||||
|
break
|
||||||
|
|
||||||
# Ping Pong, keep the connection alive.
|
# Ping Pong, keep the connection alive.
|
||||||
if irc_conn.pack["cmd"] == "PING":
|
if irc_conn.pack["cmd"] == "PING":
|
||||||
@ -215,3 +216,6 @@ def client_loop(irc_conn, plugins, log=None):
|
|||||||
def main():
|
def main():
|
||||||
(irc_conn, plugins) = init_connection()
|
(irc_conn, plugins) = init_connection()
|
||||||
client_loop(irc_conn, plugins)
|
client_loop(irc_conn, plugins)
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
@ -21,12 +21,13 @@ import re
|
|||||||
class irc:
|
class irc:
|
||||||
# TODO: Wrap in __init__
|
# TODO: Wrap in __init__
|
||||||
debug = False
|
debug = False
|
||||||
log = False
|
log = None
|
||||||
config = {}
|
config = {}
|
||||||
pack = {}
|
pack = {}
|
||||||
sock = socket.socket()
|
sock = socket.socket()
|
||||||
|
|
||||||
# IRC Parser. Parses by line Functions are lowercase, classes uppercase
|
# IRC Parser. Parses by line Functions are
|
||||||
|
# lowercase, classes uppercase
|
||||||
def Parser(self, line):
|
def Parser(self, line):
|
||||||
packet = {"nick":None, "ident":None,
|
packet = {"nick":None, "ident":None,
|
||||||
"host":None, "cmd":None,
|
"host":None, "cmd":None,
|
||||||
@ -95,7 +96,7 @@ class irc:
|
|||||||
|
|
||||||
if self.debug:
|
if self.debug:
|
||||||
print output
|
print output
|
||||||
if self.log:
|
if self.log is not None:
|
||||||
self.log.write(output+"\n")
|
self.log.write(output+"\n")
|
||||||
|
|
||||||
def User(self, nick, mode, unused, owner):
|
def User(self, nick, mode, unused, owner):
|
@ -1,3 +1,4 @@
|
|||||||
|
#!/bin/python
|
||||||
# An IRC bot named Flea
|
# An IRC bot named Flea
|
||||||
# Copyright (C) 2016 Kris Lamoureux
|
# Copyright (C) 2016 Kris Lamoureux
|
||||||
|
|
||||||
@ -18,7 +19,7 @@ import traceback
|
|||||||
import sys
|
import sys
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from core.main import *
|
import Flea.Flea
|
||||||
|
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
print "\nGoodbye!"
|
print "\nGoodbye!"
|
||||||
@ -39,4 +40,4 @@ except:
|
|||||||
raw_input()
|
raw_input()
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
main()
|
Flea.Flea.main()
|
@ -5,12 +5,12 @@ plugins = true
|
|||||||
host = irc.foonetic.net
|
host = irc.foonetic.net
|
||||||
port = 7001
|
port = 7001
|
||||||
|
|
||||||
nick = FleaTest
|
nick = DuckBorg
|
||||||
password =
|
password = fxcva
|
||||||
ident =
|
ident = ducksrule
|
||||||
mode = +B
|
mode = +B
|
||||||
unused = *
|
unused = *
|
||||||
realname = your_name
|
realname = ducky
|
||||||
|
|
||||||
control = graygoose124
|
control = graygoose124
|
||||||
channel = #freesoftware
|
channel = #freesoftware
|
||||||
|
Loading…
Reference in New Issue
Block a user