-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgraveyard.py
More file actions
157 lines (123 loc) · 4.93 KB
/
graveyard.py
File metadata and controls
157 lines (123 loc) · 4.93 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
@bot.message_handler(commands=['hard_shill', 'soft_shill'])
@check_admin
def shill(message):
# check if admin has shill group
# if admin has a shill group, don't allow them to call this function
print("shill called")
if " " in message.text:
command_list = message.text.split(" ")
else:
bot.send_message(message.chat.id, f"Please add the amount of times you would like SpongeBot to shill for. Eg (/soft_shill 2)")
if command_list:
shill_type = command_list[0]
loop_counter = int(command_list[1])
else:
shill_type = message.text
loop_counter = 3
try:
username = message.from_user.username
user_id = message.from_user.id
chat_id = message.chat.id
user_index = get_user_index(username)
print("userid: ", user_id)
if user_id == -1:
bot.send_message(chat_id, f"User not found")
return
if not is_game_master(user_id):
shill_group = db['adminList'][user_index]['shillGroup']
if shill_group and shill_group != chat_id:
bot.send_message(chat_id, f"You cannot use Sponge Bot in more than one group, after your current admin session is over, buy more hours to use Sponge Bot in another group")
return
elif not shill_group and not is_game_master(user_id):
bot.send_message(chat_id, f"Your shill group will now be set to the group you have sent this command from")
update_admin_shill_group(username, chat_id)
if shill_type == '/soft_shill':
send_soft_shill(message.chat.id, loop_counter)
except Exception as e:
print("shill error: ", e)
@background
def send_soft_shill(chat_id, loop_counter):
# try:
# # gif = open('./assets/321.gif', 'rb')
# gif = open('./assets/321-one-loop.gif', 'rb')
# bot.send_video(chat_id, gif)
# except Exception as e:
# print("send gif failed", e)
# return
SOFT_SHILL_LOOP = 120
bot.send_message(chat_id, "Soft shilling is: talking about the project in a casual manner that may not come off as shilling to people who aren’t aware of what shilling is")
time.sleep(10)
i = 0
loop = True
while loop:
if i == loop_counter:
print("loop counter reached")
loop = False
break
# get random number
n = random.randint(0,len(soft_shill_urls) - 1)
# use number to get random entry from the chat urls list
randomUrl = soft_shill_urls[n]
time.sleep(2)
bot.send_message(chat_id, "OK GUYS GET READY TO SHILL")
time.sleep(5)
bot.send_message(chat_id, f"POSTING THE RAID LINK IN 3 2 1...")
time.sleep(3)
bot.send_message(chat_id, f"GO! {randomUrl}")
time.sleep(SOFT_SHILL_LOOP)
i = i + 1
# TODO: try to get this to work with that other api
def get_args(message_text):
if " " in message_text:
return message_text.split(" ")
@bot.message_handler(commands=['Song'])
async def song(message):
try:
print("song called")
chat_id = message.chat.id
user_id = message.from_user.id
song_name = ""
message_args = get_args(message.text)
print("message args", message_args)
if message_args:
song_name = message_args[1]
status = await bot.reply_to(message,"🚀 🔎 🔎 𝐒𝐞𝐚𝐫𝐜𝐡𝐢𝐧𝐠 𝐭𝐡𝐞 𝐬𝐨𝐧𝐠... 🎶 𝐏𝐥𝐞𝐚𝐬𝐞 𝐖𝐚𝐢𝐭 ⏳️ 𝐅𝐨𝐫 𝐅𝐞𝐰 𝐒𝐞𝐜𝐨𝐧𝐝𝐬 [🚀](https://telegra.ph/file/67f41ae52a85dfc0551ae.mp4)")
video_link = yt_search(song_name)
if not video_link:
await status.edit("✖️ 𝐅𝐨𝐮𝐧𝐝 𝐍𝐨𝐭𝐡𝐢𝐧𝐠. 𝐒𝐨𝐫𝐫𝐲.\n\n𝐓𝐫𝐲 𝐀𝐧𝐨𝐭𝐡𝐞𝐫 𝐊𝐞𝐲𝐰𝐨𝐫𝐤 𝐎𝐫 𝐌𝐚𝐲𝐛𝐞 𝐒𝐩𝐞𝐥𝐥 𝐈𝐭 𝐏𝐫𝐨𝐩𝐞𝐫𝐥𝐲.\n\nEg.`/song Faded`")
return ""
yt = YouTube(video_link)
audio = yt.streams.filter(only_audio=True).first()
try:
download = audio.download(filename=f"{str(user_id)}")
except Exception as ex:
await status.edit("Failed to download song 😶")
# LOGGER.error(ex)
return ""
rename = os.rename(download, f"{str(user_id)}.mp3")
await app.send_chat_action(message.chat.id, "upload_audio")
await app.send_audio(
chat_id=message.chat.id,
audio=f"{str(user_id)}.mp3",
duration=int(yt.length),
title=str(yt.title),
performer=str(yt.author),
reply_to_message_id=message.message_id,
)
await status.delete()
os.remove(f"{str(user_id)}.mp3")
except Exception as e:
print("Song error: ", e)
# decorators
def background(f):
def wrap(*args, **kwargs):
try:
# TODO: read asyncio docs
# TODO: check if there's an even loop, if there isn't, then start one and continue
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
this = asyncio.get_event_loop().run_in_executor(None, f, *args, **kwargs)
except Exception as e:
print("background decorator error:", e)
return this
return wrap