├── Procfile ├── README.md ├── app.json ├── bot.py └── requirements.txt /Procfile: -------------------------------------------------------------------------------- 1 | worker: python bot.py 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Telegram-Level-Bot 2 | 3 | A level system Telegram bot written in Python using Pyrogram Library 4 | 5 | ## How To Host 6 | The easiest way to deploy this Bot 7 | • Enter your ```API_ID```,```MONGO_URL```,```API_HASH``` And ```BOT_TOKEN```. 8 |
9 | 10 | 11 | ## Important 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | ## © Copyright - MetaVoid (Moezilla) 20 | 21 | 22 | -------------------------------------------------------------------------------- /app.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Senko", 3 | "description": "Senko Welcome Bot", 4 | "repository": "https://github.com/MoeZilla/senko-telegram-bot", 5 | "env": { 6 | "BOT_TOKEN": { 7 | "description": "telegram bot token here", 8 | "required": true 9 | }, 10 | "API_ID": { 11 | "description": "telegram api id here", 12 | "required": true 13 | }, 14 | "API_HASH": { 15 | "description": "telegram api hash here", 16 | "required": true 17 | }, 18 | "MONGO_URL": { 19 | "description": "mongo db url", 20 | "required": true 21 | } 22 | }, 23 | "addons": [ 24 | { 25 | "plan": "heroku-postgresql" 26 | } 27 | ] 28 | } 29 | -------------------------------------------------------------------------------- /bot.py: -------------------------------------------------------------------------------- 1 | """ 2 | MIT License 3 | Copyright (C) 2021-2022 MetaVoid (MoeZilla) 4 | Permission is hereby granted, free of charge, to any person obtaining a copy 5 | of this software and associated documentation files (the "Software"), to deal 6 | in the Software without restriction, including without limitation the rights 7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the Software is 9 | furnished to do so, subject to the following conditions: 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 13 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 14 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 15 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 16 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 17 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 18 | SOFTWARE. 19 | """ 20 | 21 | from pyrogram import Client , filters 22 | from pymongo import MongoClient 23 | import os 24 | 25 | API_ID = os.environ.get("API_ID") 26 | API_HASH = os.environ.get("API_HASH") 27 | BOT_TOKEN = os.environ.get("BOT_TOKEN") 28 | MONGO_URL = os.environ.get("MONGO_URL") 29 | 30 | 31 | Chat_Group = [-1001773806532] 32 | 33 | 34 | bot = Client( 35 | "Level" , 36 | api_id = API_ID , 37 | api_hash = API_HASH , 38 | bot_token = BOT_TOKEN 39 | ) 40 | 41 | 42 | 43 | levellink =["https://telegra.ph/file/6620fe683ff3989268c7f.mp4", "https://telegra.ph/file/c6bbce91cb75d4ab318ae.mp4", "https://telegra.ph/file/c2ac7b63d248f49da952c.mp4", "https://telegra.ph/file/b100466a5f0c42fa7255f.mp4", "https://telegra.ph/file/67c9dc7b59f78aa7aaf4c.mp4", "https://telegra.ph/file/06e2d74343e89c9d3cd12.mp4", "https://telegra.ph/file/88458a18eea8e86292b14.mp4", "https://telegra.ph/file/e3786d4f321ff4335a70f.mp4"] 44 | levelname = ["Team Rocket", "Stray God", "Vector", "Hero Association", "Z Warrior", "Black Knight", "Ghoul", "Overlord"] 45 | levelnum = [2,5,15,25,35,50,70,100] 46 | 47 | 48 | 49 | 50 | @bot.on_message( 51 | (filters.document 52 | | filters.text 53 | | filters.photo 54 | | filters.sticker 55 | | filters.animation 56 | | filters.video) 57 | & ~filters.private, 58 | group=8, 59 | ) 60 | async def level(client, message): 61 | chat = message.chat.id 62 | user_id = message.from_user.id 63 | 64 | leveldb = MongoClient(MONGO_URL) 65 | 66 | level = leveldb["LevelDb"]["Level"] 67 | 68 | if message.chat.id in Chat_Group: 69 | xpnum = level.find_one({"level": user_id}) 70 | 71 | if not message.from_user.is_bot: 72 | if xpnum is None: 73 | newxp = {"level": user_id, "xp": 10} 74 | level.insert_one(newxp) 75 | 76 | else: 77 | xp = xpnum["xp"] + 10 78 | level.update_one({"level": user_id}, { 79 | "$set": {"xp": xp}}) 80 | l = 0 81 | while True: 82 | if xp < ((50*(l**2))+(50*(l))): 83 | break 84 | l += 1 85 | xp -= ((50*((l-1)**2))+(50*(l-1))) 86 | if xp == 0: 87 | await message.reply_text(f"🌟 {message.from_user.mention}, You have reached level {l}**, Nothing can stop you on your way!") 88 | 89 | for lv in range(len(levelname)) and range(len(levellink)): 90 | if l == levelnum[lv]: 91 | Link = f"{levellink[lv]}" 92 | await message.reply_video(video=Link, caption=f"{message.from_user.mention}, You have reached Rank Name **{levelname[lv]}**") 93 | 94 | 95 | 96 | @bot.on_message( 97 | filters.command("rank", prefixes=["/", ".", "?", "-"]) 98 | & ~filters.private) 99 | async def rank(client, message): 100 | chat = message.chat.id 101 | user_id = message.from_user.id 102 | 103 | leveldb = MongoClient(MONGO_URL) 104 | 105 | level = leveldb["LevelDb"]["Level"] 106 | 107 | if message.chat.id in Chat_Group: 108 | xpnum = level.find_one({"level": user_id}) 109 | xp = xpnum["xp"] 110 | l = 0 111 | r = 0 112 | while True: 113 | if xp < ((50*(l**2))+(50*(l))): 114 | break 115 | l += 1 116 | 117 | xp -= ((50*((l-1)**2))+(50*(l-1))) 118 | rank = level.find().sort("xp", -1) 119 | for k in rank: 120 | r += 1 121 | if xpnum["level"] == k["level"]: 122 | break 123 | await message.reply_text(f"{message.from_user.mention} Level Info:\nLevel: {l}\nProgess: {xp}/{int(200 *((1/2) * l))}\n Ranking: {r}") 124 | 125 | 126 | 127 | 128 | bot.run() 129 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | pyrogram==1.4.16 2 | pymongo 3 | dnspython 4 | tgcrypto==1.2.2 5 | --------------------------------------------------------------------------------