working concurrency between forgejo and discord
This commit is contained in:
parent
08a91a55f0
commit
33a493ba87
6 changed files with 41 additions and 25 deletions
BIN
.ecoplus.py.swp
BIN
.ecoplus.py.swp
Binary file not shown.
BIN
.forgejo.py.swp
BIN
.forgejo.py.swp
Binary file not shown.
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -2,6 +2,8 @@ secrets.txt
|
|||
*.db
|
||||
*.swp
|
||||
|
||||
env/
|
||||
|
||||
# Byte-compiled / optimized / DLL files
|
||||
__pycache__/
|
||||
*.py[cod]
|
||||
|
|
47
ecoplus.py
47
ecoplus.py
|
@ -1,31 +1,12 @@
|
|||
import sys
|
||||
import random
|
||||
import discord
|
||||
import datetime
|
||||
import threading
|
||||
|
||||
import discord
|
||||
import sqlite3
|
||||
|
||||
client = 0
|
||||
|
||||
async def forgejo_send_message(msg:str):
|
||||
try:
|
||||
guild = client.get_guild(1157767629738618941)
|
||||
chan = guild.get_channel(1344400105821831209)
|
||||
await chan.send(msg)
|
||||
except Exception as err:
|
||||
print(f"15 : {err}")
|
||||
|
||||
if __name__ != "__main__":
|
||||
exit()
|
||||
|
||||
database = sqlite3.connect("bdd.db")
|
||||
cursor = database.cursor()
|
||||
|
||||
try:
|
||||
cursor.execute("CREATE TABLE casino (id INT PRIMARY KEY, cash INT)")
|
||||
database.commit()
|
||||
except:
|
||||
print("La table existe déja")
|
||||
import interface
|
||||
|
||||
secrets_file = open(sys.argv[1], mode="rt")
|
||||
secrets = secrets_file.read()
|
||||
|
@ -40,6 +21,19 @@ intents.moderation = True
|
|||
|
||||
client = discord.Client(intents=intents, activity=discord.Game(name='En train de niquer des mères'))
|
||||
|
||||
interface.client = client
|
||||
|
||||
import forgejo
|
||||
|
||||
database = sqlite3.connect("bdd.db")
|
||||
cursor = database.cursor()
|
||||
|
||||
try:
|
||||
cursor.execute("CREATE TABLE casino (id INT PRIMARY KEY, cash INT)")
|
||||
database.commit()
|
||||
except:
|
||||
print("La table existe déja")
|
||||
|
||||
guilds = []
|
||||
|
||||
globals()["gmembers"] = {}
|
||||
|
@ -220,4 +214,13 @@ async def on_message(message):
|
|||
print(err)
|
||||
await message.channel.send("Commande non reconnue !")
|
||||
|
||||
def do_forgejo_thread():
|
||||
print("229")
|
||||
forgejo.app.run(port=5000)
|
||||
|
||||
forgejo_thread = threading.Thread()
|
||||
forgejo_thread.run = do_forgejo_thread
|
||||
|
||||
print("227")
|
||||
forgejo_thread.start()
|
||||
client.run(token)
|
||||
|
|
|
@ -18,11 +18,11 @@
|
|||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
# SOFTWARE.
|
||||
|
||||
|
||||
from flask import Flask, request
|
||||
import logging, requests, os
|
||||
import re
|
||||
import ecoplus
|
||||
|
||||
import interface
|
||||
|
||||
LOGLEVEL = os.environ.get('LOGLEVEL', 'INFO').upper()
|
||||
logging.basicConfig(level=LOGLEVEL)
|
||||
|
@ -180,6 +180,7 @@ def main():
|
|||
if msg:
|
||||
msg = f"*{msg}*"
|
||||
app.logger.info(msg)
|
||||
await forgejo_send_message(msg)
|
||||
interface.forgejo_send_message(msg)
|
||||
|
||||
return "ACK"
|
||||
|
||||
|
|
10
interface.py
Normal file
10
interface.py
Normal file
|
@ -0,0 +1,10 @@
|
|||
client = 0
|
||||
|
||||
async def forgejo_send_message(msg:str):
|
||||
try:
|
||||
guild = client.get_guild(1157767629738618941)
|
||||
chan = guild.get_channel(1344400105821831209)
|
||||
await chan.send(msg)
|
||||
except Exception as err:
|
||||
print(f"16 : {err}")
|
||||
|
Loading…
Add table
Reference in a new issue