merge master into pi
This commit is contained in:
commit
fcc773e2d9
13
Pipfile
Normal file
13
Pipfile
Normal file
@ -0,0 +1,13 @@
|
||||
[[source]]
|
||||
url = "https://pypi.org/simple"
|
||||
verify_ssl = true
|
||||
name = "pypi"
|
||||
|
||||
[packages]
|
||||
"fs.dropboxfs" = {git = "https://github.com/rkhwaja/fs.dropboxfs.git"}
|
||||
"discord.py" = {ref = "rewrite", git = "https://github.com/Rapptz/discord.py"}
|
||||
|
||||
[dev-packages]
|
||||
|
||||
[requires]
|
||||
python_version = "3.7"
|
29
Pipfile.lock
generated
Normal file
29
Pipfile.lock
generated
Normal file
@ -0,0 +1,29 @@
|
||||
{
|
||||
"_meta": {
|
||||
"hash": {
|
||||
"sha256": "0b00547c8080ca98592603203321ca0aa4c3be1d1d1d0d69ac0fb28b78619350"
|
||||
},
|
||||
"pipfile-spec": 6,
|
||||
"requires": {
|
||||
"python_version": "3.7"
|
||||
},
|
||||
"sources": [
|
||||
{
|
||||
"name": "pypi",
|
||||
"url": "https://pypi.org/simple",
|
||||
"verify_ssl": true
|
||||
}
|
||||
]
|
||||
},
|
||||
"default": {
|
||||
"discord.py": {
|
||||
"git": "https://github.com/Rapptz/discord.py",
|
||||
"ref": "00a659c6526b2445162b52eaf970adbd22c6d35d"
|
||||
},
|
||||
"fs.dropboxfs": {
|
||||
"git": "https://github.com/rkhwaja/fs.dropboxfs.git",
|
||||
"ref": "68988a25143a8ea760bc6dfb2a715f6f98ac31c7"
|
||||
}
|
||||
},
|
||||
"develop": {}
|
||||
}
|
27
main.py
27
main.py
@ -7,16 +7,15 @@ import os
|
||||
import sys
|
||||
|
||||
import discord
|
||||
from fs.ftpfs import FTPFS
|
||||
from fs.dropboxfs import DropboxFS
|
||||
from fs.osfs import OSFS
|
||||
from fs import path
|
||||
|
||||
fileSystem = None
|
||||
|
||||
if os.environ.get("FTP_ADDRESS", False) and os.environ.get("FTP_USER", False) and os.environ.get("FTP_PASS", False):
|
||||
if os.environ.get("DROPBOX_ACCESS_TOKEN", False):
|
||||
print("FTP")
|
||||
fileSystem = FTPFS(os.environ["FTP_ADDRESS"], user=os.environ["FTP_USER"], passwd=os.environ["FTP_PASS"],
|
||||
timeout=600)
|
||||
fileSystem = DropboxFS(os.environ["DROPBOX_ACCESS_TOKEN"])
|
||||
else:
|
||||
print("OS")
|
||||
fileSystem = OSFS(os.getcwd())
|
||||
@ -82,6 +81,7 @@ class Guild:
|
||||
self.modules = []
|
||||
self.load_config()
|
||||
self.update_modules()
|
||||
self.save_config()
|
||||
|
||||
def load_config(self):
|
||||
if self.bot.fileSystem.exists(self.config_file):
|
||||
@ -110,6 +110,9 @@ class Guild:
|
||||
self.config["modules"].append("help")
|
||||
module_to_load = list(set(self.config["modules"]))
|
||||
|
||||
self.config["modules"] = module_to_load
|
||||
self.save_config()
|
||||
|
||||
for module in module_to_load:
|
||||
# Try to load all modules by name
|
||||
if module not in self.bot.modules.keys():
|
||||
@ -139,7 +142,7 @@ class Guild:
|
||||
|
||||
class FoBot(discord.Client):
|
||||
|
||||
def __init__(self, config='foBot_config', *args, **kwargs):
|
||||
def __init__(self, config='/foBot_config', *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
self.config_folder = config
|
||||
self.config = {"guilds": {}}
|
||||
@ -209,16 +212,16 @@ class FoBot(discord.Client):
|
||||
async def on_resumed(self):
|
||||
info("foBot is resumed.")
|
||||
|
||||
async def on_guild_join(self, guild):
|
||||
self.load_modules()
|
||||
self.load_config()
|
||||
self.save_config()
|
||||
|
||||
async def on_error(self, event, *args, **kwargs):
|
||||
error("foBot encounter an error.", exc_info=True)
|
||||
if os.environ.get("FTP_ADDRESS", False) and \
|
||||
os.environ.get("FTP_USER", False) and \
|
||||
os.environ.get("FTP_PASS", False):
|
||||
if os.environ.get("DROPBOX_ACCESS_TOKEN", False):
|
||||
print("FTP")
|
||||
self.fileSystem = FTPFS(os.environ["FTP_ADDRESS"],
|
||||
user=os.environ["FTP_USER"],
|
||||
passwd=os.environ["FTP_PASS"],
|
||||
timeout=600)
|
||||
self.fileSystem = DropboxFS(os.environ["DROPBOX_ACCESS_TOKEN"])
|
||||
else:
|
||||
print("OS")
|
||||
self.fileSystem = OSFS(os.getcwd())
|
||||
|
@ -1,13 +0,0 @@
|
||||
aiohttp==3.3.2
|
||||
async-timeout==3.0.0
|
||||
attrs==18.1.0
|
||||
cffi==1.11.5
|
||||
chardet==3.0.4
|
||||
git+https://github.com/Rapptz/discord.py@rewrite#egg=discord.py
|
||||
idna==2.7
|
||||
multidict==4.3.1
|
||||
pycparser==2.18
|
||||
six==1.11.0
|
||||
websockets==6.0
|
||||
yarl==1.2.6
|
||||
fs
|
Loading…
Reference in New Issue
Block a user