forked from swee/MeowNex
Compare commits
31 commits
238c4e8c92
...
3af087af81
Author | SHA1 | Date | |
---|---|---|---|
3af087af81 | |||
ea6a360bb9 | |||
0fc91a8aab | |||
b7f777bd0a | |||
e19a147521 | |||
aebcdb8255 | |||
b626e42b76 | |||
fc19c7c0d3 | |||
e69e5c6ab2 | |||
6b55d21f91 | |||
e58abcda8d | |||
369d6a042c | |||
85730a0d23 | |||
28647f1a63 | |||
10cdf39700 | |||
71bbdbbc5e | |||
149e6bf851 | |||
680143fcf9 | |||
9f5f47c61d | |||
4e9da369db | |||
7e99e73011 | |||
525bd85283 | |||
aaaae7b9de | |||
6147a185f5 | |||
a65ce4a183 | |||
51ddc2fdf2 | |||
368ddcd885 | |||
63bbff3be8 | |||
2ee01f1b38 | |||
897f70911a | |||
f8bcbca7c7 |
5 changed files with 86 additions and 144 deletions
16
dashboard.html
Normal file
16
dashboard.html
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
<title>MeowNexUS IRC - Dashboard</title>
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<link rel="stylesheet" href="https://swee.codes/style.css" type="text/css">
|
||||||
|
<body>
|
||||||
|
<center>
|
||||||
|
<h1>MeowNexUS IRC</h1>
|
||||||
|
<noscript>Requires JS, sorry.<br></noscript>
|
||||||
|
<a class="softcard" style="display: inline-block;" title="Commands run" href="#"><span id="run">...</span><br><img src="https://swee.codes/icons/up.svg"></a>
|
||||||
|
<a class="softcard" style="display: inline-block;" title="Commands refused" href="#"><span id="blocked">...</span><br><img src="https://swee.codes/icons/down.svg"></a>
|
||||||
|
<a class="softcard" style="display: inline-block;" title="Links parsed" href="#"><span id="links">...</span><br><img width="25px" src="https://swee.codes/icons/links.svg"></a>
|
||||||
|
<br>
|
||||||
|
<br>
|
||||||
|
<a class="download" style="background: #027ef9;" title="Refresh stats" onclick="refresh();"><img src="https://swee.codes/icons/refresh.svg"></a>
|
||||||
|
</center>
|
||||||
|
<script src="script.js"></script>
|
||||||
|
</body>
|
29
script.js
29
script.js
|
@ -1,32 +1,27 @@
|
||||||
var tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]'))
|
// Fetching the run value for the first time
|
||||||
var tooltipList = tooltipTriggerList.map(function (tooltipTriggerEl) {
|
|
||||||
return new bootstrap.Tooltip(tooltipTriggerEl)
|
|
||||||
})
|
|
||||||
const delay = ms => new Promise(res => setTimeout(res, ms));
|
|
||||||
fetch ("run.txt")
|
fetch ("run.txt")
|
||||||
.then(x => x.text())
|
.then(x => x.text())
|
||||||
.then(y => document.getElementById("run").innerHTML = y);
|
.then(y => document.getElementById("run").innerHTML = y);
|
||||||
|
// Fetching the block value for the first time
|
||||||
fetch ("block.txt")
|
fetch ("block.txt")
|
||||||
.then(x => x.text())
|
.then(x => x.text())
|
||||||
.then(y => document.getElementById("blocked").innerHTML = y);
|
.then(y => document.getElementById("blocked").innerHTML = y);
|
||||||
async function reboot(){
|
fetch ("link.txt")
|
||||||
document.getElementById("rebooticon").innerHTML = "<i class=\"fas fa-power-off fa-fade\"></i>"
|
|
||||||
fetch ("reboot.run")
|
|
||||||
.then(x => x.text())
|
.then(x => x.text())
|
||||||
.then(y => document.getElementById("rebooticon").innerHTML = y);
|
.then(y => document.getElementById("links").innerHTML = y);
|
||||||
await delay(2000)
|
|
||||||
document.getElementById("rebooticon").innerHTML = "<i class=\"fas fa-power-off\"></i>"
|
|
||||||
}
|
|
||||||
async function refresh(){
|
async function refresh(){
|
||||||
document.getElementById("refresh").innerHTML = "<i class=\"fas fa-sync fa-spin\"></i>"
|
// Refresh the HTML to show the spinners
|
||||||
document.getElementById("run").innerHTML = "<span class=\"spinner-grow\"></span>"
|
document.getElementById("run").innerHTML = "..."
|
||||||
document.getElementById("blocked").innerHTML = "<span class=\"spinner-grow\"></span>"
|
document.getElementById("blocked").innerHTML = "..."
|
||||||
|
document.getElementById("links").innerHTML = "..."
|
||||||
|
// Then fetch the values the same way as on the first part of the script.
|
||||||
fetch ("run.txt")
|
fetch ("run.txt")
|
||||||
.then(x => x.text())
|
.then(x => x.text())
|
||||||
.then(y => document.getElementById("run").innerHTML = y)
|
.then(y => document.getElementById("run").innerHTML = y)
|
||||||
fetch ("block.txt")
|
fetch ("block.txt")
|
||||||
.then(x => x.text())
|
.then(x => x.text())
|
||||||
.then(y => document.getElementById("blocked").innerHTML = y);
|
.then(y => document.getElementById("blocked").innerHTML = y);
|
||||||
await delay(2000)
|
fetch ("link.txt")
|
||||||
document.getElementById("refresh").innerHTML = "<i class=\"fas fa-refresh\"></i>"
|
.then(x => x.text())
|
||||||
|
.then(y => document.getElementById("links").innerHTML = y);
|
||||||
}
|
}
|
|
@ -1,30 +0,0 @@
|
||||||
from flask import Flask
|
|
||||||
from flask import send_file
|
|
||||||
from flask import request
|
|
||||||
from flask import redirect
|
|
||||||
import os
|
|
||||||
from pathlib import Path
|
|
||||||
from time import sleep as wait
|
|
||||||
app = Flask(__name__)
|
|
||||||
|
|
||||||
@app.route('/')
|
|
||||||
def index():
|
|
||||||
return send_file("sweebot.html", mimetype='text/html')
|
|
||||||
@app.route('/run.txt')
|
|
||||||
def run():
|
|
||||||
wait(2)
|
|
||||||
return send_file(str(Path.home()) + "/run.txt", mimetype='text/html')
|
|
||||||
@app.route('/block.txt')
|
|
||||||
def block():
|
|
||||||
wait(2)
|
|
||||||
return send_file(str(Path.home()) + "/block.txt", mimetype='text/html')
|
|
||||||
@app.route('/script.js')
|
|
||||||
def script():
|
|
||||||
return send_file("script.js", mimetype='application/javascript')
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
|
|
||||||
# run() method of Flask class runs the application
|
|
||||||
# on the local development server.
|
|
||||||
app.run(host='0.0.0.0',port=2001)
|
|
17
sweebot.html
17
sweebot.html
|
@ -1,17 +0,0 @@
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
||||||
<title>SweeBot dashboard</title>
|
|
||||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css" rel="stylesheet">
|
|
||||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js"></script>
|
|
||||||
<script src="https://kit.fontawesome.com/30bde606c1.js" crossorigin="anonymous"></script>
|
|
||||||
<body class="container text-white bg-dark">
|
|
||||||
<center>
|
|
||||||
<h1>SweeBot Dashboard</h1>
|
|
||||||
<a class="btn btn-success" data-bs-toggle="tooltip" title="Commands run" href="#"><h3 id="run"><span class="spinner-grow"></span></h3><i class="fas fa-comments"></i></a>
|
|
||||||
<a class="btn btn-danger" data-bs-toggle="tooltip" title="Commands refused" href="#"><h3 id="blocked"><span class="spinner-grow"></span></h3><i class="fas fa-ban"></i></a>
|
|
||||||
|
|
||||||
<br>
|
|
||||||
<br>
|
|
||||||
<a class="btn btn-primary" data-bs-toggle="tooltip" title="Refresh stats" onclick="refresh();" id="refresh"><i class="fas fa-sync"></i></a>
|
|
||||||
</center>
|
|
||||||
<script src="script.js"></script>
|
|
||||||
</body>
|
|
112
sweebot.py
112
sweebot.py
|
@ -1,4 +1,4 @@
|
||||||
__version__ = "0.0.2 Funni update"
|
__version__ = "0.0.2 Funni update" + ". https://git.swee.codes/MeowNex"
|
||||||
import socket
|
import socket
|
||||||
import subprocess
|
import subprocess
|
||||||
from time import sleep, time, ctime
|
from time import sleep, time, ctime
|
||||||
|
@ -16,21 +16,25 @@ from googleapiclient.discovery import build
|
||||||
|
|
||||||
run = 0
|
run = 0
|
||||||
block = 0
|
block = 0
|
||||||
|
parsed = 0
|
||||||
# Dashboard thread
|
# Dashboard thread
|
||||||
from flask import Flask, send_file
|
from flask import Flask, send_file
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
|
|
||||||
@app.route('/')
|
@app.route('/')
|
||||||
def index():
|
def index_html():
|
||||||
return send_file("sweebot.html", mimetype='text/html')
|
return send_file("dashboard.html", mimetype='text/html')
|
||||||
@app.route('/run.txt')
|
@app.route('/run.txt')
|
||||||
def run():
|
def runs():
|
||||||
return str(run)
|
return str(run)
|
||||||
@app.route('/block.txt')
|
@app.route('/block.txt')
|
||||||
def block():
|
def blocks():
|
||||||
return str(block)
|
return str(block)
|
||||||
|
@app.route('/link.txt')
|
||||||
|
def parses():
|
||||||
|
return str(parsed)
|
||||||
@app.route('/script.js')
|
@app.route('/script.js')
|
||||||
def script():
|
def script_js():
|
||||||
return send_file("script.js", mimetype='application/javascript')
|
return send_file("script.js", mimetype='application/javascript')
|
||||||
threading.Thread(target=app.run, daemon=True, kwargs={"port": 2005}).start()
|
threading.Thread(target=app.run, daemon=True, kwargs={"port": 2005}).start()
|
||||||
|
|
||||||
|
@ -200,7 +204,7 @@ class bot_irc:
|
||||||
|
|
||||||
|
|
||||||
server_irc = "127.0.0.1" # Use 127.0.0.1 for local ZNC
|
server_irc = "127.0.0.1" # Use 127.0.0.1 for local ZNC
|
||||||
port_irc = 6667 # NO SSL FOR YOU
|
port_irc = 5000 # NO SSL FOR YOU
|
||||||
channel_irc = ["##sweezero"]
|
channel_irc = ["##sweezero"]
|
||||||
botnick_irc = environ.get('SBnick')
|
botnick_irc = environ.get('SBnick')
|
||||||
botnickpass_irc =environ.get('SBuser')
|
botnickpass_irc =environ.get('SBuser')
|
||||||
|
@ -219,14 +223,10 @@ baps = ["T-T", "Ow!", "Beep!"]
|
||||||
pats = ["-w-", "Meep...", "Prr!"]
|
pats = ["-w-", "Meep...", "Prr!"]
|
||||||
meows_happy = ['Meow!', 'Nyaa~', 'Mrow.', 'Prr! :3', "Mrrp?", "Mreow.", "!woeM", "3: !rrP", "~aayN", "Mew!", "Moew!"]
|
meows_happy = ['Meow!', 'Nyaa~', 'Mrow.', 'Prr! :3', "Mrrp?", "Mreow.", "!woeM", "3: !rrP", "~aayN", "Mew!", "Moew!"]
|
||||||
meows_upset = ['Hiss!', "!ssiH", "Grrr..."]
|
meows_upset = ['Hiss!', "!ssiH", "Grrr..."]
|
||||||
|
my_self = ["MeowNexUS", "MeowNexU5", "MeowN3xUS"]
|
||||||
happiness = 5
|
happiness = 5
|
||||||
global times
|
global times
|
||||||
times = 0
|
times = 0
|
||||||
def update():
|
|
||||||
open(str(Path.home()) + "/run.txt", 'w').write(str(run))
|
|
||||||
open(str(Path.home()) + "/block.txt", 'w').write(str(block))
|
|
||||||
|
|
||||||
update()
|
|
||||||
def irci2():
|
def irci2():
|
||||||
irc2.connect_irc(
|
irc2.connect_irc(
|
||||||
server_irc, port_irc, channel_irc, "sweeB0t", botpass_irc, botnickpass_irc + "/B"
|
server_irc, port_irc, channel_irc, "sweeB0t", botpass_irc, botnickpass_irc + "/B"
|
||||||
|
@ -268,18 +268,24 @@ def restart():
|
||||||
irc2.irc_socket.close()
|
irc2.irc_socket.close()
|
||||||
irc3.irc_socket.close()
|
irc3.irc_socket.close()
|
||||||
exit(0)
|
exit(0)
|
||||||
def system(cmd, chan):
|
def system(cmd, chan, rstrip=False):
|
||||||
try:
|
try:
|
||||||
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||||
|
outpp = ""
|
||||||
for line in iter(p.stdout.readline, b''):
|
for line in iter(p.stdout.readline, b''):
|
||||||
if text != "" and text != " ":
|
if text != "" and text != " ":
|
||||||
|
if not rstrip:
|
||||||
multiline(line.rstrip(), chan)
|
multiline(line.rstrip(), chan)
|
||||||
|
else:
|
||||||
|
outpp += line.decode().rstrip() + " "
|
||||||
|
if rstrip:
|
||||||
|
multiline(outpp[:-1], chan)
|
||||||
p.stdout.close()
|
p.stdout.close()
|
||||||
p.wait()
|
p.wait()
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
multiline(cmd[0] + " not found", chan)
|
multiline(cmd[0] + " not found", chan)
|
||||||
except:
|
except:
|
||||||
multiline(traceback.format_exc())
|
multiline(traceback.format_exc(), chan)
|
||||||
irl2 = threading.Thread(target=irci2, daemon=True)
|
irl2 = threading.Thread(target=irci2, daemon=True)
|
||||||
irl2.start()
|
irl2.start()
|
||||||
irl3 = threading.Thread(target=irci3, daemon=True)
|
irl3 = threading.Thread(target=irci3, daemon=True)
|
||||||
|
@ -314,10 +320,9 @@ while True:
|
||||||
pass
|
pass
|
||||||
try:
|
try:
|
||||||
#if True:
|
#if True:
|
||||||
if "PRIVMSG" in text:
|
if "PRIVMSG" in text and not nick in my_self:
|
||||||
if "PRIVMSG" in text and command[0][0] == "$":
|
if "PRIVMSG" in text and command[0][0] == "$":
|
||||||
run+=1
|
run+=1
|
||||||
update()
|
|
||||||
if command[0] == "$ping":
|
if command[0] == "$ping":
|
||||||
if random(1,2) == 1:
|
if random(1,2) == 1:
|
||||||
irc.send_irc(channel, nick + ": Pnog")
|
irc.send_irc(channel, nick + ": Pnog")
|
||||||
|
@ -330,7 +335,7 @@ while True:
|
||||||
irc.send_irc(channel, nick + ": Nice try")
|
irc.send_irc(channel, nick + ": Nice try")
|
||||||
block+=1
|
block+=1
|
||||||
run-=1
|
run-=1
|
||||||
update()
|
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
if path.isfile(cwd + "/helps/" + " ".join(command[1:])):
|
if path.isfile(cwd + "/helps/" + " ".join(command[1:])):
|
||||||
|
@ -344,7 +349,7 @@ while True:
|
||||||
irc.send_irc(channel, "tip, ping, whoami, perms, version, figlet, tdfiglet, cowsay, uptime, cc, joke, botsnack. (restart, join, part, shell, config, pull.) Use '$help (command)' for explanation.")
|
irc.send_irc(channel, "tip, ping, whoami, perms, version, figlet, tdfiglet, cowsay, uptime, cc, joke, botsnack. (restart, join, part, shell, config, pull.) Use '$help (command)' for explanation.")
|
||||||
|
|
||||||
elif command[0] == "$tip":
|
elif command[0] == "$tip":
|
||||||
system(["fortune"], channel)
|
system(["/usr/games/fortune", "debian-hints"], channel, True)
|
||||||
|
|
||||||
elif command[0] == "$whoami":
|
elif command[0] == "$whoami":
|
||||||
if perms != "":
|
if perms != "":
|
||||||
|
@ -380,7 +385,7 @@ while True:
|
||||||
irc.send_irc(channel, nick + ": Permission denied.")
|
irc.send_irc(channel, nick + ": Permission denied.")
|
||||||
block+=1
|
block+=1
|
||||||
run-=1
|
run-=1
|
||||||
update()
|
|
||||||
|
|
||||||
elif command[0] == "$pull":
|
elif command[0] == "$pull":
|
||||||
if perms == "full" or "git" in perms.split(","):
|
if perms == "full" or "git" in perms.split(","):
|
||||||
|
@ -393,7 +398,7 @@ while True:
|
||||||
irc.send_irc(channel, nick + ": Permission denied.")
|
irc.send_irc(channel, nick + ": Permission denied.")
|
||||||
block+=1
|
block+=1
|
||||||
run-=1
|
run-=1
|
||||||
update()
|
|
||||||
|
|
||||||
elif command[0] == "$join":
|
elif command[0] == "$join":
|
||||||
if perms == "full" or "join" in perms.split(","):
|
if perms == "full" or "join" in perms.split(","):
|
||||||
|
@ -412,7 +417,7 @@ while True:
|
||||||
irc.send_irc(channel, nick + ": Permission denied.")
|
irc.send_irc(channel, nick + ": Permission denied.")
|
||||||
block+=1
|
block+=1
|
||||||
run-=1
|
run-=1
|
||||||
update()
|
|
||||||
|
|
||||||
elif command[0] == "$part":
|
elif command[0] == "$part":
|
||||||
if perms == "full" or "part" in perms.split(","):
|
if perms == "full" or "part" in perms.split(","):
|
||||||
|
@ -434,7 +439,7 @@ while True:
|
||||||
irc.send_irc(channel, nick + ": Permission denied.")
|
irc.send_irc(channel, nick + ": Permission denied.")
|
||||||
block+=1
|
block+=1
|
||||||
run-=1
|
run-=1
|
||||||
update()
|
|
||||||
|
|
||||||
elif command[0] == "$socket":
|
elif command[0] == "$socket":
|
||||||
if perms == "full":
|
if perms == "full":
|
||||||
|
@ -449,7 +454,7 @@ while True:
|
||||||
irc.send_irc(channel, nick + ": Permission denied.")
|
irc.send_irc(channel, nick + ": Permission denied.")
|
||||||
block+=1
|
block+=1
|
||||||
run-=1
|
run-=1
|
||||||
update()
|
|
||||||
|
|
||||||
elif command[0] == "$patpat" or command[0] == "$headpat":
|
elif command[0] == "$patpat" or command[0] == "$headpat":
|
||||||
if len(command) == 2:
|
if len(command) == 2:
|
||||||
|
@ -481,7 +486,8 @@ while True:
|
||||||
multiline(choice(meows_upset), channel)
|
multiline(choice(meows_upset), channel)
|
||||||
else:
|
else:
|
||||||
multiline(choice(meows_happy), channel)
|
multiline(choice(meows_happy), channel)
|
||||||
|
elif command[0] == "$stats":
|
||||||
|
multiline(f"{nick}: {run} command(s) run, {block} refused, and {parsed} link(s) parsed, check out https://irc-bot.swee.codes", channel)
|
||||||
elif command[0] == "$shell":
|
elif command[0] == "$shell":
|
||||||
if perms == "full":
|
if perms == "full":
|
||||||
#or "shell" in perms.split(",")
|
#or "shell" in perms.split(",")
|
||||||
|
@ -496,7 +502,7 @@ while True:
|
||||||
irc.send_irc(channel, nick + ": Permission denied.")
|
irc.send_irc(channel, nick + ": Permission denied.")
|
||||||
block+=1
|
block+=1
|
||||||
run-=1
|
run-=1
|
||||||
update()
|
|
||||||
|
|
||||||
elif command[0] == "$version":
|
elif command[0] == "$version":
|
||||||
irc.send_irc(channel, "This is SweeBot " + __version__)
|
irc.send_irc(channel, "This is SweeBot " + __version__)
|
||||||
|
@ -556,45 +562,15 @@ while True:
|
||||||
multiline(f"\x01ACTION gives a hug to {name}\x01", channel)
|
multiline(f"\x01ACTION gives a hug to {name}\x01", channel)
|
||||||
|
|
||||||
|
|
||||||
|
elif command[0] == "$sed":
|
||||||
#elif command[0] == "$sed":
|
if len(command) > 1:
|
||||||
# if len(command) > 1:
|
try:
|
||||||
#try:
|
|
||||||
#if True:
|
#if True:
|
||||||
# com = ['sed',"" + command[1] + ""]
|
raise Exception("WorkInProgress!!!")
|
||||||
# print(command[1])
|
except:
|
||||||
# texte = open("log-text-"+channel).read().split("\n")
|
print(traceback.format_exc())
|
||||||
# texte.reverse()
|
else:
|
||||||
# texte.pop(0)
|
irc.send_irc(channel, nick + ": What to correct?")
|
||||||
# texte.pop(0)
|
|
||||||
# print(texte)
|
|
||||||
# texttoreplace = ""
|
|
||||||
# j = 0
|
|
||||||
# broken = False
|
|
||||||
# for i in texte:
|
|
||||||
# if command[1].split("/")[1] in i:
|
|
||||||
# texttoreplace = i
|
|
||||||
# broken = True
|
|
||||||
# break
|
|
||||||
# j+=1
|
|
||||||
# if not broken:
|
|
||||||
# irc.send_irc(channel, "Unable to correct: '" + command[1].split("/")[1] + "' not found in any chat message.")
|
|
||||||
# continue
|
|
||||||
# namee = open("log-name-"+channel).read().split("\n")
|
|
||||||
# namee.reverse()
|
|
||||||
# namee.pop(0)
|
|
||||||
# namee.pop(0)
|
|
||||||
# namee = namee[j]
|
|
||||||
# open("temp","w").write(texttoreplace)
|
|
||||||
# com.append("temp")
|
|
||||||
# print(com)
|
|
||||||
# result = subprocess.run(com, stdout=subprocess.PIPE)
|
|
||||||
# output = result.stdout.decode('utf-8').split("\n")
|
|
||||||
# irc.send_irc(channel, "Correction using sed: <" + namee + "> " + output[0])
|
|
||||||
# #except Exception as ex:
|
|
||||||
# #irc.send_irc(channel, nick + ": " + ex.__class__.__name__)
|
|
||||||
# else:
|
|
||||||
# irc.send_irc(channel, nick + ": What to correct?")
|
|
||||||
|
|
||||||
|
|
||||||
elif command[0] == "$config":
|
elif command[0] == "$config":
|
||||||
|
@ -628,7 +604,7 @@ while True:
|
||||||
irc.send_irc(channel, nick + ": Permission denied")
|
irc.send_irc(channel, nick + ": Permission denied")
|
||||||
block+=1
|
block+=1
|
||||||
run-=1
|
run-=1
|
||||||
update()
|
|
||||||
else:
|
else:
|
||||||
multiline("Configuration for " + channel + ": " + " ".join(sbconfig.chansettings(channel)), channel)
|
multiline("Configuration for " + channel + ": " + " ".join(sbconfig.chansettings(channel)), channel)
|
||||||
except ex:
|
except ex:
|
||||||
|
@ -639,7 +615,7 @@ while True:
|
||||||
irc.send_irc(channel, nick + ": Nice try.")
|
irc.send_irc(channel, nick + ": Nice try.")
|
||||||
block+=1
|
block+=1
|
||||||
run-=1
|
run-=1
|
||||||
update()
|
|
||||||
else:
|
else:
|
||||||
if path.isfile("cc/" + command[0][1:]):
|
if path.isfile("cc/" + command[0][1:]):
|
||||||
try:
|
try:
|
||||||
|
@ -682,11 +658,12 @@ while True:
|
||||||
if content_type in allowedparse:
|
if content_type in allowedparse:
|
||||||
if e.ok:
|
if e.ok:
|
||||||
soup = BeautifulSoup(e.text, 'html.parser')
|
soup = BeautifulSoup(e.text, 'html.parser')
|
||||||
multiline("(" + nick + ") " + (soup.title.string if soup.title != None else "[No title provided]"), channel)
|
multiline("(" + nick + ") " + (" ".join(soup.title.string.splitlines())[:100] if soup.title != None else "[No title provided]"), channel)
|
||||||
else:
|
else:
|
||||||
multiline("(" + nick + ") [HTTP " + str(e.status_code) + "]", channel)
|
multiline("(" + nick + ") [HTTP " + str(e.status_code) + "]", channel)
|
||||||
else:
|
else:
|
||||||
multiline("(" + nick + ") [" + humanbytes(content_len) + " " + str(content_type) + "]", channel)
|
multiline("(" + nick + ") [" + humanbytes(content_len) + " " + str(content_type) + "]", channel)
|
||||||
|
parsed += 1
|
||||||
except rex.SSLError as ex:
|
except rex.SSLError as ex:
|
||||||
multiline("(" + nick + ") [SSL Error: " + str(ex.message) + "]", channel)
|
multiline("(" + nick + ") [SSL Error: " + str(ex.message) + "]", channel)
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
|
@ -699,11 +676,12 @@ while True:
|
||||||
if content_type in allowedparse:
|
if content_type in allowedparse:
|
||||||
if e.ok:
|
if e.ok:
|
||||||
soup = BeautifulSoup(e.text, 'html.parser')
|
soup = BeautifulSoup(e.text, 'html.parser')
|
||||||
multiline("(" + nick + ") " + (soup.title.string if soup.title != None else "[No title provided]"), channel)
|
multiline("(" + nick + ") " + (" ".join(soup.title.string.splitlines())[:100] if soup.title != None else "[No title provided]"), channel)
|
||||||
else:
|
else:
|
||||||
multiline("(" + nick + ") [HTTP " + str(e.status_code) + "]", channel)
|
multiline("(" + nick + ") [HTTP " + str(e.status_code) + "]", channel)
|
||||||
else:
|
else:
|
||||||
multiline("(" + nick + ") [" + humanbytes(content_len) + " " + str(content_type) + "]", channel)
|
multiline("(" + nick + ") [" + humanbytes(content_len) + " " + str(content_type) + "]", channel)
|
||||||
|
parsed += 1
|
||||||
except:
|
except:
|
||||||
print(traceback.format_exc())
|
print(traceback.format_exc())
|
||||||
elif "JOIN" in text and "#nixsanctuary" in text:
|
elif "JOIN" in text and "#nixsanctuary" in text:
|
||||||
|
|
Loading…
Reference in a new issue