Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
File size: 2,781 Bytes
f772cc3 524177d bc84237 f772cc3 66b13bc d866edc f772cc3 7e4c309 0ffdf29 52be157 0ffdf29 dfc1a6d 03b1212 7e4c309 f772cc3 c295c3c 0ffdf29 7e4c309 c295c3c beb0a96 c8ad5b9 beb0a96 f772cc3 c295c3c |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
import discord
import os
import threading
from discord.ext import commands
import gradio_client
import gradio as gr
from gradio_client import Client
DISCORD_TOKEN = os.environ.get("DISCORD_TOKEN", None)
intents = discord.Intents.all()
bot = commands.Bot(command_prefix='!', intents=intents)
welcome_list = []
welcome_messages = [
"Welcome to the community <:hugging_croissant:1103375763207622656> \n",
"Good to have you with us! :hugging: Got any cool projects you feel like sharing? :eyes: \n",
"Welcome aboard π¦ β΅ \n",
"Hello friends! :wave: Where are you folks from? :globe_with_meridians: <:hugging_earth:968126923408564306> \n",
"Glad you're here! Welcome! π \n",
"Happy to have you with us! <:blobcatlove:1103376097841790986> How much have you played around with ML/AI? :computer: \n",
"New faces, new friends! Welcome! ππ \n"
]
welcome_messages_counter = 0
wait_messages_counter = 0
channel_id = 900017973547388988 # 900017973547388988 = #introduce-yourself
@bot.event
async def on_member_join(member):
global welcome_list
global welcome_messages_counter
welcome_list.append(member.mention)
if len(welcome_list) >= 8:
channel = bot.get_channel(channel_id)
print(f"channel: {channel}")
# Check if the channel has received at least 3 messages from other users (non-bot?) since the last message was sent
count = 0
print(f"count: {count}")
async for message in channel.history(limit=3):
if message.author.bot:
print(f"This is a bot message! -> {message.content}")
else:
count = count + 1
print(f"count: {count}")
if count == 3:
print(f"count: {count}")
# 8 users, can change this
message = f'{welcome_messages[welcome_messages_counter]} {welcome_list[0]} {welcome_list[1]} {welcome_list[2]} {welcome_list[3]} {welcome_list[4]} {welcome_list[5]} {welcome_list[6]} {welcome_list[7]}'
if welcome_messages_counter == 6:
welcome_messages_counter = -1
welcome_messages_counter = welcome_messages_counter + 1
await channel.send(message)
welcome_list = []
else:
print(f"welcome_list: {welcome_list}")
@bot.event
async def on_message(message):
if message.channel.id == 900017973547388988:
await message.add_reaction('π€')
await bot.process_commands(message)
DISCORD_TOKEN = os.environ.get("DISCORD_TOKEN", None)
def run_bot():
bot.run(DISCORD_TOKEN)
threading.Thread(target=run_bot).start()
def greet(name):
return "Hello " + name + "!"
demo = gr.Interface(fn=greet, inputs="text", outputs="text")
demo.launch() |