Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
93be37fc91 |
@@ -1,7 +1 @@
|
||||
liberapay: marcpartensky
|
||||
patreon: marcpartensky
|
||||
github: marcpartensky
|
||||
custom:
|
||||
# - monero:43J2XmRtjDPRLD35UsYGH2AZamFBQz7dt4VdvZXVm3SuadTrvcoXUXBRUNHqukFte23Q5TWXqhbwaLJJgoVQzzbe2AJDANQ
|
||||
- https://paypal.me/marcpartensky
|
||||
- https://buymeacoffee.com/marcpartensky
|
||||
|
||||
@@ -38,12 +38,6 @@ jobs:
|
||||
with:
|
||||
push: true
|
||||
tags: marcpartensky/discord-bot:v${{ github.run_number }}.${{ steps.tag.outputs.tag }}
|
||||
- name: Build and push
|
||||
id: docker_build
|
||||
uses: docker/build-push-action@v2
|
||||
with:
|
||||
push: true
|
||||
tags: marcpartensky/discord-bot:latest
|
||||
|
||||
test-python-versions:
|
||||
runs-on: ${{ matrix.os }}
|
||||
|
||||
@@ -8,4 +8,3 @@ venv/
|
||||
.env
|
||||
.env.dev
|
||||
./config/marc_store.yml
|
||||
.python-version
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
start:
|
||||
poetry run python .
|
||||
pipenv run python .
|
||||
update:
|
||||
poetry update
|
||||
poetry export --output requirements.txt
|
||||
pipenv lock --pre --clear
|
||||
pipenv lock -r > requirements.txt
|
||||
dev:
|
||||
docker-compose -f docker-compose.yml up -d --build --force-recreate --remove-orphans dev
|
||||
prod:
|
||||
@@ -14,8 +14,12 @@ push: build
|
||||
deploy: push
|
||||
DOCKER_HOST=ssh://vps docker service update vps_esclave
|
||||
setup:
|
||||
poetry install
|
||||
poetry shell
|
||||
pip install pipenv
|
||||
pipenv shell
|
||||
pipenv install
|
||||
recreate:
|
||||
docker-compose -f docker-compose.yml up --force-recreate dev
|
||||
fixwithbrew:
|
||||
brew install python@3.8
|
||||
sudo ln -sf /home/linuxbrew/.linuxbrew/Cellar/python@3.8/3.8.12_1/bin/python3.8 /usr/bin/python3.8
|
||||
|
||||
|
||||
@@ -36,7 +36,6 @@ unidecode = '*'
|
||||
future = '*'
|
||||
selenium = "*"
|
||||
fake-useragent = "*"
|
||||
colorama = "*"
|
||||
|
||||
[dev-packages]
|
||||
black = "*"
|
||||
@@ -44,4 +43,4 @@ pylint = "*"
|
||||
jedi = "*"
|
||||
|
||||
[requires]
|
||||
python_version = "3.8.13"
|
||||
python_version = "3.8.12"
|
||||
|
||||
Generated
+889
-1109
File diff suppressed because it is too large
Load Diff
+3
-8
@@ -17,7 +17,7 @@ from dotenv import load_dotenv
|
||||
|
||||
load_dotenv()
|
||||
|
||||
from config.config import prefix, masters, access
|
||||
from config.config import prefix, masters, delete_after_time, status, access
|
||||
from config.credentials import token, client_id
|
||||
from discord.ext import commands, tasks
|
||||
|
||||
@@ -39,11 +39,7 @@ from discord.ext import commands, tasks
|
||||
# # If we are in a guild, we allow for the user to mention us or use any of the prefixes in our list.
|
||||
# return commands.when_mentioned_or(*prefixes)(bot, message)
|
||||
|
||||
intents = discord.Intents.default()
|
||||
intents.message_content = True
|
||||
|
||||
# client = commands.Bot(command_prefix=prefix, case_insensitive=True)
|
||||
client = commands.Bot(command_prefix=prefix, intents=intents)
|
||||
client = commands.Bot(command_prefix=prefix, case_insensitive=True)
|
||||
client.id = client_id
|
||||
|
||||
|
||||
@@ -60,7 +56,7 @@ class Main(commands.Cog):
|
||||
self.load_cogs()
|
||||
self.load_status()
|
||||
self.load_icloud()
|
||||
# self.api: PycloudService = None
|
||||
self.api: PycloudService = None
|
||||
|
||||
def load_icloud(self):
|
||||
"""Charge l'api d'icloud."""
|
||||
@@ -83,7 +79,6 @@ class Main(commands.Cog):
|
||||
@commands.command()
|
||||
async def environment(self, ctx: commands.Context):
|
||||
"""Affiche l'environnement dans lequel le bot tourne."""
|
||||
print("environment")
|
||||
host = os.environ.get("HOST")
|
||||
await ctx.send(f"> Environment: **{host}**")
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ class VoiceChannel(commands.Cog):
|
||||
logging.info(before)
|
||||
channel: discord.VoiceChannel = before.channel
|
||||
members: List[discord.Member] = channel.members
|
||||
# await self.mute_if_single(members)
|
||||
await self.mute_if_single(members)
|
||||
await self.leave_if_alone(members, before.channel)
|
||||
|
||||
async def join(
|
||||
@@ -83,7 +83,7 @@ class VoiceChannel(commands.Cog):
|
||||
logging.info(after)
|
||||
channel: discord.VoiceChannel = after.channel
|
||||
members: List[discord.Member] = channel.members
|
||||
# await self.mute_if_single(members)
|
||||
await self.mute_if_single(members)
|
||||
await self.notify_on_join(member)
|
||||
await self.join_if_single(members)
|
||||
|
||||
@@ -102,7 +102,7 @@ class VoiceChannel(commands.Cog):
|
||||
before_members: List[discord.Member] = before_channel.members
|
||||
after_channel: discord.VoiceChannel = after.channel
|
||||
after_members: List[discord.Member] = after_channel.members
|
||||
# await self.mute_if_single(before_members)
|
||||
await self.mute_if_single(before_members)
|
||||
await self.join_if_single(after_members)
|
||||
|
||||
async def mute_if_single(self, members: List[discord.Member]):
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@ link = "https://discordapp.com/oauth2/authorize?&client_id=703347349623144549&sc
|
||||
prefix = os.environ.get("DISCORD_PREFIX") or "."
|
||||
masters = [478552571510915072] # , 219949869220102147]
|
||||
wolfram = wolframalpha.Client(wolfram_alpha_id)
|
||||
ialab_bot_url = os.environ.get("IALAB_URL") or "https://ialab.marcpartensky.com"
|
||||
ialab_bot_url = "https://ialab.marcpartensky.com"
|
||||
|
||||
roles = ["@Maître", "@Admin"]
|
||||
|
||||
|
||||
+12
-19
@@ -1,4 +1,5 @@
|
||||
# from mongocollection import MongoCollection
|
||||
import discord
|
||||
from pymongo import MongoClient
|
||||
from pymongo.database import Database
|
||||
from pymongo.collection import Collection, ObjectId
|
||||
@@ -101,7 +102,7 @@ class MongoCluster(MongoClient):
|
||||
def __getitem__(self, item):
|
||||
"""Return a mongo database given its key."""
|
||||
item = super().__getitem__(item)
|
||||
if isinstance(item, Database):
|
||||
if isinstance(item, pymongo.database.Database):
|
||||
return MongoDatabase.from_database(item)
|
||||
else:
|
||||
return item
|
||||
@@ -119,7 +120,7 @@ class MongoDatabase(Database):
|
||||
def __getitem__(self, item):
|
||||
"""Return a mongo collection given a key."""
|
||||
item = super().__getitem__(item)
|
||||
if isinstance(item, Collection):
|
||||
if isinstance(item, pymongo.collection.Collection):
|
||||
return MongoCollection.from_collection(item)
|
||||
else:
|
||||
return item
|
||||
@@ -200,10 +201,10 @@ class MongoCollection(Collection):
|
||||
else:
|
||||
self.insert_one(arg, **kwargs)
|
||||
|
||||
def insert_many(self, posts):
|
||||
def insert_many(self, posts, **kwargs):
|
||||
"""Insert many posts."""
|
||||
posts = [self.treat(post) for post in posts]
|
||||
super().insert_many(posts)
|
||||
super().insert_many(post)
|
||||
|
||||
def __contains__(self, id):
|
||||
return self.seek_one(_id=id) != None
|
||||
@@ -240,9 +241,10 @@ class MongoCollection(Collection):
|
||||
|
||||
def __delitem__(self, id):
|
||||
"""Delete a post."""
|
||||
# print(self.find_one(dict(_id=id)))
|
||||
print(id)
|
||||
print(self.find_one(dict(_id=id)))
|
||||
self.delete_one(dict(_id=id))
|
||||
# print(self.find_one(dict(_id=id)))
|
||||
print(self.find_one(dict(_id=id)))
|
||||
|
||||
def post(self, post):
|
||||
"""Replace or insert a post."""
|
||||
@@ -262,14 +264,12 @@ class MongoCollection(Collection):
|
||||
"""Set a default post."""
|
||||
if id in self:
|
||||
post.update(self[id]._dict)
|
||||
# print(1, post)
|
||||
print(1, post)
|
||||
self[id] = post
|
||||
# print(2, self[id])
|
||||
print(2, self[id])
|
||||
|
||||
def __setattr__(self, att, value):
|
||||
"""Set attribute to a collection."""
|
||||
# print(att, value)
|
||||
if att in type(self).keys or att in dir(self) or att.startswith("_"):
|
||||
if att in type(self).keys or att in dir(self):
|
||||
super().__setattr__(att, value)
|
||||
else:
|
||||
self.__setitem__(att, value)
|
||||
@@ -497,14 +497,7 @@ class User(DictObject):
|
||||
# command = db.commands.find(machin=34, bidule=324)
|
||||
|
||||
if __name__ == "__main__":
|
||||
import os
|
||||
from dotenv import load_dotenv
|
||||
load_dotenv()
|
||||
|
||||
cluster = os.environ["DISCORD_MONGO_CLUSTER"]
|
||||
username = os.environ["DISCORD_MONGO_USERNAME"]
|
||||
password = os.environ["DISCORD_MONGO_PASSWORD"]
|
||||
mongo_url = f"mongodb+srv://{username}:{password}@{cluster}"
|
||||
mongo_url = "mongodb+srv://esclave:esclave@discord-cluster-5ckni.mongodb.net/test"
|
||||
cl = MongoCluster(mongo_url)
|
||||
# print('cluster over')
|
||||
esclave = cl.esclave
|
||||
|
||||
Generated
-2069
File diff suppressed because it is too large
Load Diff
@@ -1,50 +0,0 @@
|
||||
[tool.poetry]
|
||||
name = "discord-bot"
|
||||
version = "0.1.0"
|
||||
description = "A discord bot multi purpose."
|
||||
authors = ["Marc Partensky <marc.partensky@gmail.com>"]
|
||||
license = "GPL2"
|
||||
readme = "README.md"
|
||||
packages = [{include = "discord_bot"}]
|
||||
|
||||
[tool.poetry.dependencies]
|
||||
python = "3.8.13"
|
||||
beautifulsoup4 = "*"
|
||||
# "discord.py[voice]" = "*"
|
||||
fbchat = "*"
|
||||
# fbchat = {git = "git://github.com/carpedm20/fbchat.git"}
|
||||
nightcore = "*"
|
||||
profanity-check = "*"
|
||||
progressbar2 = "*"
|
||||
# pyicloud = "*"
|
||||
pymongo = "*"
|
||||
requests = "*"
|
||||
rich = "*"
|
||||
translate = "*"
|
||||
wikipedia = "*"
|
||||
wolframalpha = "*"
|
||||
html2text = "*"
|
||||
gTTS = "2.2.1"
|
||||
Pillow = "*"
|
||||
PyGithub = "*"
|
||||
PyYAML = "*"
|
||||
youtube_dl = "*"
|
||||
python-dotenv = "*"
|
||||
dpy-http-server = "*"
|
||||
pexpect = "*"
|
||||
# libs/sherlock
|
||||
dnspython = "*"
|
||||
requests-futures = "*"
|
||||
torrequest = "*"
|
||||
# libs/google
|
||||
unidecode = '*'
|
||||
future = '*'
|
||||
selenium = "*"
|
||||
fake-useragent = "*"
|
||||
colorama = "*"
|
||||
py-cord = "^2.4.1"
|
||||
|
||||
|
||||
[build-system]
|
||||
requires = ["poetry-core"]
|
||||
build-backend = "poetry.core.masonry.api"
|
||||
+67
-62
@@ -1,80 +1,85 @@
|
||||
aenum==2.2.6
|
||||
aiohttp==3.8.3
|
||||
aiosignal==1.3.1
|
||||
async-generator==1.10
|
||||
async-timeout==4.0.2
|
||||
attrs==22.2.0
|
||||
beautifulsoup4==4.11.1
|
||||
certifi==2022.12.7
|
||||
cffi==1.15.1
|
||||
charset-normalizer==2.1.1
|
||||
click==7.1.2
|
||||
colorama==0.4.6
|
||||
#
|
||||
# These requirements were autogenerated by pipenv
|
||||
# To regenerate from the project's Pipfile, run:
|
||||
#
|
||||
# pipenv lock --requirements
|
||||
#
|
||||
|
||||
-i https://pypi.org/simple
|
||||
aiohttp==3.7.4.post0; python_version >= '3.6'
|
||||
async-generator==1.10; python_version >= '3.5'
|
||||
async-timeout==3.0.1; python_full_version >= '3.5.3'
|
||||
attrs==21.4.0; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4'
|
||||
beautifulsoup4==4.10.0
|
||||
certifi==2021.10.8
|
||||
cffi==1.15.0
|
||||
chardet==4.0.0; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4'
|
||||
charset-normalizer==2.0.10; python_version >= '3'
|
||||
click==7.1.2; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4'
|
||||
colorama==0.4.4; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4'
|
||||
commonmark==0.9.1
|
||||
Deprecated==1.2.13
|
||||
discord.py==2.1.0
|
||||
dnspython==2.3.0
|
||||
cryptography==36.0.1
|
||||
deprecated==1.2.13; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'
|
||||
discord.py[voice]==1.7.3; python_full_version >= '3.5.3'
|
||||
dnspython==2.2.0
|
||||
dpy-http-server==0.1.0
|
||||
exceptiongroup==1.1.0
|
||||
fake-useragent==1.1.1
|
||||
fbchat==1.9.7
|
||||
frozenlist==1.3.3
|
||||
future==0.18.3
|
||||
gTTS==2.2.4
|
||||
h11==0.14.0
|
||||
fake-useragent==0.1.11
|
||||
fbchat==2.0.0a5
|
||||
future==0.18.2
|
||||
gtts==2.2.3
|
||||
h11==0.13.0; python_version >= '3.6'
|
||||
html2text==2020.1.16
|
||||
idna==3.4
|
||||
importlib-resources==5.10.2
|
||||
jaraco.context==4.2.0
|
||||
joblib==1.2.0
|
||||
idna==3.3; python_version >= '3'
|
||||
jaraco.context==4.1.1; python_version >= '3.6'
|
||||
joblib==1.1.0; python_version >= '3.6'
|
||||
libretranslatepy==2.1.1
|
||||
lxml==4.9.2
|
||||
more-itertools==9.0.0
|
||||
multidict==6.0.4
|
||||
lxml==4.7.1; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4'
|
||||
more-itertools==8.12.0; python_version >= '3.5'
|
||||
multidict==5.2.0; python_version >= '3.6'
|
||||
nightcore==1.1.0
|
||||
numpy==1.24.1
|
||||
outcome==1.2.0
|
||||
numpy==1.22.1; python_version >= '3.8'
|
||||
outcome==1.1.0; python_version >= '3.6'
|
||||
paho-mqtt==1.6.1
|
||||
pexpect==4.8.0
|
||||
Pillow==9.4.0
|
||||
pillow==9.0.0
|
||||
profanity-check==1.0.3
|
||||
progressbar2==4.2.0
|
||||
progressbar2==4.0.0
|
||||
ptyprocess==0.7.0
|
||||
pycparser==2.21
|
||||
pydub==0.23.1
|
||||
PyGithub==1.57
|
||||
Pygments==2.14.0
|
||||
PyJWT==2.6.0
|
||||
pymongo==4.3.3
|
||||
PyNaCl==1.5.0
|
||||
PySocks==1.7.1
|
||||
python-dotenv==0.21.0
|
||||
python-utils==3.4.5
|
||||
PyYAML==6.0
|
||||
requests==2.28.2
|
||||
pygithub==1.55
|
||||
pygments==2.11.2; python_version >= '3.5'
|
||||
pyjwt==2.3.0; python_version >= '3.6'
|
||||
pymongo==4.0.1
|
||||
pynacl==1.4.0; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'
|
||||
pyopenssl==21.0.0
|
||||
pysocks==1.7.1; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'
|
||||
python-dotenv==0.19.2
|
||||
python-utils==3.1.0; python_version >= '3.7'
|
||||
pyyaml==6.0
|
||||
requests-futures==1.0.0
|
||||
rich==13.1.0
|
||||
scikit-learn==1.2.0
|
||||
scipy==1.10.0
|
||||
selenium==4.7.2
|
||||
six==1.16.0
|
||||
sniffio==1.3.0
|
||||
requests==2.27.1
|
||||
rich==11.0.0
|
||||
scikit-learn==1.0.2; python_version >= '3.7'
|
||||
scipy==1.8.0rc2; python_version < '3.11' and python_version >= '3.8'
|
||||
selenium==4.1.0
|
||||
six==1.16.0; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'
|
||||
sniffio==1.2.0; python_version >= '3.5'
|
||||
sortedcontainers==2.4.0
|
||||
soupsieve==2.3.2.post1
|
||||
stem==1.8.1
|
||||
threadpoolctl==3.1.0
|
||||
soupsieve==2.3.1; python_version >= '3.6'
|
||||
stem==1.8.0
|
||||
threadpoolctl==3.0.0; python_version >= '3.6'
|
||||
torrequest==0.1.0
|
||||
translate==3.6.1
|
||||
trio==0.22.0
|
||||
trio-websocket==0.9.2
|
||||
typing_extensions==4.4.0
|
||||
Unidecode==1.3.6
|
||||
urllib3==1.26.14
|
||||
trio-websocket==0.9.2; python_version >= '3.5'
|
||||
trio==0.19.0; python_version >= '3.6'
|
||||
typing-extensions==4.0.1; python_version >= '3.6'
|
||||
unidecode==1.3.2
|
||||
urllib3[secure]==1.26.8; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4' and python_version < '4'
|
||||
wikipedia==1.4.0
|
||||
wolframalpha==5.0.0
|
||||
wrapt==1.14.1
|
||||
wsproto==1.2.0
|
||||
xmltodict==0.13.0
|
||||
yarl==1.8.2
|
||||
wrapt==1.13.3; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4'
|
||||
wsproto==1.0.0; python_full_version >= '3.6.1'
|
||||
xmltodict==0.12.0
|
||||
yarl==1.7.2; python_version >= '3.6'
|
||||
youtube-dl==2021.12.17
|
||||
zipp==3.11.0
|
||||
|
||||
Reference in New Issue
Block a user