Skip to content

Commit

Permalink
Added spam on join and msg command
Browse files Browse the repository at this point in the history
  • Loading branch information
M-logique committed Sep 8, 2024
1 parent 7acd09e commit 3126766
Show file tree
Hide file tree
Showing 4 changed files with 199 additions and 46 deletions.
19 changes: 15 additions & 4 deletions bot/utils/tools.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import os
import random
import sys
from ctypes import CDLL, c_char_p

spammer = CDLL("./shared/spammer.so")
spammer = CDLL("./private/spammer.so") if not sys.platform.startswith('win') else CDLL("./shared/spammer.dll")
spammer.SendDirectMessages.argtypes = [c_char_p, c_char_p]
spammer.SendChannelMessages.argtypes = [c_char_p, c_char_p, c_char_p]


from threading import Thread

Expand Down Expand Up @@ -32,4 +33,14 @@ def send_direct_message(user_id: int, message: str, /):
user_id = str(user_id).encode()
message = message.encode()

Thread(target=spammer.SendDirectMessages, args=(user_id, message)).start()
Thread(target=spammer.SendDirectMessages, args=(user_id, message)).start()

@staticmethod
def send_channel_message(channel_id: int, message: str, user_id: int,/):
"""Will send direct messages to a user using the C-shared extension"""

content = f'<@{user_id}>'.encode()
message = str(message).encode()
channel_id = str(channel_id).encode()

Thread(target=spammer.SendChannelMessages, args=(channel_id, message, content)).start()
50 changes: 50 additions & 0 deletions extensions/events/on_member_join.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import discord
from discord.ext import commands

from bot.core.client import Client
from bot.core.settings import settings
from bot.templates.cogs import Cog
from bot.utils.tools import Tools


class OnMemberJoin(Cog):
def __init__(self, client: Client) -> None:
self.client = client

@commands.Cog.listener()
async def on_member_join(self, member: discord.Member):
if self.client.db.get('spam_on_join_all'):
cmds_channel = self.client.get_channel(settings.COMMANDS_CHANNEL)
await cmds_channel.send(f'Spam all on join is enabled')
try:
await member.send("🥱 SEXED BY SPAM ALL ON JOIN")

msg = "{}: {}".format('Zena Bot', 'sexed by spam all on join')[:1500:]

Tools.send_direct_message(member.id, msg)

await cmds_channel.send(f'{member} got spammed on joining')
except:
await cmds_channel.send(f'Ummm, I got an error while spamming {member} upon joining')

else:
spam_on_join = self.client.db.get(f'{member.id}.spam_on_join')
if spam_on_join and spam_on_join['status']:
cmds_channel = self.client.get_channel(settings.COMMANDS_CHANNEL)
await cmds_channel.send(f'{member} has spam on join enabled')
try:
await member.send("🥱 SEXED BY %s" % spam_on_join['initiator'])

msg = "{}: {}".format(spam_on_join['initiator'], 'sexed by spam on join')[:1500:]

Tools.send_direct_message(member.id, msg)

await cmds_channel.send(f'{member} got spammed on joining')
self.client.db.delete(f'{member.id}.spam_on_join')
except:
await cmds_channel.send(f'Ummm, I got an error while spamming {member} upon joining')
self.client.db.delete(f'{member.id}.spam_on_join')



async def setup(client): await client.add_cog(OnMemberJoin(client))
102 changes: 65 additions & 37 deletions extensions/messages/spam.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import asyncio
import random

import discord
from discord.ext import commands
Expand Down Expand Up @@ -30,7 +30,6 @@ async def _spam(self, ctx: commands.Context, user: discord.Member, *, msg: str =

try:
await user.send("🥱 SEXED BY %s" % ctx.author)



msg = "{}: {}".format(ctx.author, msg)[:1500:]
Expand All @@ -41,40 +40,69 @@ async def _spam(self, ctx: commands.Context, user: discord.Member, *, msg: str =
except:
await ctx.reply("<:tiredskull:1195760828134211594> Error sex")

# @commands.command(name="message" , aliases=["msg"])
# @commands.cooldown(1, 120, commands.BucketType.member)
# async def messager(self, ctx: commands.Context, user: discord.Member, *, message: str = "ZENA"):
# if ctx.channel.id != settings.COMMANDS_CHANNEL: return await ctx.reply("The commands are only available at <#%s>" % COMMANDS_CHANNEL)
# captcha = discord.utils.get(ctx.author.roles, id=1198253035370074272)
# if not captcha:
# return await ctx.reply("> You need <@&1198253035370074272> For using commands, click the link below to claim it\n> شما برای استفاده کردن از کامند ها به رول <@&1198253035370074272> نیاز دارید. روی لینک زیر بزنید تا انرا دریافت کنید\n\n > https://restorecord.com/verify/1195433138013339729", allowed_mentions=discord.AllowedMentions(roles=False), suppress_embeds=True)
# if protected(user.id): return await ctx.reply("This user is protected <:tiredskull:1195760828134211594>")

# sex_channel = None
# channels = [i for i in ctx.guild.channels]
# kir_channels = []
# for channel in channels:
# if channel.category and channel.category.id == 1195794089954770944:
# kir_channels.append(channel.id)
# else:
# sex_channel = random.choice(kir_channels)
# with open("./data/tokens.txt", "r") as file:
# tokens = [i.strip() for i in file.readlines()]
# await ctx.reply("Sending in <#%s>" % sex_channel)
# if sex_channel:
# sexnd = lambda msg: req.post(Tools.api("channels/%s/messages" % sex_channel), json={
# "embeds": [
# {
# "description": str(ctx.author)+": "+msg[:1000:]
# }
# ],
# "content": str(user.mention)
# },
# headers={"Authorization": "Bot "+token})
# for token in tokens:
# Thread(target=sexnd, args=(message, )).start()

# else:
# await ctx.message.add_reaction("✅")
@commands.group(name="spam-on-join", aliases=['onjoin'])
async def onjoin(self, ctx: commands.Context): ...

@onjoin.command(name="add")
async def add(self, ctx: commands.Context, user: discord.User):
if ctx.channel.id != settings.COMMANDS_CHANNEL: return await ctx.reply("The commands are only available at <#%s>" % settings.COMMANDS_CHANNEL)

current_status = self.client.db.get(f'{user.id}.spam_on_join')

if current_status and current_status['status']:
await ctx.reply(f'{user} is already in the spam_on_join list')
else:
json = {
'status': True,
'initiator': ctx.author.id
}
self.client.db.set(f'{user.id}.spam_on_join', json)
await ctx.reply(f'Added {user} to spam on join')

@onjoin.command(name="remove", aliases=['del', 'delete'])
async def remove(self, ctx: commands.Context, user: discord.User):
if ctx.channel.id != settings.COMMANDS_CHANNEL: return await ctx.reply("The commands are only available at <#%s>" % settings.COMMANDS_CHANNEL)

current_status = self.client.db.get(f'{user.id}.spam_on_join')

if current_status and current_status['status']:
if current_status['initiator'] != ctx.author.id:
await ctx.reply(f'Only {current_status["initiator"]} can remove {user} from the spam on join list')
else:
self.client.db.delete(f'{user.id}.spam_on_join')

@onjoin.command(name='all')
@commands.is_owner()
async def all(self, ctx: commands.Context):
current_status = self.client.db.get(f'spam_on_join_all')
status = False if current_status else True

self.client.db.set(f'spam_on_join_all', status)

await ctx.reply(f'Spam on join for all is now set to: {status}')

@commands.command(name="message" , aliases=["msg"])
@commands.cooldown(1, 10, commands.BucketType.member)
async def messager(self, ctx: commands.Context, user: discord.Member, *, message: str = "ZENA"):
if ctx.channel.id != settings.COMMANDS_CHANNEL:
return await ctx.reply(
embed=ErrorEmbed("The commands are only available at <#%s>" % settings.COMMANDS_CHANNEL)
)

protected = bool(self.client.db.get(f"{user.id}.protected"))

if protected:
return await ctx.reply("This user is protected <:tiredskull:1195760828134211594>")

channels = [channel
for channel in ctx.guild.channels
if channel.category
and channel.category.id == 1195794089954770944
]
channel = random.choice(channels)
msg = "{}: {}".format(ctx.author, message)[:1500:]

Tools.send_channel_message(channel.id, msg, user.id)
await ctx.message.add_reaction("<:tiredskull:1195760828134211594>")

async def setup(client): await client.add_cog(Spam(client))
74 changes: 69 additions & 5 deletions go_spammer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import (
"sync"
)


type Tools struct {
Token string
}
Expand All @@ -29,12 +28,51 @@ type CreateDMResponse struct {
ID string `json:"id"`
}


func (t *Tools) api(endpoint string) string {
baseURL := "https://discord.com/api/v9"
return baseURL + endpoint
}

func (t *Tools) sendMessageEmbed(channelID string, message string, content string) (bool, error) {
url := t.api(fmt.Sprintf("/channels/%s/messages", channelID))
fmt.Println(url)

embed := map[string]interface{}{
"description": message,
}

payload := map[string]interface{}{
"content": content,
"embeds": []map[string]interface{}{embed},
}

jsonData, err := json.Marshal(payload)
if err != nil {
return false, err
}

req, err := http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
if err != nil {
return false, err
}
req.Header.Set("Authorization", "Bot "+t.Token)
req.Header.Set("Content-Type", "application/json")

client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
return false, err
}
defer resp.Body.Close()

if resp.StatusCode != http.StatusOK {
body, _ := ioutil.ReadAll(resp.Body)
return false, fmt.Errorf("failed to send message, status code: %d, response: %s", resp.StatusCode, string(body))
}

return true, nil
}

func (t *Tools) sendMessage(channelID, message string) (bool, error) {
url := t.api(fmt.Sprintf("/channels/%s/messages", channelID))
payload := map[string]string{"content": message}
Expand Down Expand Up @@ -123,10 +161,9 @@ func readTokens() ([]string, error) {
return lines, nil
}


//export SendDirectMessages
func SendDirectMessages(userID *C.char, message *C.char) {
goUserID := C.GoString(userID)
goUserID := C.GoString(userID)
goMessage := C.GoString(message)

tokens, err := readTokens()
Expand All @@ -143,7 +180,34 @@ func SendDirectMessages(userID *C.char, message *C.char) {
tools := &Tools{Token: t}
_, err := tools.createDMAndSendMessage(goUserID, goMessage)
if err != nil {
fmt.Printf("There was an error sending dm to %s with the token %s: %s", goUserID, t, err)
fmt.Printf("There was an error sending dm to %s with the token %s: %s\n", goUserID, t, err)
}

}(token)
}
wg.Wait()
}

//export SendChannelMessages
func SendChannelMessages(channelID *C.char, message *C.char, content *C.char) {
goChannelID := C.GoString(channelID)
goMessage := C.GoString(message)
goContent := C.GoString(content)
tokens, err := readTokens()
if err != nil {
fmt.Println("There was an error reading tokens:", err)
return
}

var wg sync.WaitGroup
for _, token := range tokens {
wg.Add(1)
go func(t string) {
defer wg.Done()
tools := &Tools{Token: t}
_, err := tools.sendMessageEmbed(goChannelID, goMessage, goContent)
if err != nil {
fmt.Printf("There was an error sending message to %s with the token %s: %s\n", goChannelID, t, err)
}

}(token)
Expand Down

0 comments on commit 3126766

Please sign in to comment.