parent
22d74d7f1f
commit
67ced4e7bf
1 changed files with 29 additions and 3 deletions
32
sweebot.py
32
sweebot.py
|
@ -1,4 +1,4 @@
|
|||
__version__ = "1.0.1 AI update" + ". https://git.swee.codes/swee/MeowNex"
|
||||
__version__ = "1.0.2 DOcker-SHELL update" + ". https://git.swee.codes/swee/MeowNex"
|
||||
import socket
|
||||
import subprocess
|
||||
from time import sleep, time, ctime
|
||||
|
@ -17,6 +17,8 @@ from googleapiclient.discovery import build
|
|||
import uuid
|
||||
import ssl
|
||||
import requests
|
||||
import docker
|
||||
dock = docker.from_env()
|
||||
global lastquery
|
||||
AIurl = environ["AIurl"]
|
||||
AIsession = requests.Session()
|
||||
|
@ -60,7 +62,7 @@ def ai_response_truncate(uuidd):
|
|||
else:
|
||||
abrt(404)
|
||||
threading.Thread(target=app.run, daemon=True, kwargs={"port": 2005}).start()
|
||||
|
||||
cntr = None
|
||||
# YouTube API
|
||||
DEVELOPER_KEY = environ["ytapi"]
|
||||
headers = {
|
||||
|
@ -663,7 +665,31 @@ while True:
|
|||
irc.send_irc(channel, nick + ": Permission denied.")
|
||||
block+=1
|
||||
run-=1
|
||||
|
||||
|
||||
elif command[0] == "$dopull":
|
||||
irc.send_irc(channel, nick + ":[...] Please wait, pulling docker image...")
|
||||
image = dock.images.pull('alpine')
|
||||
irc.send_irc(channel, nick + ":[OK] Pulled docker image, running command now.")
|
||||
elif command[0] == "$doshell":
|
||||
if len(command) > 1:
|
||||
try:
|
||||
if cntr == None:
|
||||
cntr = dock.containers.run('alpine', "/bin/ash", detach=True, tty=True)
|
||||
_, stream = cntr.exec_run(cmd=" ".join(command[1:]))
|
||||
multiline(stream, channel)
|
||||
except Exception as ex:
|
||||
irc.send_irc(channel, nick + ":[ERR] Traceback:")
|
||||
multiline(traceback.format_exc(), channel)
|
||||
else:
|
||||
irc.send_irc(channel, nick + ":[ERR] ")
|
||||
elif command[0] == "$doreset":
|
||||
if cntr == None:
|
||||
irc.send_irc(channel, nick + ":[OK] No container is loaded yet.")
|
||||
else:
|
||||
cntr.remove()
|
||||
cntr = None
|
||||
irc.send_irc(channel, nick + ":[OK] Done.")
|
||||
|
||||
|
||||
elif command[0] == "$version":
|
||||
irc.send_irc(channel, "This is MeowNexUS IRC " + __version__)
|
||||
|
|
Loading…
Add table
Reference in a new issue