Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
updating based on tests
Browse files
app.py
CHANGED
|
@@ -23,22 +23,40 @@ welcome_messages = [
|
|
| 23 |
]
|
| 24 |
welcome_messages_counter = 0
|
| 25 |
wait_messages_counter = 0
|
|
|
|
| 26 |
|
| 27 |
@bot.event
|
| 28 |
async def on_member_join(member):
|
| 29 |
-
global welcome_list
|
| 30 |
global welcome_messages_counter
|
| 31 |
-
|
| 32 |
welcome_list.append(member.mention)
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
|
| 43 |
DISCORD_TOKEN = os.environ.get("DISCORD_TOKEN", None)
|
| 44 |
def run_bot():
|
|
@@ -47,4 +65,4 @@ threading.Thread(target=run_bot).start()
|
|
| 47 |
def greet(name):
|
| 48 |
return "Hello " + name + "!"
|
| 49 |
demo = gr.Interface(fn=greet, inputs="text", outputs="text")
|
| 50 |
-
demo.launch()
|
|
|
|
| 23 |
]
|
| 24 |
welcome_messages_counter = 0
|
| 25 |
wait_messages_counter = 0
|
| 26 |
+
channel_id = 900017973547388988 # 900017973547388988 = #introduce-yourself
|
| 27 |
|
| 28 |
@bot.event
|
| 29 |
async def on_member_join(member):
|
| 30 |
+
global welcome_list
|
| 31 |
global welcome_messages_counter
|
|
|
|
| 32 |
welcome_list.append(member.mention)
|
| 33 |
+
|
| 34 |
+
if len(welcome_list) >= 8:
|
| 35 |
+
channel = bot.get_channel(channel_id)
|
| 36 |
+
print(f"channel: {channel}")
|
| 37 |
+
# Check if the channel has received at least 3 messages from other users (non-bot?) since the last message was sent
|
| 38 |
+
count = 0
|
| 39 |
+
print(f"count: {count}")
|
| 40 |
+
async for message in channel.history(limit=3):
|
| 41 |
+
if message.author.bot:
|
| 42 |
+
print(f"This is a bot message! -> {message.content}")
|
| 43 |
+
else:
|
| 44 |
+
count = count + 1
|
| 45 |
+
print(f"count: {count}")
|
| 46 |
+
if count == 3:
|
| 47 |
+
print(f"count: {count}")
|
| 48 |
+
# 8 users, can change this
|
| 49 |
+
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]}'
|
| 50 |
+
if welcome_messages_counter == 6:
|
| 51 |
+
welcome_messages_counter = -1
|
| 52 |
+
welcome_messages_counter = welcome_messages_counter + 1
|
| 53 |
+
|
| 54 |
+
await channel.send(message)
|
| 55 |
+
welcome_list = []
|
| 56 |
+
|
| 57 |
+
else:
|
| 58 |
+
print(f"welcome_list: {welcome_list}")
|
| 59 |
+
|
| 60 |
|
| 61 |
DISCORD_TOKEN = os.environ.get("DISCORD_TOKEN", None)
|
| 62 |
def run_bot():
|
|
|
|
| 65 |
def greet(name):
|
| 66 |
return "Hello " + name + "!"
|
| 67 |
demo = gr.Interface(fn=greet, inputs="text", outputs="text")
|
| 68 |
+
demo.launch()
|