Skip to content

Commit

Permalink
Added a choice of pause time between sending spam messages
Browse files Browse the repository at this point in the history
  • Loading branch information
neluckoff committed Sep 29, 2022
1 parent 37428ad commit 6fca935
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 25 deletions.
2 changes: 1 addition & 1 deletion examples/mail_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
mail.send_message('friend@gmail.com')

# Start spamming by user list
mail.spam_messages(['friend1@gmail.com', 'friend2@gmail.com', 'friend3@gmail.com'])
mail.spam_messages(['friend1@gmail.com', 'friend2@gmail.com', 'friend3@gmail.com'], delay_time=1.5)

# Start bombarding one user with messages
mail.bombing_message('friend@gmail.com', 100)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from io import open
from setuptools import setup

version = '1.2.3'
version = '1.2.4'

with open('README.md', encoding='utf-8') as f:
long_description = f.read()
Expand Down
2 changes: 1 addition & 1 deletion social_spam/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@
from .whatsapp import WhatsApp

__author__ = 'neluckoff'
__version__ = '1.2.3'
__version__ = '1.2.4'
__email__ = 'neluckoff@gmail.com'
10 changes: 6 additions & 4 deletions social_spam/mail.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,33 +128,35 @@ def send_message(self, mail_receiver: str) -> None:
self.server.sendmail(self.username, mail_receiver, self.message.as_string())
self.server.quit()

def spam_messages(self, mail_receiver: list) -> None:
def spam_messages(self, mail_receiver: list, delay_time: float = 1) -> None:
"""
Start mailing to all elements of the array (1 message each)
Args:
mail_receiver (list): everyone's email
delay_time (float): delay time between sending emails
"""
self.server.login(self.username, self.password)
with alive_bar(len(mail_receiver), force_tty=True) as bar:
for user in mail_receiver:
self.server.sendmail(self.username, user, self.message.as_string())
time.sleep(1)
time.sleep(delay_time)
bar()
self.server.quit()

def bombing_message(self, mail_receiver: str, amount: int) -> None:
def bombing_message(self, mail_receiver: str, amount: int, delay_time: float = 1) -> None:
"""
Start bombarding one user with messages
Args:
mail_receiver (str): email
amount (int): number of sent messages
delay_time (float): delay time between sending emails
"""
self.server.login(self.username, self.password)
with alive_bar(amount, force_tty=True) as bar:
for i in range(amount):
self.server.sendmail(self.username, mail_receiver, self.message.as_string())
time.sleep(1)
time.sleep(delay_time)
bar()
self.server.quit()
24 changes: 15 additions & 9 deletions social_spam/telegram.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ def get_me(self) -> Client:
def start_selective_spam(self,
chats: list,
message: str = None,
image: str = None
image: str = None,
delay_time: float = 1.5
) -> None:
"""
Start mailing to all elements of the array (1 message each)
Expand All @@ -121,6 +122,7 @@ def start_selective_spam(self,
chats (list): ID of all users
message (str): set a text message
image (str): set image to message
delay_time (float): delay time between sending emails
"""
if message is not None:
self.set_message(message)
Expand All @@ -132,25 +134,27 @@ def start_selective_spam(self,
if str(id).isdigit():
if self.image is not None:
self.user.send_photo(id, self.image, caption=self.message)
time.sleep(randint(1, 3))
time.sleep(delay_time)
bar()
else:
self.user.send_message(id, self.message)
time.sleep(randint(1, 3))
time.sleep(delay_time)
bar()
else:
print(f'{id} is not ID')

def start_all_spam(self,
message: str = None,
image: str = None
image: str = None,
delay_time: float = 1.5
) -> None:
"""
Start sending to all chats you've ever interacted in
Args:
message (str): set a text message
image (str): set image to message
delay_time (float): delay time between sending emails
"""
if message is not None:
self.set_message(message)
Expand All @@ -162,18 +166,19 @@ def start_all_spam(self,
for chat in all_chats:
if self.image is None:
self.user.send_message(chat['id'], self.message)
time.sleep(randint(1, 3))
time.sleep(delay_time)
bar()
else:
self.user.send_photo(chat['id'], self.image, caption=self.message)
time.sleep(randint(1, 3))
time.sleep(delay_time)
bar()

def start_bombing(self,
user_id: int,
amount: int,
message: str = None,
image: str = None
image: str = None,
delay_time: float = 1.5
) -> None:
"""
Start bombarding one user with messages
Expand All @@ -183,6 +188,7 @@ def start_bombing(self,
amount (int): number of sent messages
message (str): set a text message
image (str): set image to message
delay_time (float): delay time between sending emails
"""
if message is not None:
self.set_message(message)
Expand All @@ -193,11 +199,11 @@ def start_bombing(self,
for i in range(amount):
if self.image is not None:
self.user.send_photo(user_id, self.image, caption=self.message)
time.sleep(1.5)
time.sleep(delay_time)
bar()
else:
self.user.send_message(user_id, self.message)
time.sleep(1.5)
time.sleep(delay_time)
bar()

def send_message(self,
Expand Down
24 changes: 15 additions & 9 deletions social_spam/vkontakte.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ def set_image(self, path: str) -> None:
def start_selective_spam(self,
chats: list,
message: str = None,
image: str = None
image: str = None,
delay_time: float = 1
) -> None:
"""
Start mailing to all elements of the array (1 message each)
Expand All @@ -127,6 +128,7 @@ def start_selective_spam(self,
chats (list): ID of all users
message (str): set a text message
image (str): set image to message
delay_time (float): delay time between sending emails
"""
if message is not None:
self.set_message(message)
Expand All @@ -138,26 +140,28 @@ def start_selective_spam(self,
if str(abs(id)).isdigit():
if self.image is None:
self.vk.messages.send(user_id=abs(id), message=self.message, random_id=0)
time.sleep(randint(1, 3))
time.sleep(delay_time)
bar()
else:
self.vk.messages.send(user_id=abs(id), message=self.message, random_id=0,
attachment=self.image)
time.sleep(randint(1, 3))
time.sleep(delay_time)
bar()
else:
print(f'{id} is not ID')

def start_all_spam(self,
message: str = None,
image: str = None
image: str = None,
delay_time: float = 1
) -> None:
"""
Start sending to all chats you've ever interacted in
Args:
message (str): set a text message
image (str): set image to message
delay_time (float): delay time between sending emails
"""
if message is not None:
self.set_message(message)
Expand All @@ -169,19 +173,20 @@ def start_all_spam(self,
for chat in chats:
if self.image is None:
self.vk.messages.send(user_id=abs(chat), message=self.message, random_id=0)
time.sleep(randint(1, 3))
time.sleep(delay_time)
bar()
else:
self.vk.messages.send(user_id=abs(chat), message=self.message, random_id=0,
attachment=self.image)
time.sleep(randint(1, 3))
time.sleep(delay_time)
bar()

def start_bombing(self,
user_id: int,
amount: int,
message: str = None,
image: str = None
image: str = None,
delay_time: float = 1
) -> None:
"""
Start bombarding one user with messages
Expand All @@ -191,6 +196,7 @@ def start_bombing(self,
amount (int): number of sent messages
message (str): set a text message
image (str): set image to message
delay_time (float): delay time between sending emails
"""
if message is not None:
self.set_message(message)
Expand All @@ -202,11 +208,11 @@ def start_bombing(self,
if self.image is not None:
self.vk.messages.send(user_id=abs(user_id), message=self.message, random_id=0,
attachment=self.image)
time.sleep(1.5)
time.sleep(delay_time)
bar()
else:
self.vk.messages.send(user_id=abs(user_id), message=self.message, random_id=0)
time.sleep(1.5)
time.sleep(delay_time)
bar()

def send_message(self,
Expand Down

0 comments on commit 6fca935

Please sign in to comment.