Fixed uploading a bit
This commit is contained in:
parent
d38fe90fce
commit
65c3a13504
1 changed files with 14 additions and 7 deletions
21
logbot.py
21
logbot.py
|
@ -51,14 +51,16 @@ DEBUG = False
|
||||||
SERVER = "irc.freenode.net"
|
SERVER = "irc.freenode.net"
|
||||||
PORT = 6667
|
PORT = 6667
|
||||||
SERVER_PASS = None
|
SERVER_PASS = None
|
||||||
CHANNELS=["#keryx"]
|
CHANNELS=["#excid3"]
|
||||||
NICK = "timber"
|
NICK = "timber"
|
||||||
NICK_PASS = ""
|
NICK_PASS = ""
|
||||||
|
|
||||||
FTP_SERVER = ""
|
FTP_SERVER = "excid3.fivebean.net"
|
||||||
FTP_USER = ""
|
FTP_USER = "excidfiv"
|
||||||
FTP_PASS = ""
|
FTP_PASS = "./:j7JW}y*;.a4'8/|kBA.tUC"
|
||||||
FTP_FOLDER = ""
|
FTP_FOLDER = "public_html/excid3.com/logs"
|
||||||
|
FTP_WAIT = 25
|
||||||
|
# Only upload every 25 messages
|
||||||
|
|
||||||
default_format = {
|
default_format = {
|
||||||
"action" : '<span class="person" style="color:%color%">* %user% %message%</span>',
|
"action" : '<span class="person" style="color:%color%">* %user% %message%</span>',
|
||||||
|
@ -189,13 +191,16 @@ class Logbot(SingleServerIRCBot):
|
||||||
|
|
||||||
if self.ftp and self.count > 25:
|
if self.ftp and self.count > 25:
|
||||||
self.count = 0
|
self.count = 0
|
||||||
|
print "Uploading to FTP..."
|
||||||
for root, dirs, files in os.walk("logs"):
|
for root, dirs, files in os.walk("logs"):
|
||||||
#TODO: Create folders
|
#TODO: Create folders
|
||||||
|
|
||||||
for fname in files:
|
for fname in files:
|
||||||
full_fname = os.path.join(root, fname)
|
full_fname = os.path.join(root, fname)
|
||||||
self.ftp.storbinary("STOR %s" % fname, open(full_fname, "rb"))
|
|
||||||
|
remote_fname = "/".join(full_fname.split("/")[1:])
|
||||||
|
self.ftp.storbinary("STOR %s" % remote_fname, open(full_fname, "rb"))
|
||||||
|
print "Finished uploading"
|
||||||
|
|
||||||
def append_log_msg(self, channel, msg):
|
def append_log_msg(self, channel, msg):
|
||||||
print "%s >>> %s" % (channel, msg)
|
print "%s >>> %s" % (channel, msg)
|
||||||
|
@ -288,6 +293,7 @@ class Logbot(SingleServerIRCBot):
|
||||||
self.write_event("pubnotice", e)
|
self.write_event("pubnotice", e)
|
||||||
|
|
||||||
def on_privmsg(self, c, e):
|
def on_privmsg(self, c, e):
|
||||||
|
print nm_to_n(e.source()), e.arguments()
|
||||||
c.privmsg(nm_to_n(e.source()), self.format["help"])
|
c.privmsg(nm_to_n(e.source()), self.format["help"])
|
||||||
|
|
||||||
def on_quit(self, c, e):
|
def on_quit(self, c, e):
|
||||||
|
@ -308,6 +314,7 @@ def main():
|
||||||
try:
|
try:
|
||||||
# Connect to FTP
|
# Connect to FTP
|
||||||
if FTP_SERVER:
|
if FTP_SERVER:
|
||||||
|
print "Using FTP %s..." % (FTP_SERVER)
|
||||||
f = FTP(FTP_SERVER, FTP_USER, FTP_PASS)
|
f = FTP(FTP_SERVER, FTP_USER, FTP_PASS)
|
||||||
f.cwd(FTP_FOLDER)
|
f.cwd(FTP_FOLDER)
|
||||||
bot.set_ftp(f)
|
bot.set_ftp(f)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue