Compare commits

...
15 Commits
Author SHA1 Message Date
marc 0205ce03d8 fix makefile 2023-08-14 00:42:36 +02:00
marc 2898bc2afd fix discord bot with poetry 2023-08-14 00:37:12 +02:00
marc 946c7382e5 Merge branch 'master' into poetry 2023-08-09 08:19:00 +02:00
marc e9e26cbe89 no .python-version pls 2023-08-09 08:18:41 +02:00
marc 5e098345d3 poetry lock changed 2023-08-08 18:49:22 +02:00
marc 57184f0b21 poetry first lock file 2023-08-06 16:04:33 +02:00
marc b8cbe8c80c poetry 2023-08-06 15:43:59 +02:00
marc 9e6a89fe78 update 2023-01-15 18:27:37 +01:00
marc 78d3c42040 update 2023-01-15 18:26:27 +01:00
marc c354ca6362 env var 2023-01-15 18:08:25 +01:00
marc 0306f11305 funding 2022-12-20 17:02:27 +01:00
marc 3668ea7d98 fix 2022-06-01 21:10:06 +02:00
marc 534050a991 update 2022-05-23 01:25:32 +02:00
marc 2893f516dc latest 2022-05-22 00:04:41 +02:00
marc be20e90f08 colorama 2022-05-22 00:03:50 +02:00
12 changed files with 3317 additions and 960 deletions
+6
View File
@@ -1 +1,7 @@
liberapay: marcpartensky
patreon: marcpartensky
github: marcpartensky
custom:
# - monero:43J2XmRtjDPRLD35UsYGH2AZamFBQz7dt4VdvZXVm3SuadTrvcoXUXBRUNHqukFte23Q5TWXqhbwaLJJgoVQzzbe2AJDANQ
- https://paypal.me/marcpartensky
- https://buymeacoffee.com/marcpartensky
+6
View File
@@ -38,6 +38,12 @@ 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 }}
+1
View File
@@ -8,3 +8,4 @@ venv/
.env
.env.dev
./config/marc_store.yml
.python-version
+5 -9
View File
@@ -1,8 +1,8 @@
start:
pipenv run python .
poetry run python .
update:
pipenv update
pipenv lock -r > requirements.txt
poetry update
poetry export --output requirements.txt
dev:
docker-compose -f docker-compose.yml up -d --build --force-recreate --remove-orphans dev
prod:
@@ -14,12 +14,8 @@ push: build
deploy: push
DOCKER_HOST=ssh://vps docker service update vps_esclave
setup:
pip install pipenv
pipenv shell
pipenv install
poetry install
poetry shell
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
+1
View File
@@ -36,6 +36,7 @@ unidecode = '*'
future = '*'
selenium = "*"
fake-useragent = "*"
colorama = "*"
[dev-packages]
black = "*"
Generated
+1092 -871
View File
File diff suppressed because it is too large Load Diff
+8 -3
View File
@@ -17,7 +17,7 @@ from dotenv import load_dotenv
load_dotenv()
from config.config import prefix, masters, delete_after_time, status, access
from config.config import prefix, masters, access
from config.credentials import token, client_id
from discord.ext import commands, tasks
@@ -39,7 +39,11 @@ 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)
client = commands.Bot(command_prefix=prefix, case_insensitive=True)
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.id = client_id
@@ -56,7 +60,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."""
@@ -79,6 +83,7 @@ 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}**")
+1 -1
View File
@@ -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 = "https://ialab.marcpartensky.com"
ialab_bot_url = os.environ.get("IALAB_URL") or "https://ialab.marcpartensky.com"
roles = ["@Maître", "@Admin"]
+19 -12
View File
@@ -1,5 +1,4 @@
# from mongocollection import MongoCollection
import discord
from pymongo import MongoClient
from pymongo.database import Database
from pymongo.collection import Collection, ObjectId
@@ -102,7 +101,7 @@ class MongoCluster(MongoClient):
def __getitem__(self, item):
"""Return a mongo database given its key."""
item = super().__getitem__(item)
if isinstance(item, pymongo.database.Database):
if isinstance(item, Database):
return MongoDatabase.from_database(item)
else:
return item
@@ -120,7 +119,7 @@ class MongoDatabase(Database):
def __getitem__(self, item):
"""Return a mongo collection given a key."""
item = super().__getitem__(item)
if isinstance(item, pymongo.collection.Collection):
if isinstance(item, Collection):
return MongoCollection.from_collection(item)
else:
return item
@@ -201,10 +200,10 @@ class MongoCollection(Collection):
else:
self.insert_one(arg, **kwargs)
def insert_many(self, posts, **kwargs):
def insert_many(self, posts):
"""Insert many posts."""
posts = [self.treat(post) for post in posts]
super().insert_many(post)
super().insert_many(posts)
def __contains__(self, id):
return self.seek_one(_id=id) != None
@@ -241,10 +240,9 @@ class MongoCollection(Collection):
def __delitem__(self, id):
"""Delete a post."""
print(id)
print(self.find_one(dict(_id=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."""
@@ -264,12 +262,14 @@ 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):
if att in type(self).keys or att in dir(self):
"""Set attribute to a collection."""
# print(att, value)
if att in type(self).keys or att in dir(self) or att.startswith("_"):
super().__setattr__(att, value)
else:
self.__setitem__(att, value)
@@ -497,7 +497,14 @@ class User(DictObject):
# command = db.commands.find(machin=34, bidule=324)
if __name__ == "__main__":
mongo_url = "mongodb+srv://esclave:esclave@discord-cluster-5ckni.mongodb.net/test"
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}"
cl = MongoCluster(mongo_url)
# print('cluster over')
esclave = cl.esclave
Generated
+2069
View File
File diff suppressed because it is too large Load Diff
+50
View File
@@ -0,0 +1,50 @@
[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"
+59 -64
View File
@@ -1,85 +1,80 @@
#
# These requirements were autogenerated by pipenv
# To regenerate from the project's Pipfile, run:
#
# pipenv lock --requirements
#
-i https://pypi.org/simple
aenum==2.2.6
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'
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.5.18.1; python_version >= '3.6'
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.12; 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'
certifi==2022.12.7
cffi==1.15.1
charset-normalizer==2.1.1
click==7.1.2
colorama==0.4.6
commonmark==0.9.1
cryptography==37.0.2
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.1
Deprecated==1.2.13
discord.py==2.1.0
dnspython==2.3.0
dpy-http-server==0.1.0
fake-useragent==0.1.11
exceptiongroup==1.1.0
fake-useragent==1.1.1
fbchat==1.9.7
future==0.18.2
gtts==2.2.4
h11==0.13.0; python_version >= '3.6'
frozenlist==1.3.3
future==0.18.3
gTTS==2.2.4
h11==0.14.0
html2text==2020.1.16
idna==3.3; python_version >= '3'
jaraco.context==4.1.1; python_version >= '3.6'
joblib==1.1.0; python_version >= '3.6'
idna==3.4
importlib-resources==5.10.2
jaraco.context==4.2.0
joblib==1.2.0
libretranslatepy==2.1.1
lxml==4.8.0; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4'
more-itertools==8.13.0; python_version >= '3.5'
multidict==6.0.2; python_version >= '3.7'
lxml==4.9.2
more-itertools==9.0.0
multidict==6.0.4
nightcore==1.1.0
numpy==1.22.4; python_version >= '3.8'
outcome==1.1.0; python_version >= '3.6'
numpy==1.24.1
outcome==1.2.0
paho-mqtt==1.6.1
pexpect==4.8.0
pillow==9.1.1
Pillow==9.4.0
profanity-check==1.0.3
progressbar2==4.0.0
progressbar2==4.2.0
ptyprocess==0.7.0
pycparser==2.21
pydub==0.23.1
pygithub==1.55
pygments==2.12.0; python_version >= '3.6'
pyjwt==2.4.0; python_version >= '3.6'
pymongo==4.1.1
pynacl==1.4.0; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'
pyopenssl==22.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.20.0
python-utils==3.2.3; python_version >= '3.7'
pyyaml==6.0
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
requests-futures==1.0.0
requests==2.27.1
rich==12.4.1
scikit-learn==1.1.1; python_version >= '3.8'
scipy==1.8.1; python_version < '3.11' and python_version >= '3.8'
selenium==4.1.5
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'
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
sortedcontainers==2.4.0
soupsieve==2.3.2.post1; python_version >= '3.6'
stem==1.8.0
threadpoolctl==3.1.0; python_version >= '3.6'
soupsieve==2.3.2.post1
stem==1.8.1
threadpoolctl==3.1.0
torrequest==0.1.0
translate==3.6.1
trio-websocket==0.9.2; python_version >= '3.5'
trio==0.20.0; python_version >= '3.7'
typing-extensions==4.2.0; python_version < '3.9'
unidecode==1.3.4
urllib3[secure,socks]==1.26.9; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4' and python_version < '4'
trio==0.22.0
trio-websocket==0.9.2
typing_extensions==4.4.0
Unidecode==1.3.6
urllib3==1.26.14
wikipedia==1.4.0
wolframalpha==5.0.0
wrapt==1.14.1; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4'
wsproto==1.1.0; python_version >= '3.7'
xmltodict==0.13.0; python_version >= '3.4'
yarl==1.7.2; python_version >= '3.6'
wrapt==1.14.1
wsproto==1.2.0
xmltodict==0.13.0
yarl==1.8.2
youtube-dl==2021.12.17
zipp==3.11.0