merge master into pi

This commit is contained in:
louis chauvet 2018-09-01 21:39:39 +02:00
commit fcc773e2d9
4 changed files with 57 additions and 25 deletions

13
Pipfile Normal file
View 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
View 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
View File

@ -7,16 +7,15 @@ import os
import sys import sys
import discord import discord
from fs.ftpfs import FTPFS from fs.dropboxfs import DropboxFS
from fs.osfs import OSFS from fs.osfs import OSFS
from fs import path from fs import path
fileSystem = None 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") print("FTP")
fileSystem = FTPFS(os.environ["FTP_ADDRESS"], user=os.environ["FTP_USER"], passwd=os.environ["FTP_PASS"], fileSystem = DropboxFS(os.environ["DROPBOX_ACCESS_TOKEN"])
timeout=600)
else: else:
print("OS") print("OS")
fileSystem = OSFS(os.getcwd()) fileSystem = OSFS(os.getcwd())
@ -82,6 +81,7 @@ class Guild:
self.modules = [] self.modules = []
self.load_config() self.load_config()
self.update_modules() self.update_modules()
self.save_config()
def load_config(self): def load_config(self):
if self.bot.fileSystem.exists(self.config_file): if self.bot.fileSystem.exists(self.config_file):
@ -110,6 +110,9 @@ class Guild:
self.config["modules"].append("help") self.config["modules"].append("help")
module_to_load = list(set(self.config["modules"])) module_to_load = list(set(self.config["modules"]))
self.config["modules"] = module_to_load
self.save_config()
for module in module_to_load: for module in module_to_load:
# Try to load all modules by name # Try to load all modules by name
if module not in self.bot.modules.keys(): if module not in self.bot.modules.keys():
@ -139,7 +142,7 @@ class Guild:
class FoBot(discord.Client): class FoBot(discord.Client):
def __init__(self, config='foBot_config', *args, **kwargs): def __init__(self, config='/foBot_config', *args, **kwargs):
super().__init__(*args, **kwargs) super().__init__(*args, **kwargs)
self.config_folder = config self.config_folder = config
self.config = {"guilds": {}} self.config = {"guilds": {}}
@ -209,16 +212,16 @@ class FoBot(discord.Client):
async def on_resumed(self): async def on_resumed(self):
info("foBot is resumed.") 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): async def on_error(self, event, *args, **kwargs):
error("foBot encounter an error.", exc_info=True) error("foBot encounter an error.", exc_info=True)
if os.environ.get("FTP_ADDRESS", False) and \ if os.environ.get("DROPBOX_ACCESS_TOKEN", False):
os.environ.get("FTP_USER", False) and \
os.environ.get("FTP_PASS", False):
print("FTP") print("FTP")
self.fileSystem = FTPFS(os.environ["FTP_ADDRESS"], self.fileSystem = DropboxFS(os.environ["DROPBOX_ACCESS_TOKEN"])
user=os.environ["FTP_USER"],
passwd=os.environ["FTP_PASS"],
timeout=600)
else: else:
print("OS") print("OS")
self.fileSystem = OSFS(os.getcwd()) self.fileSystem = OSFS(os.getcwd())

View File

@ -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