Untitled
unknown
python
2 years ago
7.2 kB
8
Indexable
from pymino import Bot from pymino.ext.context import Context from pprint import pprint from pymino.ext.community import Community from util import * from dateutil import parser from games import rock_paper from typing import List import datetime stored_messages = [] deleted_messages = [] bot = Bot(command_prefix="?", community_id=None,debug_log=True) secret = "31 RRyZCpCm bc108cca-c755-4ccd-8308-5f56ae3772bc 103.201.134.98 5b4881ef9be3916317aa2f0ccb06dd6f442bfae5 1 1684428482 5sggpxAJW10MWpbx1RymCuC0Uxk" import threading import time def bot_connect(): while True: time.sleep(30) try: bot.close_and_reconnect() print("Socket connected successfully.") except Exception as e: print(f"Socket connection error: {str(e)}") @bot.command("ping") def ping(ctx: Context): # bot.stop_websocket() ctx.send(content="Pong!") @bot.command("start") def strt_vc(ctx: Context, message: str,community: Community): bot.set_community_id(ctx.comId) bot.community.start_vc(chatId=ctx.chatId) ctx.reply("vc started") @bot.command("end") def stop_vc(ctx: Context, message: str): bot.set_community_id(ctx.comId) bot.community.stop_vc(chatId=ctx.chatId) ctx.reply("end vc") @bot.command("rank") def rank(ctx: Context, message: str): bot.set_community_id(ctx.comId) image=rank_user(ctx) ctx.send_link_snippet(image.image_bytes,ctx.author.nickname,f"ndc://user-profile/{ctx.author.userId}") @bot.on_text_message() def on_text_message(ctx: Context, message: str): save_msg(ctx,message) image=lvl_up(ctx) if image: ctx.send_embed(ctx.author.nickname,image.image_bytes,f"ndc://user-profile/{ctx.author.userId}") @bot.on_delete_message() def on_delte_message(ctx: Context, message: str): db = clie["delete_message"] com=str(ctx.comId) type=ctx.message.type chatId=str(ctx.chatId) messageId=str(ctx.message.messageId) put=db[chatId] sav={"msgId":messageId,"type":type} put.insert_one(sav) #print(sav) @bot.on_sticker_message() def on_sticker_message(ctx: Context, message: str): db = clie["save_message"] com=str(ctx.comId) chatId=str(ctx.chatId) messageId=str(ctx.message.messageId) type=ctx.message.mediaType put=db[chatId] value=ctx.message.mediaValue sav={"msgId":messageId,"content":value,"nickname":ctx.author.nickname,"userId":ctx.author.userId,"type":type} put.insert_one(sav) @bot.on_image_message() def on_image_message(ctx: Context, message: str): db = clie["save_message"] com=str(ctx.comId) chatId=str(ctx.chatId) messageId=str(ctx.message.messageId) type=ctx.message.mediaType put=db[chatId] value=ctx.message.mediaValue sav={"msgId":messageId,"content":value,"nickname":ctx.author.nickname,"userId":ctx.author.userId,"type":type} put.insert_one(sav) @bot.command("alive") def alive(ctx:Context): ctx.reply("Zinda hoon lawde/lawdi") @bot.command("ai") def ai(ctx:Context,message:str): response = chatgpt(message, messages) ctx.reply(response) @bot.command("add") def add_adats(ctx: Context,message:str): iss=insert_gc(ctx) if iss=="inserted": ctx.reply(iss) else: ctx.reply(iss) @bot.command("delete") def add_adats(ctx: Context,message:str): iss=del_gc(ctx,message) if iss=="deleted": ctx.reply(iss) else: ctx.reply(iss) @bot.command("del_all") def del_all(ctx:Context): db = clie["delete_message"] for coll in db.list_collection_names(): delete2(coll) ctx.reply("done1") db = clie["save_message"] for coll in db.list_collection_names(): delete1(coll) @bot.command("claim") def rest(ctx: Context): clie = MongoClient( "mongodb+srv://raku:raku1234@cluster0.7dhk4es.mongodb.net/?retryWrites=true&w=majority" ) db = clie["lvl_up"] put = db["savee_data"] find = put.find_one({f"coin": ctx.chatId}) if find: bot.set_community_id(ctx.comId) now= datetime.datetime.now().day full=datetime.datetime.now() delta = full - datetime.timedelta(hours=24) # com=str(ctx.comId) user=str(ctx.author.userId) level=int(ctx.author.level) ccid=None find=put.find_one({"user":user}) if level < 5: ctx.reply(f"you are below lvl") else: if find == None: if coins_check(ctx,bot)=="claimed": put.insert_one({"user":user,"tim":now,"full_time":str(delta)}) else: old=find["tim"] if now-old !=0: if coins_check(ctx,bot)=="claimed": update2(user,now,str(delta)) else: old_date=parser.parse(find["full_time"]) time_left=str(full-old_date) yes = time_left.replace(":", ",").split(",") h=24-int(yes[1]) m=60-int(yes[2]) s=60-float(yes[3]) mes=f"time_left:\nhours: {h}\nminutes:{m}\nseconds:{s}" ctx.reply(mes) @bot.command("ss") def delete_o(ctx:Context,message:str): try: db = clie["delete_message"] put=db[str(ctx.chatId)] g=put.find() list=[] for h in g: msg=h["msgId"] list.append(msg) if message=="": nn=1 else: nn=int(message)+1 id=list[-nn] db = clie["save_message"] putt = db[str(ctx.chatId)] old=putt.find_one({"msgId":str(id)}) #print(old) if old==None: #print(old) pass else: print(old["type"]) if old["type"]==113: type="Deleted Image/gif" else: type="Deleted Text" message=old["content"] nick=old["nickname"] userId=old["userId"] mm=f"Deleted {type} by {nick}:\nmessage:{message}" ctx.reply(mm) except Exception as e: print(e) @bot.command("truth") def truth(ctx: Context): ctx.reply(truth_dare('dare')) @bot.command("dare") def dare(ctx: Context): ctx.reply(truth_dare('dare')) @bot.command("wyr") def wyr(ctx: Context): ctx.reply(truth_dare('dare')) @bot.command("nhie") def nhie(ctx: Context): ctx.reply(truth_dare('dare')) @bot.command("paranoia") def pano(ctx: Context): ctx.reply(truth_dare('dare')) @bot.command("rps") def lol(ctx: Context,message:str): msg=rock_paper.rock_paper_s(message) if msg!=None: ctx.reply(msg) else: ctx.reply(f"wrong choice\nselect:\nrock,paper,scissor,lizard,spock") bot_thread = threading.Thread(target=bot_connect) bot_thread.start() bot.run("aminoc@gmail.com",secret)
Editor is loading...