-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathspongebot.py
More file actions
executable file
·33 lines (28 loc) · 925 Bytes
/
spongebot.py
File metadata and controls
executable file
·33 lines (28 loc) · 925 Bytes
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
import telebot
import re
import random
from telebot import types
from secret_vars import *
bot = telebot.TeleBot(TOKEN)
@bot.message_handler(commands=['spongify'])
def send_welcome(message):
try:
mix = lambda s: "".join((str.upper,str.lower)[i%2](ch) for i,ch in enumerate(s))
if message.reply_to_message is None:
new_message = mix(message.text.split(' ', 1)[1])
reply_id = message.message_id
else:
new_message = mix(message.reply_to_message.text)
reply_id = message.reply_to_message.message_id
bot.send_photo(
message.chat.id,
caption=new_message,
photo="https://usatftw.files.wordpress.com/2017/05/spongebob.jpg?w=1000&h=600&crop=1",
reply_to_message_id=reply_id)
except:
print("too bad")
while True:
try:
bot.polling()
except:
pass