Untitled
unknown
plain_text
3 years ago
13 kB
12
Indexable
from BotAmino import *
from PIL import Image, ImageDraw, ImageFont
from easy_pil import Editor, Canvas, load_image, Font
import io
from zipfile import ZipFile
import requests
from os import path
import urllib.request
import datetime
from games import rock_paper
from dateutil import parser
import json
from time import sleep
from functools import wraps
print("wait...")
secret="31 sxJJIUTx e11faa0d-1d6b-4c61-bb95-530abf800110 103.201.134.7 8682498e44540f2ce02343dd809ebcc12efcecc8 1 1660115636 bGp1L4NphejnK8F9A5HQrTWU4P8"
client = BotAmino("agqauz7sqiwb@1secmail.org",secret)
from pymongo import MongoClient
import unicodedata
clie = MongoClient("mongodb+srv://amino:sagar890@cluster0.fdt73lu.mongodb.net/?retryWrites=true&w=majority")
db = clie["lvl_up"]
put=db["claim"]
client.prefix = "?" # set the prefix to /
levels={"1":4, "2":5, "3":10, "4":24, "5":50, "6":100, "7":200, "8":500, "9":1000, "10":2000, "11":3000, "12":5000, "13":7000, "14":10000, "15":20000, "16":40000, "17":60000, "18":100000, "19":250000,"20":500000}
def convert(im):
with io.BytesIO() as f:
im.save(f, format='PNG')
return f.getvalue()
def update2(user,time,delta):
old=put.find_one({"user":user})
lol={"user":user,"tim":old["tim"],"full_time":old["full_time"]}
newvalues = { "$set": {"user":user,"tim":time,"full_time":delta}}
put.update_one(lol, newvalues)
def update(com,user,level):
put_level = db[com]
old=put_level.find_one({com:user})
lev=old["level"]
lol={com:user,"level":lev}
newvalues = { "$set": {com:user,"level":level}}
put_level.update_one(lol, newvalues)
@client.command("alive")
def alive(data):
data.subClient.send_message(data.chatId,"Zinda hoon lawde")
def zipurl(url):
resp = urllib.request.urlopen(url)
zipf = ZipFile(io.BytesIO(resp.read()))
inflist = zipf.infolist()
for f in inflist:
if "frame" in str(f):
#if str(f.filename) !="frame.webp":
ifile = zipf.open(f)
img = Image.open(ifile)
return img
def calPercent(x, y, integer = False):
percent = x / y * 100
if integer:
return int(percent)
return percent
def com(data):
return data.comId!=11004133
def mett(data):
return data.authorId in ("25663bd3-3688-4f73-a2ab-8548b0b0cd29")
def dec(text):
return unicodedata.normalize('NFKD',text)
def ff(name,size):
return ImageFont.truetype(name,size)
def circle(av):
circle_image = Image.new('L', (av,av))
circle_draw = ImageDraw.Draw(circle_image)
circle_draw.ellipse((0, 0,av,av), fill=255)
return circle_image
@client.command("help")
def help(data):
mes="""
[cub] help menu
‣ games
‣ claim
‣ rank
‣ alive"""
data.subClient.send_message(data.chatId,mes)
@client.command("join",condition=mett)
def j(data):
id=data.subClient.get_from_code(data.message).objectId
data.subClient.join_chat(id)
data.subClient.send_message(data.chatId,"joined")
@client.command('rank')
def cavas(data: Parameters):
level=data.level
final=levels[str(level+1)]
rep=int(data.reputation)
x=rep-int(levels[str(level)])
y=int(levels[str(level+1)])-int(levels[str(level)])
percentage=calPercent(x,y)
profile1 =load_image("https://i.ibb.co/FJQBSk6/bt.png")
background = Editor(profile1)
profile =load_image(str(data.authorIcon))
#frame=data.subClient.get_user_info(data.authorId).avatarFrame
profile = Editor(profile).resize((150, 150)).circle_image()
poppins =ImageFont.truetype('fonts/calibril.ttf', 70)
poppins_small = Font(path="fonts/calibril.ttf").poppins(size=30)
square = Canvas((500, 500), "#06FFBF")
square = Editor(square)
square.rotate(30, expand=True)
background.paste(square.image, (600, -250))
background.paste(profile.image, (30, 30))
try:
url=data.json["author"]["avatarFrame"]["resourceUrl"]
img1=zipurl(url)
if img1 !=None:
av2 = Editor(img1).resize((170, 170)).circle_image()
background.paste(av2, (16, 14))
except:
pass
background.rectangle((30, 220), width=650, height=40, fill="white", radius=20)
background.bar(
(30, 220),
max_width=650,
height=40,
percentage=percentage,
fill="#2596be",
radius=20,
)
background.text((200, 40), str(dec(data.author)), font=poppins, color="white")
background.rectangle((200, 100), width=350, height=2, fill="#17F3F6")
background.text(
(200, 130),
f"Level :{level}"
+ f" Reputation :{rep}",
font=poppins_small,
color="white",
)
data.subClient.full_embed(message=f"{data.author}",chatId=data.chatId,image=background.image_bytes,link=f"ndc://user-profile/{data.authorId}")
print("done")
@client.command("kk")
def all(data: Parameters):
user=str(data.authorId)
com=str(data.comId)
put_level = db[com]
check = "kkkkk"
#check=put_level.find_one({com:user})
if check ==None: put_level.insert_one({com:user,"level":data.level})
else:
lvl=check["level"]
if lvl < data.level:
level=data.level
#bg=str(f"backround")
background = Editor("bt.png")
profile=load_image(data.authorIcon)
profile = Editor(profile).resize((150, 150)).circle_image()
square = Canvas((500, 500), "#06FFBF")
square = Editor(square)
square.rotate(30, expand=True)
sus=str(f"lvl/{level}.png")
ll = Editor(sus).resize((70,70))
background.paste(ll,(408,249))
background.paste(square.image,(600, -250))
background.paste(profile.image, (37,79))
status=data.json["author"]["accountMembershipStatus"]
if status == 1:
plus = Editor("on.png")
background.paste(plus,(295,59))
else:
plus = Editor("off.png")
background.paste(plus,(295,59))
try:
img1=zipurl(data.json["author"]["avatarFrame"]["resourceUrl"])
if img1 !=None:
av2 = Editor(img1).resize((185, 185)).circle_image()
background.paste(av2, (20,63))
except: pass
background.text((294,121), "Congratulations", font=ff("fonts/ss.ttf",50), color="white")
background.text((301,192),f"You just reached level {level}", font=ff("fonts/ss.ttf",40), color="white")
background.text((337,60),str(data.author), font=ff("fonts/ss.ttf",40), color="white")
data.subClient.full_embed(message=f"{data.author}",chatId=data.chatId,image=background.image_bytes,link=f"ndc://user-profile/{data.authorId}")
#update(com,user,level)
print("done")
@client.command("claim",condition=com)
def rest(args):
now= datetime.datetime.now().day
full=datetime.datetime.now()
delta = full - datetime.timedelta(hours=24)
com=str(args.comId)
user=str(args.authorId)
level=int(args.level)
ccid=None
find=put.find_one({"user":user})
if level < 5:
args.subClient.send_message(args.chatId,message=f"<$@{args.author}$> you are below level 5",replyTo=args.messageId, mentionUserIds=[args.authorId])
else:
if find == None:
wallet=int(args.subClient.get_wallet_amount())
wikiId=args.subClient.get_user_wikis(userId=args.authorId,size=1).wikiId
#print(wikiId)
if len(wikiId) ==0 or wallet< 40:
blogId=args.subClient.get_user_blogs(userId=args.authorId,size=1).blogId
if len(blogId) ==0:
args.subClient.send_message(args.chatId,message=f"<$@{args.author}$> make a blog or maybe my wallet is empty",replyTo=args.messageId, mentionUserIds=[args.authorId])
else:
args.subClient.send_coins(blogId=blogId[0],coins=40)
args.subClient.send_message(args.chatId,message=f"<$@{args.author}$> claimed props",replyTo=args.messageId, mentionUserIds=[args.authorId])
put.insert_one({"user":user,"tim":now,"full_time":str(delta)})
else:
args.subClient.send_coins(objectId=wikiId[0],coins=40)
args.subClient.send_message(args.chatId,message=f"<$@{args.author}$> claimed props",replyTo=args.messageId, mentionUserIds=[args.authorId])
put.insert_one({"user":user,"tim":now,"full_time":str(delta)})
else:
old=find["tim"]
if now-old !=0:
wikiId=args.subClient.get_user_wikis(userId=args.authorId,size=1).wikiId
wallet=int(args.subClient.get_wallet_amount())
if len(wikiId) ==0 or wallet< 40:
blogId=args.subClient.get_user_blogs(userId=args.authorId,size=1).blogId
if len(blogId) ==0:
args.subClient.send_message(args.chatId,message=f"<$@{args.author}$> make a blog or maybe my wallet is empty",replyTo=args.messageId, mentionUserIds=[args.authorId])
else:
args.subClient.send_coins(blogId=blogId[0],coins=40)
args.subClient.send_message(args.chatId,message=f"<$@{args.author}$> claimed props",replyTo=args.messageId, mentionUserIds=[args.authorId])
update2(user,now,str(delta))
else:
args.subClient.send_coins(objectId=wikiId[0],coins=40)
args.subClient.send_message(args.chatId,message=f"<$@{args.author}$> claimed props",replyTo=args.messageId, mentionUserIds=[args.authorId])
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}"
args.subClient.send_message(args.chatId,message=f"<$@{args.author}$> \n{mes}",replyTo=args.messageId, mentionUserIds=[args.authorId])
def truth_dare(data: str):
return requests.get(f"https://api.truthordarebot.xyz/api/{data}").json()["question"]
@client.command("games")
def truth(data):
msg="""
[cub] Games Menu
‣ truth : send a truth
‣ dare: send a dare
‣ wyr: Would You Rather
‣ nhie: Never Have I Ever
‣ paranoia: ask a paranoia Question}
‣ rps: usage: ?rps rock options:rock, paper,scissor,lizard,spock"""
data.subClient.send_message(data.chatId,msg)
@client.command("truth")
def truth(data):
data.subClient.send_message(data.chatId,message=f"<$@{data.author}$> {truth_dare('truth')}",replyTo=data.messageId, mentionUserIds=[data.authorId])
@client.command("dare")
def dare(data):
data.subClient.send_message(data.chatId,message=f"<$@{data.author}$> {truth_dare('dare')}",replyTo=data.messageId, mentionUserIds=[data.authorId])
@client.command("wyr")
def wyr(data):
data.subClient.send_message(data.chatId,message=f"<$@{data.author}$> {truth_dare('wyr')}",replyTo=data.messageId, mentionUserIds=[data.authorId])
@client.command("nhie")
def nhie(data):
data.subClient.send_message(data.chatId,message=f"<$@{data.author}$> {truth_dare('nhie')}",replyTo=data.messageId, mentionUserIds=[data.authorId])
@client.command("paranoia")
def pano(data):
data.subClient.send_message(data.chatId,message=f"<$@{data.author}$> {truth_dare('paranoia')}",replyTo=data.messageId, mentionUserIds=[data.authorId])
@client.command("rps")
def lol(data):
msg=rock_paper.rock_paper_s(data.message)
if msg!=None: data.subClient.send_message(data.chatId,message=msg,replyTo=data.messageId)
else: data.subClient.send_message(data.chatId,message=f"wrong choice\nselect:\nrock,paper,scissor,lizard,spock",replyTo=data.messageId)
import os
from time import sleep
import threading
import sys
def maintenance():
print("launch maintenance")
i = 0
while i < 7200:
i += 10
sleep(10)
os.execv(sys.executable, ["None", os.path.basename(sys.argv[0])])
client.launch()
threading.Thread(target=maintenance).start()
def reconsocketloop():
while True:
client.close()
client.run_amino_socket()
sleep(120)
socketloop = threading.Thread(target=reconsocketloop, daemon=True)
socketloop.start()
print("Ready")
Editor is loading...