Initial commit
This commit is contained in:
132
arch/bot_old.py
Normal file
132
arch/bot_old.py
Normal file
@@ -0,0 +1,132 @@
|
||||
import asyncio
|
||||
from aiogram import Bot, Dispatcher, types, F
|
||||
from aiogram.types import ReplyKeyboardMarkup, KeyboardButton, InlineKeyboardMarkup, InlineKeyboardButton
|
||||
from aiogram.filters import CommandStart
|
||||
from aiogram.fsm.storage.memory import MemoryStorage
|
||||
from aiogram.fsm.context import FSMContext
|
||||
from aiogram.fsm.state import StatesGroup, State
|
||||
|
||||
TOKEN = "8517883174:AAFA-dHF5Xm6q1mPQJA_eSBcyqDsaO0nPS4"
|
||||
CHANNEL_ID = -1003749575740
|
||||
REVIEW_ID = -1003911723791
|
||||
|
||||
bot = Bot(token=TOKEN)
|
||||
dp = Dispatcher(storage=MemoryStorage())
|
||||
|
||||
submissions = {}
|
||||
counter = 0
|
||||
|
||||
class Upload(StatesGroup):
|
||||
waiting_media = State()
|
||||
confirm = State()
|
||||
|
||||
start_kb = ReplyKeyboardMarkup(
|
||||
keyboard=[
|
||||
[KeyboardButton(text="Upload Photo")],
|
||||
[KeyboardButton(text="Upload Video")]
|
||||
],
|
||||
resize_keyboard=True
|
||||
)
|
||||
|
||||
confirm_kb = InlineKeyboardMarkup(
|
||||
inline_keyboard=[
|
||||
[InlineKeyboardButton(text="Submit", callback_data="submit")],
|
||||
[InlineKeyboardButton(text="Cancel", callback_data="cancel")]
|
||||
]
|
||||
)
|
||||
|
||||
def admin_kb(sub_id):
|
||||
return InlineKeyboardMarkup(
|
||||
inline_keyboard=[
|
||||
[InlineKeyboardButton(text="Approve", callback_data="a|" + str(sub_id))],
|
||||
[InlineKeyboardButton(text="Reject", callback_data="r|" + str(sub_id))]
|
||||
]
|
||||
)
|
||||
|
||||
@dp.message(CommandStart())
|
||||
async def start(message: types.Message, state: FSMContext):
|
||||
await message.answer("The other videos/images can be found in the channel. Channel invite link: https://t.me/+engKAbYjPgNmYTQ1 here is where your stuff will be posted too")
|
||||
args = message.text.split()
|
||||
if len(args) > 1 and args[1] == "submit":
|
||||
await message.answer("Send your photo or video", reply_markup=start_kb)
|
||||
else:
|
||||
await message.answer("Choose:", reply_markup=start_kb)
|
||||
|
||||
@dp.message(F.text == "Upload Photo")
|
||||
async def photo_btn(message: types.Message, state: FSMContext):
|
||||
await state.set_state(Upload.waiting_media)
|
||||
await state.update_data(type="photo")
|
||||
await message.answer("Send photo")
|
||||
|
||||
@dp.message(F.text == "Upload Video")
|
||||
async def video_btn(message: types.Message, state: FSMContext):
|
||||
await state.set_state(Upload.waiting_media)
|
||||
await state.update_data(type="video")
|
||||
await message.answer("Send video")
|
||||
|
||||
@dp.message(Upload.waiting_media, F.photo | F.video)
|
||||
async def handle_media(message: types.Message, state: FSMContext):
|
||||
if message.photo:
|
||||
file_id = message.photo[-1].file_id
|
||||
file_type = "photo"
|
||||
else:
|
||||
file_id = message.video.file_id
|
||||
file_type = "video"
|
||||
await state.update_data(file_id=file_id, file_type=file_type)
|
||||
await state.set_state(Upload.confirm)
|
||||
await message.answer("Confirm submission", reply_markup=confirm_kb)
|
||||
|
||||
@dp.callback_query(F.data == "submit")
|
||||
async def submit(cb: types.CallbackQuery, state: FSMContext):
|
||||
global counter
|
||||
data = await state.get_data()
|
||||
file_id = data["file_id"]
|
||||
file_type = data["file_type"]
|
||||
user = cb.from_user
|
||||
counter += 1
|
||||
submissions[counter] = (user.id, file_id, file_type)
|
||||
caption = "New submission from @" + (user.username if user.username else user.full_name)
|
||||
if file_type == "photo":
|
||||
await bot.send_photo(REVIEW_ID, file_id, caption=caption, reply_markup=admin_kb(counter))
|
||||
else:
|
||||
await bot.send_video(REVIEW_ID, file_id, caption=caption, reply_markup=admin_kb(counter))
|
||||
await cb.message.answer("Submitted")
|
||||
await state.clear()
|
||||
|
||||
@dp.callback_query(F.data == "cancel")
|
||||
async def cancel(cb: types.CallbackQuery, state: FSMContext):
|
||||
await state.clear()
|
||||
await cb.message.answer("Cancelled")
|
||||
|
||||
@dp.callback_query(F.data.startswith("a|"))
|
||||
async def approve(cb: types.CallbackQuery):
|
||||
sub_id = int(cb.data.split("|")[1])
|
||||
user_id, file_id, file_type = submissions[sub_id]
|
||||
if file_type == "photo":
|
||||
await bot.send_photo(CHANNEL_ID, file_id, caption="Approved submission, submit your own self-harm media using https://t.me/Selfharmmeowbot?start=submit")
|
||||
else:
|
||||
await bot.send_video(CHANNEL_ID, file_id, caption="Approved submission, submit your own self-harm media using https://t.me/Selfharmmeowbot?start=submit")
|
||||
await bot.send_message(user_id, "Your submission was approved")
|
||||
await cb.message.edit_reply_markup()
|
||||
|
||||
@dp.callback_query(F.data.startswith("r|"))
|
||||
async def reject(cb: types.CallbackQuery):
|
||||
sub_id = int(cb.data.split("|")[1])
|
||||
user_id, _, _ = submissions[sub_id]
|
||||
await bot.send_message(user_id, "Your submission was rejected")
|
||||
await cb.message.edit_reply_markup()
|
||||
|
||||
@dp.message(F.new_chat_members)
|
||||
async def welcome(message: types.Message):
|
||||
for user in message.new_chat_members:
|
||||
text = f"<a href='tg://user?id={user.id}'>{user.first_name}</a> welcome to the channel. if you want to submit media of SH please use this link to our bot: https://t.me/selfharmmeowbot?start=submit If you want to view existing self-harm media in the channel, please click on it and go to the media section."
|
||||
msg = await message.answer(text, parse_mode="HTML")
|
||||
await asyncio.sleep(1800)
|
||||
await msg.delete()
|
||||
|
||||
|
||||
async def main():
|
||||
await dp.start_polling(bot)
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main())
|
||||
BIN
arch/sh-bot.rar
Normal file
BIN
arch/sh-bot.rar
Normal file
Binary file not shown.
Reference in New Issue
Block a user