Created
May 7, 2019 15:19
-
-
Save bashbaugh/029450b45925a7dd840ed88366be1a05 to your computer and use it in GitHub Desktop.
A simple discord bot that generates spam (strings of random characters) when a user types `$spamhere`.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Spambot | |
# A simple discord bot that generates spam (strings of random characters) when a user types `$spamhere`. | |
# Written by Benjamin A | |
from time import sleep | |
import string | |
import random | |
import os | |
import logging | |
import discord | |
MAX_SPAM_MESSAGES = 200 | |
ALLOWED_SPAM_CHANNELS = ['bot-spam'] | |
MESSAGE_DELAY = 0.5 | |
try: | |
DISCORD_TOKEN = os.environ['SPAMBOT_TOKEN'] | |
except: | |
DISCORD_TOKEN = 'token' | |
logging.basicConfig(level=logging.INFO) | |
client = discord.Client() | |
@client.event | |
async def on_ready(): | |
print('Logged in as {0.user}'.format(client)) | |
activity = discord.Game("SPAMMING YOUR LIFE") | |
await client.change_presence(status=discord.Status.idle, activity=activity) | |
@client.event | |
async def on_message(message): | |
if message.author == client.user: | |
return | |
if message.content.startswith('$spamhere'): | |
if message.channel.name in ALLOWED_SPAM_CHANNELS: | |
await message.channel.send("YOU ASKED FOR IT") | |
sleep(2) | |
for i in range(MAX_SPAM_MESSAGES): | |
spam_msg = ''.join(random.choice(string.ascii_uppercase + string.digits) for l in range(random.randint(1, 1000))) | |
await message.channel.send(spam_msg) | |
sleep(MESSAGE_DELAY) | |
else: | |
await message.channel.send('I will not spam this channel.') | |
client.run(DISCORD_TOKEN) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment