File size: 1,888 Bytes
f772cc3
524177d
bc84237
f772cc3
 
 
 
 
 
 
66b13bc
d866edc
f772cc3
7e4c309
0ffdf29
78e5f3a
0ffdf29
 
1ea3c95
0ffdf29
dfe7482
9b2ca80
0ffdf29
 
7e4c309
f772cc3
 
7e4c309
0ffdf29
 
7e4c309
2453cb2
53c0719
9b2ca80
0ffdf29
fc98dd9
0ffdf29
 
 
7e4c309
 
f772cc3
 
 
 
 
 
 
 
 
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
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> ",
    "Good to have you with us! :hugging: Got any cool projects you feel like sharing? :eyes:",
    "Welcome aboard 🦜 β›΅",
    "Hello friends! :wave: Where are you folks from? :globe_with_meridians: <:hugging_earth:968126923408564306> ",
    "Glad you're here! Welcome! 🎊",
    "Happy to have you with us! <:blobcatlove:1103376097841790986> How much have you played around with ML/AI? :computer:",    
    "New faces, new friends! Welcome! πŸ˜„πŸ‘‹"
]
welcome_messages_counter = 0

@bot.event
async def on_member_join(member):
    global welcome_list 
    global welcome_messages_counter
    
    welcome_list.append(member.mention)
    if len(welcome_list) > 4:
        channel = bot.get_channel(900017973547388988)
        message = f'{welcome_messages[welcome_messages_counter]} {welcome_list[0]} {welcome_list[1]} {welcome_list[2]} {welcome_list[3]}'
        if welcome_messages_counter == 6:
            welcome_messages_counter = -1
        welcome_messages_counter = welcome_messages_counter + 1
        
        #message = f'Welcome to the server, {welcome_list[0]} {welcome_list[1]} {welcome_list[2]} {welcome_list[3]}! :hugging_face:'
        await channel.send(message)
        welcome_list = []

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()