├── .DS_Store ├── .deepsource.toml ├── .github └── workflows │ └── codeql-analysis.yml ├── .gitignore ├── Aptfile ├── CODE_OF_CONDUCT ├── Dockerfile ├── GenerateStringSession.py ├── LICENSE ├── Procfile ├── README.md ├── app.json ├── generate_drive_session.py ├── heroku.yml ├── init ├── CI_Test_Script.sh ├── Merge.sh ├── init_script.sh ├── telegram ├── telegramapi └── userbot ├── main.py ├── modules ├── requirements.txt ├── requirementsDOCKER.txt ├── runtime.txt ├── sample_config.env ├── userbot ├── .DS_Store ├── __init__.py ├── cmdhelp.py ├── events.py ├── fonts │ └── impact.ttf ├── language.py ├── language │ ├── AZ.asenajson │ ├── DEFAULT.asenajson │ ├── EN.asenajson │ ├── TR.asenajson │ └── UZ.asenajson ├── main.py └── modules │ ├── .DS_Store │ ├── __asena.py │ ├── __helpme.py │ ├── __init__.py │ ├── __plugin.py │ ├── admin.py │ ├── afk.py │ ├── anti_spambot.py │ ├── aria.py │ ├── atsiz.py │ ├── auto.py │ ├── autopp.py │ ├── blacklist.py │ ├── cevir.py │ ├── chat.py │ ├── covid19.py │ ├── deepfry.py │ ├── degistir.py │ ├── dil.py │ ├── durum.py │ ├── evaluators.py │ ├── ezanvakti.py │ ├── filter.py │ ├── galeri.py │ ├── gdrive.py │ ├── goodbye.py │ ├── grupbilgisi.py │ ├── hash.py │ ├── lastfm.py │ ├── liste.py │ ├── locks.py │ ├── lydia.py │ ├── lyrics.py │ ├── memes.py │ ├── misc.py │ ├── nekobin.py │ ├── notes.py │ ├── ocr.py │ ├── open_apis_game.py │ ├── open_apis_github.py │ ├── open_apis_insta.py │ ├── open_apis_similarity.py │ ├── open_apis_textpro.py │ ├── open_apis_tiktok.py │ ├── pmpermit.py │ ├── profile.py │ ├── purge.py │ ├── qrcode.py │ ├── remove_bg.py │ ├── reverse.py │ ├── rgb.py │ ├── scrapers.py │ ├── scrapers_bot.py │ ├── screencapture.py │ ├── shazam.py │ ├── shazam_helper │ ├── __init__.py │ ├── algorithm.py │ ├── communication.py │ ├── signature_format.py │ └── user_agent.py │ ├── snips.py │ ├── song.py │ ├── sozluk.py │ ├── spammer.py │ ├── spotify.py │ ├── sql_helper │ ├── .DS_Store │ ├── __init__.py │ ├── blacklist_sql.py │ ├── filter_sql.py │ ├── galeri_sql.py │ ├── gban_sql.py │ ├── globals.py │ ├── gmute_sql.py │ ├── goodbye_sql.py │ ├── keep_read_sql.py │ ├── lydia_sql.py │ ├── mesaj_sql.py │ ├── notes_sql.py │ ├── pm_permit_sql.py │ ├── quick_phrases_sql.py │ ├── snips_sql.py │ ├── spam_mute_sql.py │ ├── warn_sql.py │ └── welcome_sql.py │ ├── stickers.py │ ├── store.py │ ├── system_stats.py │ ├── tagall.py │ ├── time.py │ ├── updater.py │ ├── upload_download.py │ ├── weather.py │ ├── welcomes.py │ ├── whois.py │ └── www.py └── windows_startup_script.py /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yusufusta/AsenaUserBot/d850bae0f8491911465fb5f54e1692b0b9f112de/.DS_Store -------------------------------------------------------------------------------- /.deepsource.toml: -------------------------------------------------------------------------------- 1 | version = 1 2 | 3 | test_patterns = ["*/userbot/*"] 4 | 5 | [[analyzers]] 6 | name = "python" 7 | enabled = true 8 | 9 | [analyzers.meta] 10 | runtime_version = "3.x.x" 11 | -------------------------------------------------------------------------------- /.github/workflows/codeql-analysis.yml: -------------------------------------------------------------------------------- 1 | # For most projects, this workflow file will not need changing; you simply need 2 | # to commit it to your repository. 3 | # 4 | # You may wish to alter this file to override the set of languages analyzed, 5 | # or to provide custom queries or build logic. 6 | name: "CodeQL" 7 | 8 | on: 9 | push: 10 | branches: [master] 11 | pull_request: 12 | # The branches below must be a subset of the branches above 13 | branches: [master] 14 | schedule: 15 | - cron: '0 21 * * 6' 16 | 17 | jobs: 18 | analyze: 19 | name: Analyze 20 | runs-on: ubuntu-latest 21 | 22 | strategy: 23 | fail-fast: false 24 | matrix: 25 | # Override automatic language detection by changing the below list 26 | # Supported options are ['csharp', 'cpp', 'go', 'java', 'javascript', 'python'] 27 | language: ['python'] 28 | # Learn more... 29 | # https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#overriding-automatic-language-detection 30 | 31 | steps: 32 | - name: Checkout repository 33 | uses: actions/checkout@v2 34 | with: 35 | # We must fetch at least the immediate parents so that if this is 36 | # a pull request then we can checkout the head. 37 | fetch-depth: 2 38 | 39 | # If this run was triggered by a pull request event, then checkout 40 | # the head of the pull request instead of the merge commit. 41 | - run: git checkout HEAD^2 42 | if: ${{ github.event_name == 'pull_request' }} 43 | 44 | # Initializes the CodeQL tools for scanning. 45 | - name: Initialize CodeQL 46 | uses: github/codeql-action/init@v1 47 | with: 48 | languages: ${{ matrix.language }} 49 | # If you wish to specify custom queries, you can do so here or in a config file. 50 | # By default, queries listed here will override any specified in a config file. 51 | # Prefix the list here with "+" to use these queries and those in the config file. 52 | # queries: ./path/to/local/query, your-org/your-repo/queries@main 53 | 54 | # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). 55 | # If this step fails, then you should remove it and run the build manually (see below) 56 | - name: Autobuild 57 | uses: github/codeql-action/autobuild@v1 58 | 59 | # ℹ️ Command-line programs to run using the OS shell. 60 | # 📚 https://git.io/JvXDl 61 | 62 | # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines 63 | # and modify them (or add more) to build your code if your project 64 | # uses a compiled language 65 | 66 | #- run: | 67 | # make bootstrap 68 | # make release 69 | 70 | - name: Perform CodeQL Analysis 71 | uses: github/codeql-action/analyze@v1 72 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | *.pyc 3 | bin/cmrudl 4 | bin/megadown 5 | *.check 6 | *.log 7 | *.session-journal 8 | *.session 9 | *.db 10 | config.env 11 | userbot/.DS_Store 12 | userbot/.DS_Store 13 | .DS_Store 14 | .DS_Store 15 | -------------------------------------------------------------------------------- /Aptfile: -------------------------------------------------------------------------------- 1 | neofetch 2 | chromium-chromedriver 3 | chromium-browser 4 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT: -------------------------------------------------------------------------------- 1 | # Code of Conduct 2 | 3 | All participants of RaphielGang are expected to abide by our Code of Conduct, 4 | both online and during in-person events that are hosted and/or associated with RaphielGang. 5 | 6 | 7 | ### The Pledge 8 | 9 | In the interest of fostering an open and welcoming environment, we pledge to make participation 10 | in our project and our community a harassment-free experience for everyone, regardless of age, 11 | body size, disability, ethnicity, gender identity and expression, level of experience, 12 | nationality, personal appearance, race, religion, or sexual identity and orientation. 13 | 14 | 15 | ### The Standards 16 | 17 | Examples of behaviour that contributes to creating a positive environment include: 18 | 19 | * **Be welcoming**: We strive to be a community that welcomes and supports people of all backgrounds and identities. This includes, but is not limited to members of any race, ethnicity, culture, national origin, colour, immigration status, social and economic class, educational level, sex, sexual orientation, gender identity and expression, age, size, family status, political belief, religion, and mental and physical ability. 20 | * **Be considerate**: Your work will be used by other people, and you in turn will depend on the work of others. Any decision you take will affect users and colleagues, and you should take those consequences into account when making decisions. Remember that we're a world-wide community, so you might not be communicating in someone else's primary language. 21 | * **Be respectful**: Not all of us will agree all the time, but disagreement is no excuse for poor behavior and poor manners. We might all experience some frustration now and then, but we cannot allow that frustration to turn into a personal attack. It’s important to remember that a community where people feel uncomfortable or threatened is not a productive one. 22 | * **Gracefully accepting constructive criticism**: Not everyone are perfect, you can get some critism of your works from us, but it's not means that we don't accepting your contribution, we just want you to fixing it and making it better. 23 | * **Referring to people by their preferred pronouns/words**, but we do not have standardized gender-neutral pronouns/words, so your milleage may vary. 24 | * **Do not attack somebody because you have a different opinion** All opinions are accepted as long as they are reasonable, and everyone have right to shouting their opinion. 25 | * **Just chill :D** 26 | * **Don't forget, nobody is perfect, mistakes can be made** 27 | * **Equality is not a privilege, it's a rule!** 28 | 29 | ### Examples of unacceptable behaviour by participants include: 30 | 31 | * **Trolling, insulting/derogatory comments, public or private harassment** 32 | * **Publishing others' private information (Doxing)** such as a physical or electronic address, without explicit permission 33 | * **Not being respectful to reasonable communication boundaries** such as 'leave me alone,' 'go away,' or 'Fuck off.' 34 | * **The usage of sexualised language or imagery and unwelcome sexual attention or advances** 35 | * **Demonstrating the graphics or any other content you know may be considered disturbing** 36 | * **Assuming or promoting any kind of inequality** including but not limited to: age, body size, disability, ethnicity, gender identity and expression, nationality and race, personal appearance, religion, or sexual identity and orientation 37 | * **Drug promotion of any kind** 38 | * **Attacking personal tastes** 39 | * **Other conduct which you know could reasonably be considered inappropriate in a professional setting** 40 | 41 | 42 | ### Enforcement 43 | 44 | Violations of the Code of Conduct may be reported by sending an email to [raphielscape@outlook.com](mailto:raphielscape@outlook.com). 45 | All reports will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. 46 | Further details of specific enforcement policies may be posted separately. 47 | 48 | We hold the right and responsibility to remove comments or other contributions that 49 | are not aligned to this Code of Conduct, or to ban temporarily or permanently any members 50 | for other behaviours that they deem inappropriate, threatening, offensive, or harmful. -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | # Faster & Secure & Special Container # 2 | # Thanks to mkaraniya & zakaryan2004 3 | 4 | FROM fusuf/asenauserbot:latest 5 | RUN git clone https://github.com/quiec/AsenaUserBot /root/AsenaUserBot 6 | WORKDIR /root/AsenaUserBot/ 7 | RUN pip3 install -r requirements.txt 8 | CMD ["python3", "main.py"] 9 | -------------------------------------------------------------------------------- /Procfile: -------------------------------------------------------------------------------- 1 | worker: python3 main.py -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | [No more support.](https://t.me/fusufs/826) 3 | 4 | ---- 5 | 6 |
7 | 8 |

Asena UserBot

9 |
10 |

11 | Asena UserBot, Telegram kullanmanızı kolaylaştıran bir bottur. Tamamen açık kaynaklı ve ücretsizdir. 12 |
13 | Kurulum | 14 | Güncelleme | 15 | Telegram Kanalı 16 |
17 |

18 | 19 | ---- 20 | ![Docker Pulls](https://img.shields.io/docker/pulls/fusuf/asenauserbot?style=flat-square) ![Docker Image Size (latest by date)](https://img.shields.io/docker/image-size/fusuf/asenauserbot?style=flat-square) 21 | ## Kurulum 22 | ### Çok Basit Yöntem 23 | [Youtube Videosu](https://www.youtube.com/watch?v=mUUQ53TYqI0) ![YouTube Video Views](https://img.shields.io/youtube/views/mUUQ53TYqI0?style=flat-square) 24 | 25 | **Android:** Termuxu açın ve bu kodu yapıştırın: `bash <(curl -L https://kutt.it/88I5KA)` 26 | 27 | **iOS:** iSH açın ve bu kodu yapıştırın: `apk update && apk add bash && apk add curl && curl -L -o asena_installer.sh https://t.ly/vATX && chmod +x asena_installer.sh && bash asena_installer.sh` 28 | 29 | **Windows 10:** [Python](https://www.microsoft.com/en-us/p/python-38/9mssztt1n39l#activetab=pivot:overviewtab) indirin ardından PowerShell bu kodu yapıştırın: `Invoke-Expression (New-Object System.Net.WebClient).DownloadString('https://kutt.it/aYTzCx')` 30 | 31 | ### Basit Yöntem 32 | Eğer botu kurma hakkında fikriniz yoksa burayı okuyunuz: [Kurulum Rehberi](https://github.com/Quiec/AsenaUserBot/wiki/Kurulum/) 33 | 34 | [![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy?template=https://github.com/Quiec/AsenaUserBot) 35 | ### Zor Yöntem 36 | ```python 37 | git clone https://github.com/Quiec/AsenaUserBot.git 38 | cd AsenaUserBot 39 | pip install -r requirements.txt 40 | # Config.env oluşturun ve düzenleyin. # 41 | python3 main.py 42 | ``` 43 | 44 | ## Örnek Plugin 45 | ```python 46 | from userbot.events import register 47 | from userbot.cmdhelp import CmdHelp # <-- Bunu ekleyin. 48 | 49 | @register(outgoing=True, pattern="^.deneme") 50 | async def deneme(event): 51 | await event.edit('Gerçekten deneme!') 52 | 53 | Help = CmdHelp('deneme') # Bilgi ekleyeceğiz diyoruz. 54 | Help.add_command('deneme', # Komut 55 | None, # Komut parametresi varsa yazın yoksa None yazın 56 | 'Gerçekten deneme yapıyor!', # Komut açıklaması 57 | 'deneme' # Örnek kullanım. 58 | ) 59 | Help.add_info('@Fusuf tarafından yapılmıştır.') # Bilgi ekleyebilirsiniz. 60 | # Ya da uyarı --> Help.add_warning('KULLANMA!') 61 | Help.add() # Ve Ekleyelim. 62 | ``` 63 | 64 | ## Bilgilendirme 65 | Herhangi bir istek & şikâyet & öneri varsa [destek grubuna](https://t.me/AsenaSupport) ulaşabilirsiniz. 66 | 67 | ``` 68 | Userbottan dolayı; Telegram hesabınız yasaklanabilir. 69 | Bu bir açık kaynaklı projedir, yaptığınız her işlemden kendiniz sorumlusunuz. Kesinlikle Asena yöneticileri sorumluluk kabul etmemektedir. 70 | Asenayı kurarak bu sorumlulukları kabul etmiş sayılırsınız. 71 | ``` 72 | 73 | ## Credit 74 | Thanks for; 75 | 76 | [Seden UserBot](https://github.com/TeamDerUntergang/Telegram-UserBot) 77 | 78 | [Userge](https://github.com/UsergeTeam/Userge) 79 | 80 | [Spechide](https://github.com/Spechide) 81 | -------------------------------------------------------------------------------- /generate_drive_session.py: -------------------------------------------------------------------------------- 1 | from pydrive.auth import GoogleAuth 2 | 3 | 4 | def main(): 5 | gauth = GoogleAuth() 6 | # Kayıtlı istemci kimlik bilgilerini yüklemeyi dene 7 | gauth.LoadCredentialsFile("secret.json") 8 | if gauth.credentials is None: 9 | # Orada değillerse kimlik doğrulaması yap 10 | gauth.LocalWebserverAuth() 11 | elif gauth.access_token_expired: 12 | # Süresi dolmuşsa yenile 13 | gauth.Refresh() 14 | else: 15 | # Kaydedilen kimlik bilgilerini başlat 16 | gauth.Authorize() 17 | # Geçerli kimlik bilgilerini bir dosyaya kaydet 18 | gauth.SaveCredentialsFile("secret.json") 19 | 20 | 21 | if __name__ == '__main__': 22 | main() 23 | -------------------------------------------------------------------------------- /heroku.yml: -------------------------------------------------------------------------------- 1 | build: 2 | docker: 3 | worker: Dockerfile 4 | run: 5 | worker: python3 main.py 6 | -------------------------------------------------------------------------------- /init/CI_Test_Script.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright (C) 2019 The Raphielscape Company LLC. 3 | # 4 | # Licensed under the Raphielscape Public License, Version 1.b (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # 7 | # CI Runner Script for baalajimaestro's userbot 8 | 9 | # We need this directive 10 | # shellcheck disable=1090 11 | 12 | . "$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")"/telegram 13 | 14 | PARSE_BRANCH="$(git rev-parse --abbrev-ref HEAD)" 15 | PARSE_ORIGIN="$(git config --get remote.origin.url)" 16 | COMMIT_POINT="$(git log --pretty=format:'%h : %s' -1)" 17 | COMMIT_HASH="$(git rev-parse --verify HEAD)" 18 | TELEGRAM_TOKEN=${BOT_API_KEY} 19 | export BOT_API_KEY PARSE_BRANCH PARSE_ORIGIN COMMIT_POINT TELEGRAM_TOKEN 20 | 21 | kickstart_pub 22 | 23 | req_install() { 24 | pip3 install -r requirements.txt 25 | } 26 | 27 | get_session() { 28 | curl -sLo userbot.session "$PULL_LINK" 29 | } 30 | 31 | test_run() { 32 | python3 -m userbot test 33 | STATUS=${?} 34 | export STATUS 35 | } 36 | 37 | # Nuke Trap, coz it not working 38 | 39 | tg_senderror() { 40 | tg_sendinfo "Build Throwing Error(s)" \ 41 | "@baalajimaestro @raphielscape @MrYacha please look in!" \ 42 | "Logs: https://semaphoreci.com/baalajimaestro/telegram-userbot" 43 | 44 | [ -n "${STATUS}" ] && 45 | exit "${STATUS}" || 46 | exit 1 47 | } 48 | 49 | tg_yay() { 50 | tg_sendinfo "Compilation Success!" 51 | } 52 | 53 | # Fin Prober 54 | fin() { 55 | echo "Yay! My works took $((DIFF / 60)) minute(s) and $((DIFF % 60)) seconds.~" 56 | tg_yay 57 | } 58 | 59 | finerr() { 60 | echo "My works took $((DIFF / 60)) minute(s) and $((DIFF % 60)) seconds but it's error..." 61 | tg_senderror 62 | 63 | [ -n "${STATUS}" ] && 64 | exit "${STATUS}" || 65 | exit 1 66 | } 67 | 68 | execute() { 69 | BUILD_START=$(date +"%s") 70 | req_install 71 | test_run 72 | BUILD_END=$(date +"%s") 73 | DIFF=$((BUILD_END - BUILD_START)) 74 | if [ $STATUS -eq 0 ]; 75 | then 76 | fin 77 | else 78 | finerr 79 | fi 80 | } 81 | 82 | get_session 83 | execute -------------------------------------------------------------------------------- /init/Merge.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright (C) 2019 The Raphielscape Company LLC. 3 | # 4 | # Licensed under the Raphielscape Public License, Version 1.b (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # 7 | # CI Runner Script for baalajimaestro's userbot 8 | 9 | # We need this directive 10 | # shellcheck disable=1090 11 | 12 | export SEMAPHORE_PROJECT_DIR=`pwd` 13 | . "$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")"/telegram 14 | TELEGRAM_TOKEN=${BOT_API_KEY} 15 | export BOT_API_KEY TELEGRAM_TOKEN 16 | tg_sendinfo "I am gonna merge staging into master" 17 | cd 18 | git clone https://github.com/RaphielGang/Telegram-UserBot.git 19 | cd Telegram-UserBot 20 | git remote rm origin 21 | git remote add origin https://baalajimaestro:${GH_PERSONAL_TOKEN}@github.com/raphielgang/telegram-userbot.git 22 | git fetch 23 | git checkout staging 24 | git pull origin staging 25 | git push --force origin staging:master 26 | tg_sendinfo "I have merged all commits from staging into master" 27 | -------------------------------------------------------------------------------- /init/init_script.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env dash 2 | 3 | set -e 4 | 5 | scr_dir=$(realpath $(dirname $0)) 6 | prog_f=$scr_dir/.progress 7 | 8 | reset_prog() { 9 | if [ -f "$prog_f" ]; then 10 | echo "Cleaning: $prog_f" 11 | rm $prog_f 12 | fi 13 | echo "Al progress has been reset.. now u can re-run the script from start" 14 | exit 15 | } 16 | 17 | save_prog() { 18 | echo "$1=y" >> $prog_f 19 | } 20 | 21 | #reset progress.. if user prompted 22 | [ "$1" = "--reset" ] && reset_prog 23 | 24 | #load progress... if any 25 | [ -f "$prog_f" ] && source $prog_f 26 | 27 | # Welcome Message 28 | welcome() { 29 | echo "*****Welcome to Quiec's userbot setup***** 30 | This Guided Setup shall help you get your own userbot up and running. 31 | You might be asked for sudo password several number of times." 32 | } 33 | 34 | # Package requirements install 35 | packageinstall() { 36 | # add-apt-repository only exists in Ubuntu 37 | [ "$(lsb_release -is)" = "Ubuntu" ] && sudo add-apt-repository ppa:deadsnakes/ppa 38 | 39 | sudo apt --yes --force-yes upgrade 40 | sudo apt --yes --force-yes install build-essential checkinstall git \ 41 | libreadline-gplv2-dev libncursesw5-dev libssl-dev wget \ 42 | libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev 43 | sudo apt --yes --force-yes install python3.7 docker 44 | } 45 | 46 | # Clone the required repo 47 | botclone() { 48 | cd ~ 49 | echo "Cloning bot sources..." 50 | if [ -z "$bot_clone" ]; then 51 | git clone https://github.com/Quuiec/AsenaUserBot -b master 52 | save_prog "bot_clone" 53 | fi 54 | echo "DONE!!" 55 | cd Telegram-UserBot 56 | } 57 | 58 | # Requirement install function 59 | reqinstall() { 60 | echo "***Installing Requirements***" 61 | if [ -z "$req" ]; then 62 | sudo python3.7 -m pip install -r requirements.txt 63 | clear 64 | save_prog "req" 65 | fi 66 | echo "DONE!!" 67 | } 68 | 69 | DB="n" 70 | 71 | # Questionaire 72 | questions() { 73 | echo "***Please enter your details***" 74 | read -r -p "What's your API_ID? " API_KEY 75 | read -r -p "What's your API_HASH? " API_HASH 76 | read -r -p "What's your Screenshot Layer API Key? " SCREENSHOT_LAYER_ACCESS_KEY 77 | 78 | read -r -p "Do you need PMPermit Enabled? (y/n) " PMPERMIT 79 | if [ "$PMPERMIT" = "y" ]; then 80 | PM_AUTO_BAN=True 81 | else 82 | PM_AUTO_BAN=False 83 | fi 84 | 85 | read -r -p "Do you need Logging Enabled? (y/n) " LOG 86 | if [ "$LOG" = "y" ]; then 87 | read -r -p "Enter the Log Group ID: " LOGGER_GROUP 88 | LOGGER=True 89 | else 90 | LOGGER=False 91 | LOGGER_GROUP=0 92 | fi 93 | read -r -p "What's your OpenWeatherMap API Key? " OPEN_WEATHER_MAP_APPID 94 | 95 | read -r -p "Do you need a Database Mode? (y/n) " DB 96 | if [ "$DB" = "y" ]; then 97 | read -r -p "Enter your DB URL: " DB_URI 98 | else 99 | DB_URI=None 100 | fi 101 | } 102 | 103 | #Fixup the postgresql server 104 | postgresconfig() { 105 | echo "PostgreSQL config..." 106 | if [ -z "$psql" ]; then 107 | TRACK = echo `ls /etc/postgresql` 108 | sudo mv init/pg_hba.conf /etc/postgresql/$TRACK/main/pg_hba.conf 109 | sudo echo "listen_address = '*'" >> postgresql.conf 110 | save_prog "psql" 111 | fi 112 | echo "DONE!!" 113 | } 114 | 115 | # Config write function 116 | writeconfig() { 117 | echo "Configuring..." 118 | if [ -z "$gen_conf" ]; then 119 | questions 120 | echo "API_KEY=$API_KEY 121 | API_HASH=$API_HASH 122 | SCREENSHOT_LAYER_ACCESS_KEY=$SCREENSHOT_LAYER_ACCESS_KEY 123 | PM_AUTO_BAN=$PM_AUTO_BAN 124 | LOGGER=$LOGGER 125 | LOGGER_GROUP=$LOGGER_GROUP 126 | OPEN_WEATHER_MAP_APPID=$OPEN_WEATHER_MAP_APPID 127 | DATABASE_URL=$DB_URI" >> config.env 128 | sudo mv config.env ~/Telegram-UserBot 129 | save_prog "gen_conf" 130 | fi 131 | echo "DONE!!" 132 | } 133 | 134 | #Generate the userbot.session 135 | session() { 136 | echo "Generating session..." 137 | if [ -z "$sess" ]; then 138 | python3 windows_startup_script.py 139 | python3.7 -m userbot test 140 | save_prog "sess" 141 | fi 142 | echo "DONE!!" 143 | } 144 | 145 | #Spinup Docker installation 146 | dockerspin() { 147 | echo "Docker installation..." 148 | if [ -z "$dock" ]; then 149 | sudo systemctl start docker 150 | sudo systemctl enable docker 151 | sudo chmod 777 /var/run/docker.sock 152 | cd ~/Telegram-UserBot 153 | docker build -t userbot . 154 | save_prog "dock" 155 | fi 156 | echo "DONE!!" 157 | } 158 | 159 | # Systemd service bringup 160 | systemd() { 161 | echo "Sys service..." 162 | if [ -z "$sysserv" ]; then 163 | sudo mv userbot /etc/systemd/system/userbot.service 164 | save_prog "sysserv" 165 | fi 166 | sudo systemctl start userbot.service 167 | sudo systemctl enable userbot.service 168 | echo "DONE!!" 169 | } 170 | 171 | # Close down 172 | close() { 173 | echo " 174 | 175 | Pushed to systemd service. Bot runs on docker, and it will run across reboots too. 176 | 177 | Hope you love using my bot." 178 | exit 179 | } 180 | 181 | # 182 | # Here's where the mejik happens 183 | # 184 | clear 185 | welcome 186 | 187 | createuser 188 | cd /tmp || exit 189 | botclone 190 | 191 | reqinstall 192 | 193 | writeconfig 194 | 195 | if [ "$DB" = "y" ] 196 | then 197 | postgresconfig 198 | fi 199 | 200 | session 201 | dockerspin 202 | 203 | systemd 204 | close 205 | -------------------------------------------------------------------------------- /init/telegram: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env dash 2 | # shellcheck source=/dev/null 3 | # 4 | # Copyright (C) 2018 Raphielscape LLC. 5 | # 6 | # Licensed under the Raphielscape Public License, Version 1.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # 9 | # Telegram command container 10 | 11 | TELEGRAM=$SEMAPHORE_PROJECT_DIR/init/telegramapi 12 | export TELEGRAM 13 | # Caster configurations 14 | MAINGROUP_ID="-1001372533112" 15 | BUILDSCAPERER_ID="-1001192834712" 16 | DEBUG_ID="-1001200493978" 17 | 18 | # Graphics Interchange Format Assets 19 | Start_Asset="CAADBAADHwEAArznMw8iLJLuDeQskAI" 20 | Stop_Asset="https://i.imgur.com/Q6nllGX.gif" 21 | Jump_Asset="https://media.giphy.com/media/l41lI4bYmcsPJX9Go/giphy.gif" 22 | 23 | # GIF Stuff 24 | tg_build_sendsticker() { 25 | curl -s -X POST "https://api.telegram.org/bot$BOT_API_KEY/SendSticker" \ 26 | -d sticker="${Start_Asset}" \ 27 | -d chat_id=${BUILDSCAPERER_ID} >> /dev/null 28 | } 29 | 30 | tg_buildmain_sendgif() { 31 | curl -s -X POST "https://api.telegram.org/bot$BOT_API_KEY/SendAnimation" \ 32 | -d animation="${Jump_Asset}" \ 33 | -d chat_id=${MAINGROUP_ID} >> /dev/null 34 | } 35 | 36 | # Interruption Happen, report with GIF 37 | tg_intgif() { 38 | curl -s -X POST "https://api.telegram.org/bot$BOT_API_KEY/SendAnimation" \ 39 | -d animation="${Stop_Asset}" \ 40 | -d chat_id=${BUILDSCAPERER_ID} >> /dev/null 41 | } 42 | 43 | tg_intgifmain() { 44 | curl -s -X POST "https://api.telegram.org/bot$BOT_API_KEY/SendAnimation" \ 45 | -d animation="${Stop_Asset}" \ 46 | -d chat_id=${MAINGROUP_ID} >> /dev/ -t null 47 | } 48 | 49 | # Push to Channel 50 | push() { 51 | "${TELEGRAM}" -f "Retarded-Nightly.zip" \ 52 | -c ${BUILDSCAPERER_ID} -t $BOT_API_KEY 53 | } 54 | 55 | # sendcast to group 56 | tg_sendinfo() { 57 | "${TELEGRAM}" -c ${MAINGROUP_ID} -H \ 58 | "$( 59 | for POST in "${@}"; do 60 | echo "${POST}" 61 | done 62 | )" \ 63 | -t $BOT_API_KEY 64 | } 65 | 66 | # sendcast to channel 67 | tg_channelcast() { 68 | "${TELEGRAM}" -c ${BUILDSCAPERER_ID} -H \ 69 | "$( 70 | for POST in "${@}"; do 71 | echo "${POST}" 72 | done 73 | )" \ 74 | -t $BOT_API_KEY 75 | } 76 | 77 | # Debugcasting 78 | tg_debugcast() { 79 | "${TELEGRAM}" -c ${DEBUG_ID} -H \ 80 | "$( 81 | for POST in "${@}"; do 82 | echo "${POST}" 83 | done 84 | )" \ 85 | -t $BOT_API_KEY 86 | } 87 | 88 | kickstart_pub() { 89 | 90 | tg_sendinfo "I am starting build" \ 91 | "Branch ${PARSE_BRANCH}" \ 92 | "Commit Point ${COMMIT_POINT}" \ 93 | " " \ 94 | "Github Link: https://github.com/naytseyd/telegram-userbot/commit/${COMMIT_HASH}" \ 95 | " " \ 96 | "CI Link: https://semaphoreci.com/baalajimaestro/telegram-userbot" 97 | } 98 | 99 | kickstart_priv() { 100 | tg_buildmain_sendgif 101 | 102 | tg_debugcast "Compiler ${COMPILER_USED}" \ 103 | "Device ${DEVICE}" \ 104 | "Branch ${PARSE_BRANCH}" \ 105 | "Commit Point ${COMMIT_POINT}" \ 106 | "Under $(hostname)" \ 107 | "Started on $(whoami)" 108 | 109 | tg_debugcast "This ${COMPILER_USED} build will not producing any binaries" \ 110 | "This is internal build" 111 | } 112 | -------------------------------------------------------------------------------- /init/userbot: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Telegram UserBot Systemd Service 3 | After=network.target 4 | 5 | [Install] 6 | WantedBy=multi-user.target 7 | 8 | [Service] 9 | Type=simple 10 | User=root 11 | ExecStart=bash ./runner.sh 12 | ProtectSystem=full 13 | Restart=on-failure 14 | # Other Restart options: or always, on-abort, etc 15 | -------------------------------------------------------------------------------- /main.py: -------------------------------------------------------------------------------- 1 | # Added for fix restart event 2 | if __name__ == '__main__': 3 | from userbot import main 4 | -------------------------------------------------------------------------------- /modules: -------------------------------------------------------------------------------- 1 | import os 2 | import subprocess 3 | import platform 4 | from userbot import SUDO 5 | 6 | def _start_instalation(): 7 | install_with = None 8 | package_managers = ["pacman", "apt-get", "yum", "brew", "yaourt", "dnf", "homebrew", "eopkg", "snap"] 9 | if "linux" in str(platform.system()).lower(): 10 | for manager in package_managers: 11 | try: 12 | subprocess.check_call(f"which {manager}", shell=True, stderr=subprocess.STDOUT) 13 | install_package(manager) 14 | return 15 | except: 16 | continue 17 | 18 | 19 | 20 | def install_package(package_manager): 21 | packages = [] 22 | to_install = [] 23 | with open("Aptfile") as file: 24 | for line in file: 25 | packages.append(line) 26 | 27 | for package in packages: 28 | try: 29 | subprocess.check_call(f"which {package}", shell=True, stderr=subprocess.STDOUT) 30 | except: 31 | to_install.append(package) 32 | 33 | if to_install: 34 | if SUDO: 35 | subprocess.Popen(f"echo {str(SUDO)} | sudo -S {str(package_manager)}" + 36 | f" install -y {' '.join(to_install)}", shell=True) 37 | else: 38 | subprocess.Popen(f"{str(package_manager)} install -y {' '.join(to_install)}", 39 | shell=True) 40 | 41 | try: 42 | if not 'heroku' in os.environ['PATH']: 43 | _start_instalation() 44 | except: 45 | _start_instalation() 46 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | aiohttp 2 | aria2p 3 | async_generator 4 | beautifulsoup4>=4.8.1 5 | bs4 6 | cairosvg 7 | chromedriver-autoinstaller 8 | coffeehouse 9 | cowpy 10 | cryptg 11 | dnspython 12 | eksipy 13 | emoji 14 | emoji-country-flag 15 | git+https://github.com/bisoncorps/search-engine-parser 16 | git+https://github.com/Joeclinton1/google-images-download.git 17 | git+https://github.com/johnwmillr/LyricsGenius.git 18 | gitpython 19 | google-api-python-client 20 | google-auth-oauthlib 21 | googletrans==4.0.0rc1 22 | google_images_download>=2.7.1 23 | gTTS-token>=1.1.3 24 | gTTS>=2.1.1 25 | hachoir 26 | heroku3 27 | httplib2 28 | humanize 29 | imagedown 30 | lottie 31 | lxml==4.5.2 32 | lyricsgenius 33 | numpy 34 | oauth2client 35 | Pillow 36 | psycopg2 37 | pybase64>=0.4.0 38 | pydub 39 | pylast==4.1.0 40 | pySmartDL 41 | python-barcode 42 | python-dotenv 43 | pytz 44 | qrcode 45 | requests>=2.18.4 46 | selenium>=3.141.0 47 | speedtest 48 | spotdl 49 | spotify_token 50 | sqlalchemy>=1.2 51 | telegraph 52 | telethon-session-sqlalchemy>=0.2.6 53 | telethon>=1.24.0 54 | twitter_scraper 55 | urbandict>=0.5 56 | wikipedia>=1.4.0 57 | youtube-dl -------------------------------------------------------------------------------- /requirementsDOCKER.txt: -------------------------------------------------------------------------------- 1 | aiohttp 2 | cowpy 3 | cowsay 4 | cryptg 5 | dnspython 6 | emoji 7 | gitpython 8 | google-api-python-client 9 | google-api-python-client 10 | google-auth-oauthlib 11 | googletrans==3.1.0a0 12 | googletrans>=2.4.0 13 | google_auth_oauthlib 14 | google_images_download>=2.4.2 15 | google_images_download>=2.4.2 16 | gsearch>=1.6.0 17 | gsearch>=1.6.0 18 | gTTS-token>=1.1.3 19 | gTTS-token>=1.1.3 20 | gTTS>=2.0.1 21 | gtts>=2.0.1 22 | gTTS>=2.0.1 23 | hachoir 24 | hastebin.py>=0.2 25 | https://github.com/LonamiWebs/Telethon/archive/master.zip 26 | incremental 27 | language_check 28 | lmgtfy 29 | Pillow>=5.3.0 30 | psycopg2 31 | pybase64>=0.4.0 32 | pyfiglet 33 | PyLyrics 34 | pymongo 35 | python-dotenv 36 | pythonping 37 | pytube 38 | redis 39 | speedtest 40 | speedtest-cli>=2.0.2 41 | spongemock 42 | spongemock 43 | spotify_token 44 | sqlalchemy>=1.2 45 | telegraph 46 | telegraph 47 | telethon-session-sqlalchemy>=0.2.6 48 | telethon-session-sqlalchemy>=0.2.6 49 | twitter_scraper 50 | urbandict>=0.5 51 | urbandict>=0.5 52 | wikipedia>=1.4.0 53 | wikipedia>=1.4.0 54 | zalgo_text>=0.6 55 | zalgo_text>=0.6 -------------------------------------------------------------------------------- /runtime.txt: -------------------------------------------------------------------------------- 1 | python-3.8.2 2 | -------------------------------------------------------------------------------- /sample_config.env: -------------------------------------------------------------------------------- 1 | # Bir şey yapmadan önce bu satırı silin 2 | ___________LUTFEN_______BU_____SATIRI_____SILIN__________=True 3 | 4 | # Bunları https://my.telegram.org/ adresinden alın 5 | API_KEY = "YOUR API KEY" 6 | API_HASH = "YOUR API HASH" 7 | 8 | # .weather komutu için OpenWeather Map API Key 9 | # https://openweathermap.org/ adresinden alın 10 | OPEN_WEATHER_MAP_APPID = "" 11 | WEATHER_DEFCITY = "" 12 | 13 | # .carbon modülü için ChromeDriver konumu 14 | # Linux makineleri için örnek : "/usr/bin/chromedriver" 15 | CHROME_DRIVER = "" 16 | 17 | # python3 GenerateStringSession çalıştırarak bu değeri alın 18 | STRING_SESSION = "" 19 | 20 | # .carbon modülü için Google Chrome konumu 21 | # Linux makineleri için örnek : "/usr/bin/chromium-browser" 22 | GOOGLE_CHROME_BIN = "" 23 | 24 | # .ocr komutu için OCR Space API Key 25 | # https://ocr.space/ocrapi adresinden alın 26 | OCR_SPACE_API_KEY = "" 27 | 28 | # .rbg komutu için remove.bg API Key 29 | # https://www.remove.bg/api adresinden alın 30 | REM_BG_API_KEY = "" 31 | 32 | # Günlük grubu için grup ID 33 | # ID'den önce tire veya negatif işaret ekleyin 34 | # Bu bir tamsayı, lütfen dizeleri kullanmayın 35 | BOTLOG_CHATID = # bu bir tamsayı, lütfen tırnak kullanmayın. 36 | 37 | # Günlüğü kapatmak istiyorsanız, bunu False olarak ayarlayın 38 | BOTLOG = True 39 | 40 | # LOGSPAMMER 41 | LOGSPAMMER = True 42 | 43 | # Günlüğe kaydetme konusunda ayrıntıya ihtiyacınız varsa 44 | CONSOLE_LOGGER_VERBOSE = False 45 | 46 | # PM otomatik ban özelliği 47 | PM_AUTO_BAN = False 48 | 49 | # Veritabanı 50 | # Örnek: 'postgres://userbot:userbot@localhost:5432/userbot' 51 | DATABASE_URL = "" 52 | 53 | # .yt komutun için YouTube Data API Key 54 | # https://console.cloud.google.com adresinden alın 55 | YOUTUBE_API_KEY = "" 56 | 57 | # Ülke ve Saat Dilimi kurulumu için 58 | # .time ve .date modülü 59 | COUNTRY = "" 60 | TZ_NUMBER = # bu bir tamsayı, lütfen tırnak kullanmayın. 61 | 62 | # .gdrive komutu için Google Drive bilgileri 63 | # https://console.cloud.google.com adresinden alın 64 | G_DRIVE_CLIENT_ID = "" 65 | G_DRIVE_CLIENT_SECRET = "" 66 | G_DRIVE_AUTH_TOKEN_DATA = "" 67 | TEMP_DOWNLOAD_DIRECTORY = "" 68 | 69 | # Last.fm modülü 70 | # https://www.last.fm/api/account/create adresinden alın 71 | LASTFM_API = None 72 | LASTFM_SECRET = None 73 | LASTFM_USERNAME = None # last.fm kullanıcı adınız 74 | LASTFM_PASSWORD = "last.fm şifreniz" 75 | 76 | # last.fm modülü için bot şarkı adından önce ekleyecektir. 77 | # Örnek: GitHub: MacTavishAO : Skillet - Feel Invincible 78 | BIO_PREFIX = "" 79 | 80 | # Varsayılan biyografi mesajı 81 | DEFAULT_BIO = "" 82 | 83 | # Lydia erişimi için 84 | LYDIA_API_KEY = "" 85 | LYDIA_ANTI-PM = "" 86 | 87 | # Anti Spambot 88 | ANTI_SPAMBOT = False 89 | ANTI_SPAMBOT_SHOUT = False 90 | 91 | # Genius modülü 92 | GENIUS = "" 93 | 94 | # Auto PP modülü 95 | AUTO_PP = "" 96 | 97 | # Inline bot çalışması için 98 | BOT_USERNAME = "" 99 | BOT_TOKEN = "" 100 | 101 | # Galeri 102 | GALERI_SURE = 60 103 | 104 | # WARN 105 | WARN_LIMIT = 3 106 | WARN_SURE = 60 -------------------------------------------------------------------------------- /userbot/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yusufusta/AsenaUserBot/d850bae0f8491911465fb5f54e1692b0b9f112de/userbot/.DS_Store -------------------------------------------------------------------------------- /userbot/cmdhelp.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2020 Yusuf Usta. 2 | # 3 | # Licensed under the GPL-3.0 License; 4 | # you may not use this file except in compliance with the License. 5 | # 6 | 7 | # Asena UserBot - Yusuf Usta 8 | from userbot import PATTERNS, CMD_HELP, CMD_HELP_BOT 9 | 10 | class CmdHelp: 11 | """ 12 | Komut yardımlarını daha iyi üretmek için yazdığım sınıf. 13 | """ 14 | 15 | FILE = "" 16 | ORIGINAL_FILE = "" 17 | FILE_AUTHOR = "" 18 | IS_OFFICIAL = True 19 | COMMANDS = {} 20 | PREFIX = PATTERNS[:1] 21 | WARNING = "" 22 | INFO = "" 23 | 24 | def __init__(self, file: str, official : bool = True, file_name : str = None): 25 | self.FILE = file 26 | self.ORIGINAL_FILE = file 27 | self.IS_OFFICIAL = official 28 | self.FILE_NAME = file_name if not file_name == None else file + '.py' 29 | self.COMMANDS = {} 30 | self.FILE_AUTHOR = "" 31 | self.WARNING = "" 32 | self.INFO = "" 33 | 34 | def set_file_info(self, name : str, value : str): 35 | if name == 'name': 36 | self.FILE = value 37 | elif name == 'author': 38 | self.FILE_AUTHOR = value 39 | return self 40 | 41 | def add_command(self, command : str, params = None, usage: str = '', example = None): 42 | """ 43 | Komut ekler. 44 | """ 45 | 46 | self.COMMANDS[command] = {'command': command, 'params': params, 'usage': usage, 'example': example} 47 | return self 48 | 49 | def add_warning(self, warning): 50 | self.WARNING = warning 51 | return self 52 | 53 | def add_info(self, info): 54 | self.INFO = info 55 | return self 56 | 57 | def get_result(self): 58 | """ 59 | Sonuç getirir. 60 | """ 61 | 62 | result = f"**📗 Dosya:** `{self.FILE}`\n" 63 | if self.WARNING == '' and self.INFO == '': 64 | result += f"**⬇️ Official:** {'✅' if self.IS_OFFICIAL else '❌'}\n\n" 65 | else: 66 | result += f"**⬇️ Official:** {'✅' if self.IS_OFFICIAL else '❌'}\n" 67 | 68 | if self.INFO == '': 69 | if not self.WARNING == '': 70 | result += f"**⚠️ Uyarı:** {self.WARNING}\n\n" 71 | else: 72 | if not self.WARNING == '': 73 | result += f"**⚠️ Uyarı:** {self.WARNING}\n" 74 | result += f"**ℹ️ Info:** {self.INFO}\n\n" 75 | 76 | for command in self.COMMANDS: 77 | command = self.COMMANDS[command] 78 | if command['params'] == None: 79 | result += f"**🛠 Komut:** `{PATTERNS[:1]}{command['command']}`\n" 80 | else: 81 | result += f"**🛠 Komut:** `{PATTERNS[:1]}{command['command']} {command['params']}`\n" 82 | 83 | if command['example'] == None: 84 | result += f"**💬 Açıklama:** `{command['usage']}`\n\n" 85 | else: 86 | result += f"**💬 Açıklama:** `{command['usage']}`\n" 87 | result += f"**⌨️ Örnek:** `{PATTERNS[:1]}{command['example']}`\n\n" 88 | return result 89 | 90 | def add(self): 91 | """ 92 | Direkt olarak CMD_HELP ekler. 93 | """ 94 | CMD_HELP_BOT[self.FILE] = {'info': {'official': self.IS_OFFICIAL, 'warning': self.WARNING, 'info': self.INFO}, 'commands': self.COMMANDS} 95 | CMD_HELP[self.FILE] = self.get_result() 96 | return True 97 | 98 | def getText(self, text : str): 99 | if text == 'REPLY_OR_USERNAME': 100 | return ' ' 101 | elif text == 'OR': 102 | return 'veya' 103 | elif text == 'USERNAMES': 104 | return '' 105 | -------------------------------------------------------------------------------- /userbot/events.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2019 The Raphielscape Company LLC. 2 | # 3 | # Licensed under the Raphielscape Public License, Version 1.c (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # 6 | 7 | # Asena UserBot - Yusuf Usta 8 | 9 | """ Olayları yönetmek için UserBot modülü. 10 | UserBot'un ana bileşenlerinden biri. """ 11 | 12 | import sys 13 | from asyncio import create_subprocess_shell as asyncsubshell 14 | from asyncio import subprocess as asyncsub 15 | from os import remove 16 | from time import gmtime, strftime 17 | from traceback import format_exc 18 | 19 | from telethon import events 20 | 21 | from userbot import bot, BOTLOG_CHATID, LOGSPAMMER, PATTERNS 22 | 23 | 24 | def register(**args): 25 | """ Yeni bir etkinlik kaydedin. """ 26 | pattern = args.get('pattern', None) 27 | disable_edited = args.get('disable_edited', False) 28 | groups_only = args.get('groups_only', False) 29 | trigger_on_fwd = args.get('trigger_on_fwd', False) 30 | trigger_on_inline = args.get('trigger_on_inline', False) 31 | disable_errors = args.get('disable_errors', False) 32 | 33 | if pattern: 34 | args["pattern"] = pattern.replace("^.", "^["+ PATTERNS + "]") 35 | if "disable_edited" in args: 36 | del args['disable_edited'] 37 | 38 | if "ignore_unsafe" in args: 39 | del args['ignore_unsafe'] 40 | 41 | if "groups_only" in args: 42 | del args['groups_only'] 43 | 44 | if "disable_errors" in args: 45 | del args['disable_errors'] 46 | 47 | if "trigger_on_fwd" in args: 48 | del args['trigger_on_fwd'] 49 | 50 | if "trigger_on_inline" in args: 51 | del args['trigger_on_inline'] 52 | 53 | def decorator(func): 54 | async def wrapper(check): 55 | if not LOGSPAMMER: 56 | send_to = check.chat_id 57 | else: 58 | send_to = BOTLOG_CHATID 59 | 60 | if not trigger_on_fwd and check.fwd_from: 61 | return 62 | 63 | if check.via_bot_id and not trigger_on_inline: 64 | return 65 | 66 | if groups_only and not check.is_group: 67 | await check.respond("`Bunun bir grup olduğunu sanmıyorum.`") 68 | return 69 | 70 | try: 71 | await func(check) 72 | 73 | 74 | except events.StopPropagation: 75 | raise events.StopPropagation 76 | except KeyboardInterrupt: 77 | pass 78 | except BaseException: 79 | if not disable_errors: 80 | date = strftime("%Y-%m-%d %H:%M:%S", gmtime()) 81 | 82 | text = "**USERBOT HATA RAPORU**\n" 83 | link = "[Asena Destek Grubu](https://t.me/AsenaSupport)" 84 | text += "İsterseniz, bunu rapor edebilirsiniz" 85 | text += f"- sadece bu mesajı buraya iletin {link}.\n" 86 | text += "Hata ve Tarih dışında hiçbir şey kaydedilmez\n" 87 | 88 | ftext = "========== UYARI ==========" 89 | ftext += "\nBu dosya sadece burada yüklendi," 90 | ftext += "\nsadece hata ve tarih kısmını kaydettik," 91 | ftext += "\ngizliliğinize saygı duyuyoruz," 92 | ftext += "\nburada herhangi bir gizli veri varsa" 93 | ftext += "\nbu hata raporu olmayabilir, kimse verilerinize ulaşamaz.\n" 94 | ftext += "================================\n\n" 95 | ftext += "--------USERBOT HATA GUNLUGU--------\n" 96 | ftext += "\nTarih: " + date 97 | ftext += "\nGrup ID: " + str(check.chat_id) 98 | ftext += "\nGönderen kişinin ID: " + str(check.sender_id) 99 | ftext += "\n\nOlay Tetikleyici:\n" 100 | ftext += str(check.text) 101 | ftext += "\n\nGeri izleme bilgisi:\n" 102 | ftext += str(format_exc()) 103 | ftext += "\n\nHata metni:\n" 104 | ftext += str(sys.exc_info()[1]) 105 | ftext += "\n\n--------USERBOT HATA GUNLUGU BITIS--------" 106 | 107 | command = "git log --pretty=format:\"%an: %s\" -10" 108 | ftext += "\n\n\nUserbot ID: QXNlbmEgVGVsZWdyYW0*" 109 | ftext += "\nSon 10 commit:\n" 110 | 111 | process = await asyncsubshell(command, 112 | stdout=asyncsub.PIPE, 113 | stderr=asyncsub.PIPE) 114 | stdout, stderr = await process.communicate() 115 | result = str(stdout.decode().strip()) \ 116 | + str(stderr.decode().strip()) 117 | 118 | ftext += result 119 | 120 | file = open("error.log", "w+") 121 | file.write(ftext) 122 | file.close() 123 | 124 | if LOGSPAMMER: 125 | await check.client.respond("`Üzgünüm, UserBot'um çöktü.\ 126 | \nHata günlükleri UserBot günlük grubunda saklanır.`") 127 | 128 | await check.client.send_file(send_to, 129 | "error.log", 130 | caption=text) 131 | remove("error.log") 132 | else: 133 | pass 134 | if not disable_edited: 135 | bot.add_event_handler(wrapper, events.MessageEdited(**args)) 136 | bot.add_event_handler(wrapper, events.NewMessage(**args)) 137 | 138 | return wrapper 139 | 140 | return decorator 141 | -------------------------------------------------------------------------------- /userbot/fonts/impact.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yusufusta/AsenaUserBot/d850bae0f8491911465fb5f54e1692b0b9f112de/userbot/fonts/impact.ttf -------------------------------------------------------------------------------- /userbot/language.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2020 Yusuf Usta. 2 | # 3 | # Licensed under the GPL-3.0 License; 4 | # you may not use this file except in compliance with the License. 5 | # 6 | 7 | # Asena UserBot - Yusuf Usta 8 | 9 | from . import LANGUAGE, LOGS, bot, PLUGIN_CHANNEL_ID 10 | from json import loads, JSONDecodeError 11 | from os import path, remove 12 | from telethon.tl.types import InputMessagesFilterDocument 13 | 14 | pchannel = bot.get_entity(PLUGIN_CHANNEL_ID) 15 | LOGS.info("Dil dosyası yükleniyor...") 16 | LANGUAGE_JSON = None 17 | 18 | for dil in bot.iter_messages(pchannel, filter=InputMessagesFilterDocument): 19 | if ((len(dil.file.name.split(".")) >= 2) and (dil.file.name.split(".")[1] == "asenajson")): 20 | if path.isfile(f"./userbot/language/{dil.file.name}"): 21 | try: 22 | LANGUAGE_JSON = loads(open(f"./userbot/language/{dil.file.name}", "r").read()) 23 | except JSONDecodeError: 24 | dil.delete() 25 | remove(f"./userbot/language/{dil.file.name}") 26 | 27 | if path.isfile("./userbot/language/DEFAULT.asenajson"): 28 | LOGS.warn("Varsayılan dil dosyası kullanılıyor...") 29 | LANGUAGE_JSON = loads(open(f"./userbot/language/DEFAULT.asenajson", "r").read()) 30 | else: 31 | raise Exception("Your language file is invalid") 32 | else: 33 | try: 34 | DOSYA = dil.download_media(file="./userbot/language/") 35 | LANGUAGE_JSON = loads(open(DOSYA, "r").read()) 36 | except JSONDecodeError: 37 | dil.delete() 38 | if path.isfile("./userbot/language/DEFAULT.asenajson"): 39 | LOGS.warn("Varsayılan dil dosyası kullanılıyor...") 40 | LANGUAGE_JSON = loads(open(f"./userbot/language/DEFAULT.asenajson", "r").read()) 41 | else: 42 | raise Exception("Your language file is invalid") 43 | break 44 | 45 | if LANGUAGE_JSON == None: 46 | if path.isfile(f"./userbot/language/{LANGUAGE}.asenajson"): 47 | try: 48 | LANGUAGE_JSON = loads(open(f"./userbot/language/{LANGUAGE}.asenajson", "r").read()) 49 | except JSONDecodeError: 50 | raise Exception("Invalid json file") 51 | else: 52 | if path.isfile("./userbot/language/DEFAULT.asenajson"): 53 | LOGS.warn("Varsayılan dil dosyası kullanılıyor...") 54 | LANGUAGE_JSON = loads(open(f"./userbot/language/DEFAULT.asenajson", "r").read()) 55 | else: 56 | raise Exception(f"Didn't find {LANGUAGE} file") 57 | 58 | LOGS.info(f"{LANGUAGE_JSON['LANGUAGE']} dili yüklendi.") 59 | 60 | def get_value (plugin = None, value = None): 61 | global LANGUAGE_JSON 62 | 63 | if LANGUAGE_JSON == None: 64 | raise Exception("Please load language file first") 65 | else: 66 | if not plugin == None or value == None: 67 | Plugin = LANGUAGE_JSON.get("STRINGS").get(plugin) 68 | if Plugin == None: 69 | raise Exception("Invalid plugin") 70 | else: 71 | String = LANGUAGE_JSON.get("STRINGS").get(plugin).get(value) 72 | if String == None: 73 | return Plugin 74 | else: 75 | return String 76 | else: 77 | raise Exception("Invalid plugin or string") -------------------------------------------------------------------------------- /userbot/modules/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yusufusta/AsenaUserBot/d850bae0f8491911465fb5f54e1692b0b9f112de/userbot/modules/.DS_Store -------------------------------------------------------------------------------- /userbot/modules/__helpme.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2020 Yusuf Usta. 2 | # 3 | # Licensed under the GPL-3.0 License; 4 | # you may not use this file except in compliance with the License. 5 | # 6 | 7 | # Asena UserBot - Yusuf Usta 8 | 9 | # @Qulec tarafından yazılmıştır. 10 | # Thanks @Spechide. 11 | 12 | from userbot import BOT_USERNAME 13 | from userbot.events import register 14 | 15 | # ██████ LANGUAGE CONSTANTS ██████ # 16 | 17 | from userbot.language import get_value 18 | LANG = get_value("__helpme") 19 | 20 | # ████████████████████████████████ # 21 | 22 | @register(outgoing=True, pattern="^.yard[iı]m|^.help") 23 | async def yardim(event): 24 | tgbotusername = BOT_USERNAME 25 | if tgbotusername is not None: 26 | results = await event.client.inline_query( 27 | tgbotusername, 28 | "@AsenaUserBot" 29 | ) 30 | await results[0].click( 31 | event.chat_id, 32 | reply_to=event.reply_to_msg_id, 33 | hide_via=True 34 | ) 35 | await event.delete() 36 | else: 37 | await event.edit(LANG["NO_BOT"]) 38 | -------------------------------------------------------------------------------- /userbot/modules/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2019 The Raphielscape Company LLC. 2 | # 3 | # Licensed under the Raphielscape Public License, Version 1.c (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # 6 | 7 | # Asena UserBot - Yusuf Usta 8 | # 9 | 10 | """ Tüm modülleri yükleyen init dosyası """ 11 | from userbot import LOGS 12 | 13 | 14 | def __list_all_modules(): 15 | from os.path import dirname, basename, isfile 16 | import glob 17 | 18 | mod_paths = glob.glob(dirname(__file__) + "/*.py") 19 | all_modules = [ 20 | basename(f)[:-3] for f in mod_paths 21 | if isfile(f) and f.endswith(".py") and not f.endswith("__init__.py") 22 | ] 23 | return all_modules 24 | 25 | 26 | ALL_MODULES = sorted(__list_all_modules()) 27 | LOGS.info("Yüklenecek modüller: %s", str(ALL_MODULES)) 28 | __all__ = ALL_MODULES + ["ALL_MODULES"] 29 | -------------------------------------------------------------------------------- /userbot/modules/auto.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2020 Yusuf Usta. 2 | # 3 | # Licensed under the GPL-3.0 License; 4 | # you may not use this file except in compliance with the License. 5 | # 6 | 7 | # Asena UserBot - Yusuf Usta 8 | 9 | 10 | 11 | import asyncio 12 | import time 13 | from telethon.tl import functions 14 | 15 | from userbot import CMD_HELP, ASYNC_POOL 16 | from userbot.events import register 17 | from userbot.cmdhelp import CmdHelp 18 | 19 | # ██████ LANGUAGE CONSTANTS ██████ # 20 | 21 | from userbot.language import get_value 22 | LANG = get_value("auto") 23 | 24 | # ████████████████████████████████ # 25 | 26 | @register(outgoing=True, pattern="^.auto ?(.*)") 27 | async def auto(event): 28 | metod = event.pattern_match.group(1).lower() 29 | 30 | if str(metod) != "isim" and str(metod) != "bio": 31 | await event.edit(LANG['INVALID_TYPE']) 32 | return 33 | 34 | if metod in ASYNC_POOL: 35 | await event.edit(LANG['ALREADY'] % metod) 36 | return 37 | 38 | await event.edit(LANG['SETTING'] % metod) 39 | if metod == "isim": 40 | HM = time.strftime("%H:%M") 41 | 42 | await event.client(functions.account.UpdateProfileRequest( # pylint:disable=E0602 43 | last_name=LANG['NAME'] % HM 44 | )) 45 | elif metod == "bio": 46 | DMY = time.strftime("%d.%m.%Y") 47 | HM = time.strftime("%H:%M") 48 | 49 | Bio = LANG['BIO'].format(tarih=DMY, saat=HM) + LANG['NICK'] 50 | await event.client(functions.account.UpdateProfileRequest( # pylint:disable=E0602 51 | about=Bio 52 | )) 53 | 54 | 55 | await event.edit(LANG['SETTED'] % metod) 56 | 57 | ASYNC_POOL.append(metod) 58 | 59 | while metod in ASYNC_POOL: 60 | try: 61 | if metod == "isim": 62 | HM = time.strftime("%H:%M") 63 | 64 | await event.client(functions.account.UpdateProfileRequest( # pylint:disable=E0602 65 | last_name=LANG['NAME'] % HM 66 | )) 67 | elif metod == "bio": 68 | DMY = time.strftime("%d.%m.%Y") 69 | HM = time.strftime("%H:%M") 70 | 71 | Bio = LANG['BIO'].format(tarih=DMY, saat=HM) + LANG['NICK'] 72 | await event.client(functions.account.UpdateProfileRequest( # pylint:disable=E0602 73 | about=Bio 74 | )) 75 | 76 | await asyncio.sleep(60) 77 | except: 78 | return 79 | 80 | CmdHelp('auto').add_command( 81 | 'auto', 'isim ya da bio', 'Otomatik saate göre değiştirir', '.auto isim' 82 | ).add() -------------------------------------------------------------------------------- /userbot/modules/autopp.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2020 Yusuf Usta. 2 | # 3 | # Licensed under the GPL-3.0 License; 4 | # you may not use this file except in compliance with the License. 5 | # 6 | 7 | # Asena UserBot - Yusuf Usta 8 | 9 | # @NaytSeyd tarafından portlanmıştır. 10 | # @frknkrc44 tarafından düzenlenmiştir. 11 | # @Fusuf tarafından AutoVideo yazılmıştır. 12 | 13 | import os 14 | from datetime import datetime 15 | from PIL import Image, ImageDraw, ImageFont 16 | from telethon.tl import functions 17 | from telethon.tl.types import InputMessagesFilterDocument 18 | from userbot import CMD_HELP, AUTO_PP, ASYNC_POOL 19 | from userbot.events import register 20 | import asyncio 21 | import random 22 | import shutil 23 | import requests 24 | import time 25 | from telethon.errors import VideoFileInvalidError 26 | from userbot.cmdhelp import CmdHelp 27 | 28 | # ██████ LANGUAGE CONSTANTS ██████ # 29 | 30 | from userbot.language import get_value 31 | LANG = get_value("autopp") 32 | 33 | # ████████████████████████████████ # 34 | 35 | # Before kang; please ask to @fusuf :) # 36 | @register(outgoing=True, pattern="^.autovideo ?(.*)$") 37 | async def autovideo(event): 38 | if 'autovideo' in ASYNC_POOL: 39 | await event.edit(LANG['VIDEO_ALREADY_CHANGING']) 40 | return 41 | 42 | if not event.reply_to_msg_id: 43 | return await event.edit(LANG['NEED_VIDEO']) 44 | else: 45 | await event.edit(LANG['SETTING_VIDEO']) 46 | 47 | # Telethon doesn't support download profile-video so ... # 48 | reply = await event.get_reply_message() 49 | video = await reply.download_media() 50 | yazi = event.pattern_match.group(1) 51 | 52 | try: 53 | os.remove("./pp.mp4") 54 | except: 55 | pass 56 | 57 | try: 58 | await event.client(functions.photos.UploadProfilePhotoRequest( 59 | video=await event.client.upload_file(video) 60 | )) 61 | except VideoFileInvalidError: 62 | return await event.edit(LANG['INVALID_VIDEO']) 63 | 64 | ASYNC_POOL.append('autovideo') 65 | 66 | await event.edit(LANG['STARTED_VIDEO']) 67 | while "autovideo" in ASYNC_POOL: 68 | saat = time.strftime("%H\.%M") 69 | tarih = time.strftime("%d\/%m\/%Y") 70 | 71 | if yazi: 72 | yazi = yazi.replace("$saat", saat).replace("$tarih", tarih) 73 | KOMUT = f"text=\'{yazi}\' :expansion=normal: y=h-line_h-10:x=(mod(5*n\,w+tw)-tw): fontcolor=white: fontsize=30: box=1: boxcolor=black@0.5: boxborderw=5: shadowx=2: shadowy=2" 74 | else: 75 | KOMUT = f"text=\'Saat\: {saat} Tarih\: {tarih} {yazi}\' :expansion=normal: y=h-line_h-10:x=(mod(5*n\,w+tw)-tw): fontcolor=white: fontsize=30: box=1: boxcolor=black@0.5: boxborderw=5: shadowx=2: shadowy=2" 76 | 77 | ses = await asyncio.create_subprocess_shell(f"ffmpeg -y -i '{video}' -vf drawtext=\"{KOMUT}\" pp.mp4") 78 | await ses.communicate() 79 | 80 | await event.client(functions.photos.UploadProfilePhotoRequest( 81 | video=await event.client.upload_file("pp.mp4") 82 | )) 83 | os.remove("./pp.mp4") 84 | await asyncio.sleep(60) 85 | 86 | os.remove(video) 87 | 88 | @register(outgoing=True, pattern="^.autopp (.*)") 89 | async def autopic(event): 90 | if 'autopic' in ASYNC_POOL: 91 | await event.edit(LANG['PHOTO_ALREADY_CHANGING']) 92 | return 93 | 94 | await event.edit(LANG['SETTING']) 95 | 96 | FONT_FILE_TO_USE = await get_font_file(event.client, "@FontDunyasi") 97 | 98 | downloaded_file_name = "./userbot/eskipp.png" 99 | r = requests.get(AUTO_PP) 100 | 101 | with open(downloaded_file_name, 'wb') as f: 102 | f.write(r.content) 103 | photo = "yenipp.png" 104 | await event.edit(LANG['SETTED']) 105 | 106 | ASYNC_POOL.append('autopic') 107 | 108 | while 'autopic' in ASYNC_POOL: 109 | shutil.copy(downloaded_file_name, photo) 110 | current_time = datetime.now().strftime("%H:%M") 111 | img = Image.open(photo) 112 | drawn_text = ImageDraw.Draw(img) 113 | fnt = ImageFont.truetype(FONT_FILE_TO_USE, 70) 114 | size = drawn_text.multiline_textsize(current_time, font=fnt) 115 | drawn_text.text(((img.width - size[0]) / 2, (img.height - size[1])), 116 | current_time, font=fnt, fill=(255, 255, 255)) 117 | img.save(photo) 118 | file = await event.client.upload_file(photo) # pylint:disable=E0602 119 | try: 120 | await event.client(functions.photos.UploadProfilePhotoRequest( # pylint:disable=E0602 121 | file 122 | )) 123 | os.remove(photo) 124 | await asyncio.sleep(60) 125 | except: 126 | return 127 | 128 | async def get_font_file(client, channel_id): 129 | # Önce yazı tipi mesajlarını al 130 | font_file_message_s = await client.get_messages( 131 | entity=channel_id, 132 | filter=InputMessagesFilterDocument, 133 | # Bu işlem çok fazla kullanıldığında 134 | # "FLOOD_WAIT" yapmaya neden olabilir 135 | limit=None 136 | ) 137 | # Yazı tipi listesinden rastgele yazı tipi al 138 | # https://docs.python.org/3/library/random.html#random.choice 139 | font_file_message = random.choice(font_file_message_s) 140 | # Dosya yolunu indir ve geri dön 141 | return await client.download_media(font_file_message) 142 | 143 | CmdHelp('autopp').add_command( 144 | 'autopp', None, 'Bu komut belirlediğiniz fotoğrafı profil resmi yapar ve bir saat ekler. Bu saat her dakika değişir.', '.autopp' 145 | ).add() 146 | 147 | CmdHelp('autovideo').add_command( 148 | 'autopp', None, 149 | 'Bu komut yanıt verdiğiniz videoyu profil video yapar ve bir saat veya tarih veya istediğiniz bir yazı ekler. Bu saat her dakika değişir. nEğer botun kendi yazısını kullanmak istiyorsanız ekstradan bir şey yazmayın. Kendi yazınızı eklemek istiyorsanız .autovideo yazı şeklinde kullanın. ', 150 | '.autovideo ahan saat $saat bu da tarih $tarih' 151 | ).add() -------------------------------------------------------------------------------- /userbot/modules/covid19.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2019 The Raphielscape Company LLC. 2 | # 3 | # Licensed under the Raphielscape Public License, Version 1.c (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # 6 | 7 | # Asena UserBot - Yusuf Usta 8 | 9 | # ██████ LANGUAGE CONSTANTS ██████ # 10 | 11 | from userbot.language import get_value 12 | LANG = get_value("covid19") 13 | 14 | # ████████████████████████████████ # 15 | 16 | from userbot import CMD_HELP 17 | from userbot.events import register 18 | from requests import get 19 | import pytz 20 | import flag 21 | from userbot.cmdhelp import CmdHelp 22 | 23 | @register(outgoing=True, pattern="^.covid ?(.*)$") 24 | async def covid(event): 25 | try: 26 | if event.pattern_match.group(1) == '': 27 | country = 'TR' 28 | else: 29 | country = event.pattern_match.group(1) 30 | 31 | bayrak = flag.flag(country) 32 | worldData = get('https://coronavirus-19-api.herokuapp.com/all').json() 33 | countryData = get('https://coronavirus-19-api.herokuapp.com/countries/' + pytz.country_names[country]).json() 34 | except: 35 | await event.edit(LANG['SOME_ERRORS']) 36 | return 37 | 38 | sonuclar = (f"** {LANG['DATA']}**\n" + 39 | f"\n**{LANG['EARTH']}**\n" + 40 | f"**{LANG['CASE']}** `{worldData['cases']}`\n" + 41 | f"**{LANG['DEATH']}** `{worldData['deaths']}`\n" + 42 | f"**{LANG['HEAL']}** `{worldData['recovered']}`\n" + 43 | f"\n**{pytz.country_names[country]}**\n" + 44 | f"**{bayrak} {LANG['TR_ALL_CASES']}** `{countryData['cases']}`\n" + 45 | f"**{bayrak} {LANG['TR_CASES']}** `{countryData['todayCases']}`\n" + 46 | f"**{bayrak} {LANG['TR_CASE']}** `{countryData['active']}`\n" + 47 | f"**{bayrak} {LANG['TR_ALL_DEATHS']}** `{countryData['deaths']}`\n" + 48 | f"**{bayrak} {LANG['TR_DEATHS']}** `{countryData['todayDeaths']}`\n" + 49 | f"**{bayrak} {LANG['TR_HEAL']}** `{countryData['recovered']}`\n" + 50 | f"**{bayrak} Test Sayısı:** `{countryData['totalTests']}`" 51 | ) 52 | await event.edit(sonuclar) 53 | 54 | CmdHelp('covid19').add_command( 55 | 'covid', '<ülke kodu>', 'Hem Dünya geneli hem de verdiğiniz ülke için güncel Covid 19 istatistikleri. Ülkeniz farklı ise komutun yanına eklemeniz yeterlidir.', 56 | 'covid az -> Azerbaycanı getirir.' 57 | ).add_warning('`Ülke yazmazsanız Türkiyeyi seçer.`').add() -------------------------------------------------------------------------------- /userbot/modules/deepfry.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2019 The Raphielscape Company LLC. 2 | # 3 | # Licensed under the Raphielscape Public License, Version 1.c (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # 6 | 7 | # Asena UserBot - Yusuf Usta 8 | 9 | 10 | # Deepfry modülü kaynak kodu: https://github.com/Ovyerus/deeppyer 11 | # @NaytSeyd tarafından portlanmıştır. 12 | 13 | import io 14 | from random import randint, uniform 15 | from userbot import CMD_HELP 16 | from userbot.events import register 17 | 18 | from PIL import Image, ImageEnhance, ImageOps 19 | from telethon.tl.types import DocumentAttributeFilename 20 | from userbot.cmdhelp import CmdHelp 21 | 22 | # ██████ LANGUAGE CONSTANTS ██████ # 23 | 24 | from userbot.language import get_value 25 | LANG = get_value("deepfry") 26 | 27 | # ████████████████████████████████ # 28 | 29 | @register(pattern="^.deepfry(?: |$)(.*)", outgoing=True) 30 | async def deepfryer(event): 31 | try: 32 | frycount = int(event.pattern_match.group(1)) 33 | if frycount < 1: 34 | raise ValueError 35 | except ValueError: 36 | frycount = 1 37 | 38 | if event.is_reply: 39 | reply_message = await event.get_reply_message() 40 | data = await check_media(reply_message) 41 | 42 | if isinstance(data, bool): 43 | await event.edit(LANG['CANT_DEEPFRY']) 44 | return 45 | else: 46 | await event.edit(LANG['REPLY_PHOTO']) 47 | return 48 | 49 | # Fotoğrafı (yüksek çözünürlük) bayt dizisi olarak indir 50 | await event.edit(LANG['MEDIA_DOWNLOADING']) 51 | image = io.BytesIO() 52 | await event.client.download_media(data, image) 53 | image = Image.open(image) 54 | 55 | # Resime uygula 56 | await event.edit(LANG['APPLYING_DEEPFRY']) 57 | for _ in range(frycount): 58 | image = await deepfry(image) 59 | 60 | fried_io = io.BytesIO() 61 | fried_io.name = "image.jpeg" 62 | image.save(fried_io, "JPEG") 63 | fried_io.seek(0) 64 | 65 | await event.reply(file=fried_io) 66 | 67 | 68 | async def deepfry(img: Image) -> Image: 69 | colours = ( 70 | (randint(50, 200), randint(40, 170), randint(40, 190)), 71 | (randint(190, 255), randint(170, 240), randint(180, 250)) 72 | ) 73 | 74 | img = img.copy().convert("RGB") 75 | 76 | # Resim formatı ayarla 77 | img = img.convert("RGB") 78 | width, height = img.width, img.height 79 | img = img.resize((int(width ** uniform(0.8, 0.9)), int(height ** uniform(0.8, 0.9))), resample=Image.LANCZOS) 80 | img = img.resize((int(width ** uniform(0.85, 0.95)), int(height ** uniform(0.85, 0.95))), resample=Image.BILINEAR) 81 | img = img.resize((int(width ** uniform(0.89, 0.98)), int(height ** uniform(0.89, 0.98))), resample=Image.BICUBIC) 82 | img = img.resize((width, height), resample=Image.BICUBIC) 83 | img = ImageOps.posterize(img, randint(3, 7)) 84 | 85 | # Renk yerleşimi oluştur 86 | overlay = img.split()[0] 87 | overlay = ImageEnhance.Contrast(overlay).enhance(uniform(1.0, 2.0)) 88 | overlay = ImageEnhance.Brightness(overlay).enhance(uniform(1.0, 2.0)) 89 | 90 | overlay = ImageOps.colorize(overlay, colours[0], colours[1]) 91 | 92 | # Kırmızı ve sarıyı ana görüntüye yerleştir ve keskinleştir 93 | img = Image.blend(img, overlay, uniform(0.1, 0.4)) 94 | img = ImageEnhance.Sharpness(img).enhance(randint(5, 300)) 95 | 96 | return img 97 | 98 | 99 | async def check_media(reply_message): 100 | if reply_message and reply_message.media: 101 | if reply_message.photo: 102 | data = reply_message.photo 103 | elif reply_message.document: 104 | if DocumentAttributeFilename(file_name='AnimatedSticker.tgs') in reply_message.media.document.attributes: 105 | return False 106 | if reply_message.gif or reply_message.video or reply_message.audio or reply_message.voice: 107 | return False 108 | data = reply_message.media.document 109 | else: 110 | return False 111 | else: 112 | return False 113 | 114 | if not data or data is None: 115 | return False 116 | else: 117 | return data 118 | 119 | CmdHelp('deepfry').add_command( 120 | 'deepfry', '', 'Belirlenen görüntüye deepfry efekti uygular.', 'deepfry 5' 121 | ).add() -------------------------------------------------------------------------------- /userbot/modules/degistir.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2020 Yusuf Usta. 2 | # 3 | # Licensed under the GPL-3.0 License; 4 | # you may not use this file except in compliance with the License. 5 | # 6 | 7 | # Asena UserBot - Yusuf Usta 8 | 9 | import re 10 | import userbot.modules.sql_helper.mesaj_sql as sql 11 | from userbot import CMD_HELP 12 | from userbot.events import register 13 | from userbot.main import PLUGIN_MESAJLAR, ORJ_PLUGIN_MESAJLAR, PLUGIN_CHANNEL_ID 14 | from userbot.cmdhelp import CmdHelp 15 | 16 | # ██████ LANGUAGE CONSTANTS ██████ # 17 | 18 | from userbot.language import get_value 19 | LANG = get_value("degistir") 20 | 21 | # ████████████████████████████████ # 22 | 23 | @register(outgoing=True, pattern="^.change ?(.*)") 24 | @register(outgoing=True, pattern="^.de[gğ]i[sş]tir ?(.*)") 25 | async def degistir(event): 26 | plugin = event.pattern_match.group(1) 27 | mesaj = re.search(r"\"(.*)\"", plugin) 28 | 29 | if mesaj: 30 | rege = re.findall(r"(?:|$)(.*)\"(.*)\"", plugin) 31 | plugin = rege[0][0] 32 | mesaj = rege[0][1] 33 | else: 34 | mesaj = [] 35 | 36 | plugin = plugin.strip() 37 | TURLER = ["afk", "alive", "pm", "kickme", "dızcı", "ban", "mute", "approve", "disapprove", "block"] 38 | if type(mesaj) == list: 39 | if plugin in TURLER: 40 | if event.is_reply: 41 | reply = await event.get_reply_message() 42 | if reply.media: 43 | mesaj = await reply.forward_to(PLUGIN_CHANNEL_ID) 44 | PLUGIN_MESAJLAR[plugin] = reply 45 | sql.ekle_mesaj(plugin, f"MEDYA_{mesaj.id}") 46 | return await event.edit(f"Plugin(`{plugin}`) {LANG['SETTED_MEDIA']}") 47 | PLUGIN_MESAJLAR[plugin] = reply.text 48 | sql.ekle_mesaj(plugin, reply.text) 49 | return await event.edit(f"Plugin(`{plugin}`) {LANG['SETTED_REPLY']}") 50 | 51 | silme = sql.sil_mesaj(plugin) 52 | if silme == True: 53 | PLUGIN_MESAJLAR[plugin] = ORJ_PLUGIN_MESAJLAR[plugin] 54 | await event.edit(LANG['SUCCESS_DELETED']) 55 | else: 56 | await event.edit(f"{LANG['ERROR_DELETED']}: `{silme}`") 57 | else: 58 | await event.edit(LANG['NOT_FOUND'] + ":`afk/alive/pm/kickme/dızcı/ban/mute/approve/disapprove/block`") 59 | elif len(plugin) < 1: 60 | await event.edit(LANG['USAGE']) 61 | elif type(mesaj) == str: 62 | if plugin in TURLER: 63 | if mesaj.isspace(): 64 | await event.edit(LANG['CANNOT_EMPTY']) 65 | return 66 | else: 67 | PLUGIN_MESAJLAR[plugin] = mesaj 68 | sql.ekle_mesaj(plugin, mesaj) 69 | await event.edit(LANG['SETTED'].format(plu=plugin, msj=mesaj)) 70 | else: 71 | await event.edit(LANG['NOT_FOUND'] + ":`afk/alive/pm/kickme/dızcı/ban/mute/approve/disapprove/block`") 72 | 73 | CmdHelp('degistir').add_command( 74 | 'değiştir', ' ', 'Değiştir, bottaki plugin-mesajlarını değiştirmenize yarar. Eğer mesaj yazmazsanız Plugin mesajını orijinal haline döndürür.', '.değiştir afk \"Şu an burda değilim... Belki hiç gelmem\"' 75 | ).add_info( 76 | '**Desteklenen Pluginler:** `afk/alive/pm/kickme/dızcı/ban/mute/approve/disapprove/block`\n**Alive Değişkenleri:** `{plugin}, {telethon}, {asena}, {python}, {username}, {fullname}, {lastname}, {id}, {mention}`\n\ 77 | **Ban/Mute Değişkenleri:** `{id}, {username}, {first_name}, {last_name}, {mention}, {date}, {count}`\n\ 78 | **AFK Değişkenleri:** `{username}, {mention}, {first_name}, {last_name}, {last_seen_seconds}, {last_seen}, {last_seen_long}`\n\ 79 | **PMpermit Değişkenler(pm, block, approve, disapprove):** `{id}, {username}, {mention}, {first_name}, {last_name}`\ 80 | **Kickme Değişkenleri:** `{title}`' 81 | ).add() -------------------------------------------------------------------------------- /userbot/modules/dil.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2020 Yusuf Usta. 2 | # 3 | # Licensed under the GPL-3.0 License; 4 | # you may not use this file except in compliance with the License. 5 | # 6 | 7 | # Asena UserBot - Yusuf Usta 8 | 9 | from userbot.cmdhelp import CmdHelp 10 | from userbot import PLUGIN_CHANNEL_ID, CMD_HELP 11 | from userbot.events import register 12 | from re import search 13 | from json import loads, JSONDecodeError 14 | from userbot.language import LANGUAGE_JSON 15 | from os import remove 16 | 17 | @register(outgoing=True, pattern="^.dil ?(.*)") 18 | @register(outgoing=True, pattern="^.lang ?(.*)") 19 | async def dil(event): 20 | global LANGUAGE_JSON 21 | 22 | komut = event.pattern_match.group(1) 23 | if search(r"y[uü]kle|install", komut): 24 | await event.edit("`Dil dosyası yükleniyor... Lütfen bekleyiniz.`") 25 | if event.is_reply: 26 | reply = await event.get_reply_message() 27 | dosya = await reply.download_media() 28 | 29 | if ((len(reply.file.name.split(".")) >= 2) and (not reply.file.name.split(".")[1] == "asenajson")): 30 | return await event.edit("`Lütfen geçerli bir` **AsenaJSON** `dosyası verin!`") 31 | 32 | try: 33 | dosya = loads(open(dosya, "r").read()) 34 | except JSONDecodeError: 35 | return await event.edit("`Lütfen geçerli bir` **AsenaJSON** `dosyası verin!`") 36 | 37 | await event.edit(f"`{dosya['LANGUAGE']}` `dili yükleniyor...`") 38 | pchannel = await event.client.get_entity(PLUGIN_CHANNEL_ID) 39 | 40 | dosya = await reply.download_media(file="./userbot/language/") 41 | dosya = loads(open(dosya, "r").read()) 42 | await reply.forward_to(pchannel) 43 | 44 | LANGUAGE_JSON = dosya 45 | await event.edit(f"✅ `{dosya['LANGUAGE']}` `dili başarıyla yüklendi!`\n\n**İşlemlerin geçerli olması için botu yeniden başlatın!**") 46 | else: 47 | await event.edit("**Lütfen bir dil dosyasına yanıt verin!**") 48 | elif search(r"bilgi|info", komut): 49 | await event.edit("`Dil dosyası bilgileri getiriliyor... Lütfen bekleyiniz.`") 50 | if event.is_reply: 51 | reply = await event.get_reply_message() 52 | if ((len(reply.file.name.split(".")) >= 1) and (not reply.file.name.split(".")[1] == "asenajson")): 53 | return await event.edit("`Lütfen geçerli bir` **AsenaJSON** `dosyası verin!`") 54 | 55 | dosya = await reply.download_media() 56 | 57 | try: 58 | dosya = loads(open(dosya, "r").read()) 59 | except JSONDecodeError: 60 | return await event.edit("`Lütfen geçerli bir` **AsenaJSON** `dosyası verin!`") 61 | 62 | await event.edit( 63 | f"**Dil: **`{dosya['LANGUAGE']}`\n" 64 | f"**Dil Kodu: **`{dosya['LANGCODE']}`\n" 65 | f"**Çevirmen: **`{dosya['AUTHOR']}`\n" 66 | 67 | f"\n\n`Dil dosyasını yüklemek için` `.dil yükle` `komutunu kullanınız.`" 68 | ) 69 | else: 70 | await event.edit("**Lütfen bir dil dosyasına yanıt verin!**") 71 | else: 72 | await event.edit( 73 | f"**Dil: **`{LANGUAGE_JSON['LANGUAGE']}`\n" 74 | f"**Dil Kodu: **`{LANGUAGE_JSON['LANGCODE']}`\n" 75 | f"**Çevirmen: **`{LANGUAGE_JSON ['AUTHOR']}`\n" 76 | 77 | f"\n\nDiğer diller için @AsenaDil kanalına bakabilirsiniz." 78 | ) 79 | 80 | CmdHelp('dil').add_command( 81 | 'dil', None, 'Yüklediğiniz dil hakkında bilgi verir.' 82 | ).add_command( 83 | 'dil bilgi', None, 'Yanıt verdiğiniz dil dosyası hakkında bilgi verir.' 84 | ).add_command( 85 | 'dil yükle', None, 'Yanıt verdiğiniz dil dosyasını yükler.' 86 | ).add() -------------------------------------------------------------------------------- /userbot/modules/durum.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2020 Yusuf Usta. 2 | # 3 | # Licensed under the GPL-3.0 License; 4 | # you may not use this file except in compliance with the License. 5 | # 6 | 7 | # Asena UserBot - Yusuf Usta 8 | 9 | from userbot import CMD_HELP, ASYNC_POOL, tgbot, SPOTIFY_DC, G_DRIVE_CLIENT_ID, lastfm, LYDIA_API_KEY, YOUTUBE_API_KEY, OPEN_WEATHER_MAP_APPID, AUTO_PP, REM_BG_API_KEY, OCR_SPACE_API_KEY, PM_AUTO_BAN, BOTLOG_CHATID, ASENA_VERSION 10 | from userbot.events import register 11 | from telethon import version 12 | from platform import python_version 13 | from userbot.cmdhelp import CmdHelp 14 | 15 | # ██████ LANGUAGE CONSTANTS ██████ # 16 | 17 | from userbot.language import get_value 18 | LANG = get_value("durum") 19 | 20 | # ████████████████████████████████ # 21 | 22 | def durum(s): 23 | if s == None: 24 | return "❌" 25 | else: 26 | if s == False: 27 | return "❌" 28 | else: 29 | return "✅" 30 | 31 | @register(outgoing=True, pattern="^.durum|^.status") 32 | async def durums(event): 33 | 34 | await event.edit(f""" 35 | **Python {LANG['VERSION']}:** `{python_version()}` 36 | **TeleThon {LANG['VERSION']}:** `{version.__version__}` 37 | **Asena {LANG['VERSION']}:** `{ASENA_VERSION}` 38 | 39 | **{LANG['PLUGIN_COUNT']}:** `{len(CMD_HELP)}` 40 | 41 | **Inline Bot:** `{durum(tgbot)}` 42 | **Spotify:** `{durum(SPOTIFY_DC)}` 43 | **GDrive:** `{durum(G_DRIVE_CLIENT_ID)}` 44 | **LastFm:** `{durum(lastfm)}` 45 | **YouTube ApiKey:** `{durum(YOUTUBE_API_KEY)}` 46 | **Lydia:** `{durum(LYDIA_API_KEY)}` 47 | **OpenWeather:** `{durum(OPEN_WEATHER_MAP_APPID)}` 48 | **AutoPP:** `{durum(AUTO_PP)}` 49 | **RemoveBG:** `{durum(REM_BG_API_KEY)}` 50 | **OcrSpace:** `{durum(OCR_SPACE_API_KEY)}` 51 | **Pm AutoBan:** `{durum(PM_AUTO_BAN)}` 52 | **BotLog:** `{durum(BOTLOG_CHATID)}` 53 | **Plugin:** `{LANG['PERMAMENT']}` 54 | 55 | **{LANG['OK']} ✅** 56 | """) 57 | 58 | CmdHelp('durum').add_command( 59 | 'durum', None, 'Eklenen Apiler ve sürümleri gösterir.' 60 | ).add() -------------------------------------------------------------------------------- /userbot/modules/ezanvakti.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2019 The Raphielscape Company LLC. 2 | # 3 | # Licensed under the Raphielscape Public License, Version 1.c (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # 6 | 7 | # Asena UserBot - Yusuf Usta 8 | 9 | # @NaytSeyd tarafından portlanmıştır. 10 | # @frknkrc44 tarafından düzenlenmiştir. 11 | 12 | import requests 13 | from userbot import CMD_HELP 14 | from userbot.events import register 15 | from bs4 import BeautifulSoup 16 | from userbot.cmdhelp import CmdHelp 17 | 18 | # ██████ LANGUAGE CONSTANTS ██████ # 19 | 20 | from userbot.language import get_value 21 | LANG = get_value("ezanvakti") 22 | 23 | # ████████████████████████████████ # 24 | 25 | 26 | @register(outgoing=True, pattern="^.ezanvakti ?(\w*)") 27 | async def ezanvakti(event): 28 | konum = event.pattern_match.group(1).lower() 29 | if not event.text.partition(konum)[2] == '': 30 | ilce = event.text.partition(konum)[2] 31 | else: 32 | ilce = None 33 | 34 | if len(konum) < 1: 35 | await event.edit(LANG['NEED_CITY']) 36 | return 37 | 38 | url = f'https://www.mynet.com/{konum}/namaz-vakitleri' 39 | if not ilce == None: 40 | url += '/' + ilce.strip() 41 | 42 | request = requests.get(url) 43 | if not request.status_code == 200: 44 | await event.edit(f"`{konum} {LANG['NOT_FOUND']}`") 45 | return 46 | 47 | bs4 = BeautifulSoup( 48 | request.text, 'lxml' 49 | ) 50 | 51 | result = bs4.find('div', {'class': 'prayer-timeline'}).find_all('div') 52 | imsak = result[0].find('span', {'class': 'time'}).get_text().strip() 53 | gunes = result[1].find('span', {'class': 'time'}).get_text().strip() 54 | ogle = result[2].find('span', {'class': 'time'}).get_text().strip() 55 | ikindi = result[3].find('span', {'class': 'time'}).get_text().strip() 56 | aksam = result[4].find('span', {'class': 'time'}).get_text().strip() 57 | yatsi = result[5].find('span', {'class': 'time'}).get_text().strip() 58 | 59 | vakitler =(f"**{LANG['DIYANET']}**\n\n" + 60 | f"📍 **{LANG['LOCATION']}: **`{konum.capitalize()}/{ilce.strip().capitalize() if not ilce == None else konum.capitalize()}`\n\n" + 61 | f"🏙 **{LANG['IMSAK']}: ** `{imsak}`\n" + 62 | f"🌅 **{LANG['GUNES']}: ** `{gunes}`\n" + 63 | f"🌇 **{LANG['OGLE']}: ** `{ogle}`\n" + 64 | f"🌆 **{LANG['IKINDI']}: ** `{ikindi}`\n" + 65 | f"🌃 **{LANG['AKSAM']}: ** `{aksam}`\n" + 66 | f"🌌 **{LANG['YATSI']}: ** `{yatsi}`\n") 67 | 68 | await event.edit(vakitler) 69 | 70 | CmdHelp('ezanvakti').add_command( 71 | 'ezanvakti', '<şehir> ', 'Belirtilen şehir için namaz vakitlerini gösterir.', 'ezanvakti ankara etimesgut' 72 | ).add() -------------------------------------------------------------------------------- /userbot/modules/galeri.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2020 Yusuf Usta. 2 | # 3 | # Licensed under the GPL-3.0 License; 4 | # you may not use this file except in compliance with the License. 5 | # 6 | 7 | # Asena UserBot - Yusuf Usta 8 | 9 | import re 10 | import asyncio 11 | 12 | from userbot import CMD_HELP, ASYNC_POOL, GALERI_SURE 13 | from userbot.events import register 14 | from userbot.main import FotoDegistir 15 | from userbot.cmdhelp import CmdHelp 16 | 17 | # ██████ LANGUAGE CONSTANTS ██████ # 18 | 19 | from userbot.language import get_value 20 | LANG = get_value("galeri") 21 | 22 | # ████████████████████████████████ # 23 | 24 | URL_REGEX = re.compile( 25 | # https://github.com/django/django/blob/stable/1.3.x/django/core/validators.py#L45 26 | r'^(?:http|ftp)s?://' # http:// or https:// 27 | r'(?:(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+(?:[A-Z]{2,6}\.?|[A-Z0-9-]{2,}\.?)|' #domain... 28 | r'localhost|' #localhost... 29 | r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})' # ...or ip 30 | r'(?::\d+)?' # optional port 31 | r'(?:/?|[/?]\S+)$', re.IGNORECASE) 32 | 33 | @register(outgoing=True, pattern="^.galeri ?(.*)") 34 | async def galeri(event): 35 | try: 36 | import userbot.modules.sql_helper.galeri_sql as sql 37 | except: 38 | await event.edit("`SQL dışı mod'ta galeri çalışmaz!`") 39 | secenek = event.pattern_match.group(1) 40 | secen = secenek.split(" ") 41 | if secen[0] == "ekle": 42 | if len(secen) > 1: 43 | URL = re.search(URL_REGEX, secen[1]) 44 | if URL != None: 45 | sql.ekle_foto(secen[1]) 46 | sql.getir_foto() 47 | await event.edit(LANG['ADDED_LIST']) 48 | else: 49 | await event.edit(LANG['INVALID_URL']) 50 | else: 51 | await event.edit(LANG['EXAMPLE']) 52 | elif secen[0] == "liste": 53 | yfoto = "" 54 | sql.getir_foto() 55 | fotolar = sql.TUM_GALERI 56 | for foto in fotolar: 57 | yfoto += f"\n▶️ ({foto.g_id}) [Fotoğraf]({foto.foto})" 58 | await event.edit(f"**{LANG['LIST']}**\n" + yfoto) 59 | elif secen[0] == "sil": 60 | if secen[1].isdigit(): 61 | silme = sql.sil_foto(secen[1]) 62 | if silme == True: 63 | await event.edit(LANG['REMOVED']) 64 | else: 65 | await event.edit(f"{LANG['REMOVED_ERROR']}: {silme}") 66 | else: 67 | await event.edit(f"**{LANG['NEED_NUMBER']}** `.galeri sil 2`") 68 | elif secen[0] == "başla": 69 | if "galeri" in ASYNC_POOL: 70 | await event.edit(LANG['WORKING']) 71 | return 72 | ASYNC_POOL.append("galeri") 73 | sql.getir_foto() 74 | await event.edit(LANG['STARTED']) 75 | if len(sql.TUM_GALERI) >= 1: 76 | while "galeri" in ASYNC_POOL: 77 | fotolar = sql.TUM_GALERI 78 | i = 0 79 | while i < len(fotolar): 80 | if not "galeri" in ASYNC_POOL: 81 | break 82 | if i == len(fotolar): 83 | i = 0 84 | await FotoDegistir(i) 85 | await asyncio.sleep(GALERI_SURE) 86 | i += 1 87 | else: 88 | await event.edit(LANG['NEED_PHOTO']) 89 | return 90 | elif secen[0] == "kapa": 91 | if "galeri" in ASYNC_POOL: 92 | ASYNC_POOL.remove("galeri") 93 | await event.edit(LANG['STOPPED']) 94 | else: 95 | event.edit(LANG['ALREADY_STOP']) 96 | return 97 | else: 98 | await event.edit(LANG['INVALID']) 99 | 100 | CmdHelp('galeri').add_command( 101 | 'galeri ekle', '', 'Galeri sırasına fotoğraf ekler', 'galeri ekle https://i.hizliresim.com/wFSVKd.jpg' 102 | ).add_command( 103 | 'galeri liste', None, 'Galeri sırasını gösterir.' 104 | ).add_command( 105 | 'galeri sil', '', 'Galeri sırasından bir resmi siler.', 'galeri sil 4' 106 | ).add() -------------------------------------------------------------------------------- /userbot/modules/hash.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2019 The Raphielscape Company LLC. 2 | # 3 | # Licensed under the Raphielscape Public License, Version 1.c (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # 6 | 7 | # Asena UserBot - Yusuf Usta 8 | 9 | 10 | """ Hash ve encode/decode çözme komutlarını içeren UserBot modülü. """ 11 | 12 | from subprocess import PIPE 13 | from subprocess import run as runapp 14 | import pybase64 15 | from userbot import CMD_HELP 16 | from userbot.events import register 17 | from userbot.cmdhelp import CmdHelp 18 | 19 | @register(outgoing=True, pattern="^.hash (.*)") 20 | async def gethash(hash_q): 21 | """ .hash komutu md5, sha1, sha256, sha512 dizelerini bulur. """ 22 | textx = await gethash.get_reply_message() 23 | hashtxt_ = gethash.pattern_match.group(1) 24 | if hashtxt_: 25 | pass 26 | elif textx: 27 | hashtxt_ = textx.text 28 | else: 29 | await gethash.edit("`Bana çevirilecek bir metin ver!`") 30 | return 31 | 32 | # hashtxt_ = hash_q.pattern_match.group(1) 33 | hashtxt = open("hashdis.txt", "w+") 34 | hashtxt.write(hashtxt_) 35 | hashtxt.close() 36 | md5 = runapp(["md5sum", "hashdis.txt"], stdout=PIPE) 37 | md5 = md5.stdout.decode() 38 | sha1 = runapp(["sha1sum", "hashdis.txt"], stdout=PIPE) 39 | sha1 = sha1.stdout.decode() 40 | sha256 = runapp(["sha256sum", "hashdis.txt"], stdout=PIPE) 41 | sha256 = sha256.stdout.decode() 42 | sha512 = runapp(["sha512sum", "hashdis.txt"], stdout=PIPE) 43 | runapp(["rm", "hashdis.txt"], stdout=PIPE) 44 | sha512 = sha512.stdout.decode() 45 | ans = ("Text: `" + hashtxt_ + "`\nMD5: `" + md5 + "`SHA1: `" + sha1 + 46 | "`SHA256: `" + sha256 + "`SHA512: `" + sha512[:-1] + "`") 47 | if len(ans) > 4096: 48 | hashfile = open("hashes.txt", "w+") 49 | hashfile.write(ans) 50 | hashfile.close() 51 | await hash_q.client.send_file( 52 | hash_q.chat_id, 53 | "hashes.txt", 54 | reply_to=hash_q.id, 55 | caption="`Çok büyük, bunun yerine bir metin dosyası gönderiliyor. `") 56 | runapp(["rm", "hashes.txt"], stdout=PIPE) 57 | else: 58 | await hash_q.reply(ans) 59 | 60 | 61 | @register(outgoing=True, pattern="^.base64 (en|de) (.*)") 62 | async def endecrypt(query): 63 | """ .base64 komutu verilen dizenin base64 kodlamasını bulur. """ 64 | if query.pattern_match.group(1) == "en": 65 | lething = str( 66 | pybase64.b64encode(bytes(query.pattern_match.group(2), 67 | "utf-8")))[2:] 68 | await query.reply("Encoded: `" + lething[:-1] + "`") 69 | else: 70 | lething = str( 71 | pybase64.b64decode(bytes(query.pattern_match.group(2), "utf-8"), 72 | validate=True))[2:] 73 | await query.reply("Decoded: `" + lething[:-1] + "`") 74 | 75 | CmdHelp('hash').add_command( 76 | 'base64', None, 'Verilen dizenin base64 kodlamasını bulun' 77 | ).add_command( 78 | 'hash', None, 'Bir txt dosyası yazıldığında md5, sha1, sha256, sha512 dizelerini bulun.' 79 | ).add() -------------------------------------------------------------------------------- /userbot/modules/liste.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2020 Yusuf Usta. 2 | # 3 | # Licensed under the GPL-3.0 License; 4 | # you may not use this file except in compliance with the License. 5 | # 6 | 7 | # Asena UserBot - Yusuf Usta 8 | 9 | from userbot import CMD_HELP 10 | from userbot.events import register 11 | from PIL import Image 12 | import io 13 | import os 14 | import asyncio 15 | from userbot.cmdhelp import CmdHelp 16 | 17 | # ██████ LANGUAGE CONSTANTS ██████ # 18 | 19 | from userbot.language import get_value 20 | LANG = get_value("liste") 21 | 22 | # ████████████████████████████████ # 23 | 24 | @register(outgoing=True, pattern="^.liste ?(gmute|gban)?") 25 | async def liste(event): 26 | liste = event.pattern_match.group(1) 27 | try: 28 | if len(liste) < 1: 29 | await event.edit(LANG['WRONG_INPUT']) 30 | return 31 | except: 32 | await event.edit(LANG['WRONG_INPUT']) 33 | return 34 | 35 | if liste == "gban": 36 | try: 37 | from userbot.modules.sql_helper.gban_sql import gbanlist 38 | except: 39 | await event.edit(LANG['NEED_SQL_MODE']) 40 | return 41 | await event.edit(LANG['GBANNED_USERS']) 42 | mesaj = "" 43 | for user in gbanlist(): 44 | mesaj += f"**ID: **`{user.sender}`\n" 45 | 46 | if len(mesaj) > 4000: 47 | await event.edit(LANG['TOO_MANY_GBANNED']) 48 | open("gban_liste.txt", "w+").write(mesaj) 49 | await event.client.send_message(event.chat_id, LANG['GBAN_TXT'], file="gban_liste.txt") 50 | os.remove("gban_liste.txt") 51 | else: 52 | await event.edit(LANG['GBAN_LIST'] % mesaj) 53 | elif liste == "gmute": 54 | try: 55 | from userbot.modules.sql_helper.gmute_sql import gmutelist 56 | except: 57 | await event.edit(LANG['NEED_SQL_MODE']) 58 | return 59 | await event.edit(LANG['GMUTE_DATA']) 60 | mesaj = "" 61 | for user in gmutelist(): 62 | mesaj += f"**ID: **`{user.sender}`\n" 63 | 64 | if len(mesaj) > 4000: 65 | await event.edit(LANG['TOO_MANY_GMUTED']) 66 | open("gmute_liste.txt", "w+").write(mesaj) 67 | await event.client.send_message(event.chat_id, LANG['GMUTE_TXT'], file="gmute_liste.txt") 68 | os.remove("gmute_liste.txt") 69 | else: 70 | await event.edit(LANG['GMUTE_LIST'] % mesaj) 71 | 72 | CmdHelp('liste').add_command( 73 | 'liste', '', 'Gbanladığınız ya da Gmutelediğiniz kişileri getirir.' 74 | ).add() -------------------------------------------------------------------------------- /userbot/modules/lydia.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2019 The Raphielscape Company LLC. 2 | # 3 | # Licensed under the Raphielscape Public License, Version 1.c (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # 6 | 7 | # Asena UserBot - Yusuf Usta 8 | 9 | # credit goes to @snapdragon and @devpatel_73 for making it work on this userbot. 10 | # 11 | 12 | from userbot.events import register 13 | from userbot import CMD_HELP 14 | from userbot import LYDIA_API_KEY 15 | import coffeehouse as cf 16 | from coffeehouse.lydia import LydiaAI 17 | from coffeehouse.api import API 18 | import asyncio 19 | import logging 20 | from userbot.cmdhelp import CmdHelp 21 | 22 | logging.basicConfig(format='[%(levelname) 5s/%(asctime)s] %(name)s: %(message)s', 23 | level=logging.WARNING) 24 | 25 | # ██████ LANGUAGE CONSTANTS ██████ # 26 | 27 | from userbot.language import get_value 28 | LANG = get_value("lydia") 29 | 30 | # ████████████████████████████████ # 31 | 32 | try: 33 | from userbot.modules.sql_helper.lydia_sql import get_s, get_all_s, add_s, remove_s 34 | except: 35 | logging.log(level=logging.WARNING, 36 | msg="Lydia veritabanı bağlantısı başarısız oldu") 37 | 38 | # SQL dışı mod 39 | ACC_LYDIA = {} 40 | 41 | if LYDIA_API_KEY: 42 | api_key = LYDIA_API_KEY 43 | api_client = API(api_key) 44 | lydia = LydiaAI(api_client) 45 | 46 | 47 | @register(outgoing=True, pattern="^.repcf$") 48 | async def repcf(event): 49 | if event.fwd_from: 50 | return 51 | await event.edit(LANG['WORKING']) 52 | try: 53 | session = lydia.create_session() 54 | reply = await event.get_reply_message() 55 | msg = reply.text 56 | text_rep = session.think_thought(msg) 57 | await event.edit(LANG['LYDIA_SAYS'].format(text_rep)) 58 | except Exception as e: 59 | await event.edit(str(e)) 60 | 61 | @register(outgoing=True, pattern="^.addcf$") 62 | async def addcf(event): 63 | if event.fwd_from: 64 | return 65 | await event.edit(LANG['SQL_OFF']) 66 | await asyncio.sleep(3) 67 | await event.edit(LANG['WORKING']) 68 | reply_msg = await event.get_reply_message() 69 | if reply_msg: 70 | session = lydia.create_session() 71 | session_id = session.id 72 | if reply_msg.from_id is None: 73 | return await event.edit(LANG['REPLY_USER_ERR']) 74 | ACC_LYDIA.update({(event.chat_id & reply_msg.from_id): session}) 75 | await event.edit(LANG['LYDIA_ACTIVATED'].format(str(reply_msg.from_id), str(event.chat_id))) 76 | else: 77 | await event.edit(LANG['REPLY_FOR_ACTIVATE']) 78 | 79 | @register(outgoing=True, pattern="^.remcf$") 80 | async def remcf(event): 81 | if event.fwd_from: 82 | return 83 | await event.edit(LANG['SQL_OFF']) 84 | await asyncio.sleep(3) 85 | await event.edit("İşleniyor...") 86 | reply_msg = await event.get_reply_message() 87 | try: 88 | del ACC_LYDIA[event.chat_id & reply_msg.from_id] 89 | await event.edit(LANG['LYDIA_DEACTIVATED'].format(str(reply_msg.from_id), str(event.chat_id))) 90 | except Exception: 91 | await event.edit(LANG['LYDIA_OFF_FOR_USER']) 92 | 93 | 94 | @register(incoming=True, disable_edited=True) 95 | async def user(event): 96 | user_text = event.text 97 | try: 98 | session = ACC_LYDIA[event.chat_id & event.from_id] 99 | msg = event.text 100 | async with event.client.action(event.chat_id, "typing"): 101 | text_rep = session.think_thought(msg) 102 | wait_time = 0 103 | for i in range(len(text_rep)): 104 | wait_time = wait_time + 0.1 105 | await asyncio.sleep(wait_time) 106 | await event.reply(text_rep) 107 | except (KeyError, TypeError): 108 | return 109 | 110 | CmdHelp('lydia').add_command( 111 | 'addcf', '', 'Lydia\'nın otomatik sohbetini etkinleştirir.' 112 | ).add_command( 113 | 'remcf', '', 'Lydia\'nın otomatik sohbetini devre dışı bırakır.' 114 | ).add_command( 115 | 'repcf', '', 'Lydia\'nın otomatik sohbetiini belli bir kişi için etkinleştirir.' 116 | ).add() -------------------------------------------------------------------------------- /userbot/modules/lyrics.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2019 The Raphielscape Company LLC. 2 | # 3 | # Licensed under the Raphielscape Public License, Version 1.c (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # 6 | 7 | # Asena UserBot - Yusuf Usta 8 | 9 | 10 | import os 11 | import lyricsgenius 12 | import asyncio 13 | 14 | from userbot.events import register 15 | from userbot import CMD_HELP, GENIUS 16 | from userbot.cmdhelp import CmdHelp 17 | 18 | # ██████ LANGUAGE CONSTANTS ██████ # 19 | 20 | from userbot.language import get_value 21 | LANG = get_value("lyrics") 22 | 23 | # ████████████████████████████████ # 24 | 25 | @register(outgoing=True, pattern="^.lyrics(?: |$)(.*)") 26 | async def lyrics(lyric): 27 | if r"-" in lyric.text: 28 | pass 29 | else: 30 | await lyric.edit(LANG['WRONG_TYPE']) 31 | return 32 | 33 | if GENIUS is None: 34 | await lyric.edit( 35 | LANG['GENIUS_NOT_FOUND']) 36 | return 37 | else: 38 | genius = lyricsgenius.Genius(GENIUS) 39 | try: 40 | args = lyric.text.split('.lyrics')[1].split('-') 41 | artist = args[0].strip(' ') 42 | song = args[1].strip(' ') 43 | except: 44 | await lyric.edit(LANG['GIVE_INFO']) 45 | return 46 | 47 | if len(args) < 1: 48 | await lyric.edit(LANG['GIVE_INFO']) 49 | return 50 | 51 | await lyric.edit(LANG['SEARCHING'].format(artist, song)) 52 | 53 | try: 54 | songs = genius.search_song(song, artist) 55 | except TypeError: 56 | songs = None 57 | 58 | if songs is None: 59 | await lyric.edit(LANG['NOT_FOUND'].format(artist, song)) 60 | return 61 | if len(songs.lyrics) > 4096: 62 | await lyric.edit(LANG['TOO_LONG']) 63 | with open("lyrics.txt", "w+") as f: 64 | f.write(f"{LANG['LYRICS']} \n{artist} - {song}\n\n{songs.lyrics}") 65 | await lyric.client.send_file( 66 | lyric.chat_id, 67 | "lyrics.txt", 68 | reply_to=lyric.id, 69 | ) 70 | os.remove("lyrics.txt") 71 | else: 72 | await lyric.edit(f"{LANG['LYRICS']} \n`{artist} - {song}`\n\n```{songs.lyrics}```") 73 | return 74 | 75 | @register(outgoing=True, pattern="^.singer(?: |$)(.*)") 76 | async def singer(lyric): 77 | if r"-" in lyric.text: 78 | pass 79 | else: 80 | await lyric.edit(LANG['WRONG_TYPE']) 81 | return 82 | 83 | if GENIUS is None: 84 | await lyric.edit( 85 | LANG['GENIUS_NOT_FOUND']) 86 | return 87 | else: 88 | genius = lyricsgenius.Genius(GENIUS) 89 | try: 90 | args = lyric.text.split('.singer')[1].split('-') 91 | artist = args[0].strip(' ') 92 | song = args[1].strip(' ') 93 | except: 94 | await lyric.edit(LANG['GIVE_INFO']) 95 | return 96 | 97 | if len(args) < 1: 98 | await lyric.edit(LANG['GIVE_INFO']) 99 | return 100 | 101 | await lyric.edit(LANG['SEARCHING'].format(artist, song)) 102 | 103 | try: 104 | songs = genius.search_song(song, artist) 105 | except TypeError: 106 | songs = None 107 | 108 | if songs is None: 109 | await lyric.edit(LANG['NOT_FOUND'].format(artist, song)) 110 | return 111 | await lyric.edit(LANG['SINGER_LYRICS'].format(artist, song)) 112 | await asyncio.sleep(1) 113 | 114 | split = songs.lyrics.splitlines() 115 | i = 0 116 | while i < len(split): 117 | try: 118 | if split[i] != None: 119 | await lyric.edit(split[i]) 120 | await asyncio.sleep(2) 121 | i += 1 122 | except: 123 | i += 1 124 | await lyric.edit(LANG['SINGER_ENDED']) 125 | 126 | return 127 | 128 | 129 | 130 | CMD_HELP.update({ 131 | "lyrics": 132 | "Kullanım: .`lyrics - <şarkı ismi>`\n" 133 | "NOT: ""-"" ayracı önemli!", 134 | "singer": 135 | "Şarkı söyler, Kullanım: .`singer - <şarkı ismi>`\n" 136 | "NOT: ""-"" ayracı önemli!" 137 | 138 | }) 139 | 140 | CmdHelp('lyrics').add_command( 141 | 'lyrics', ' - <şarkı ismi>', 'Şarkı sözlerini getirir.', 'lyrics System Of a Down - Scince' 142 | ).add_command( 143 | 'singer', ' - <şarkı ismi>', 'Şarkı söyler.', 'singer System Of a Down - Scince' 144 | ).add() -------------------------------------------------------------------------------- /userbot/modules/nekobin.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2019 The Raphielscape Company LLC. 2 | # 3 | # Licensed under the Raphielscape Public License, Version 1.c (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # 6 | 7 | # Asena UserBot - Yusuf Usta 8 | 9 | 10 | """ Nekobin ile etkileşim için komutlar içeren UserBot modülü (https://nekobin.com/) """ 11 | 12 | import os 13 | from userbot import BOTLOG, BOTLOG_CHATID, CMD_HELP, TEMP_DOWNLOAD_DIRECTORY 14 | from userbot.events import register 15 | from userbot.cmdhelp import CmdHelp 16 | import aiohttp 17 | import asyncio 18 | import json 19 | 20 | URL = "https://nekobin.com/" 21 | 22 | # ██████ LANGUAGE CONSTANTS ██████ # 23 | 24 | from userbot.language import get_value 25 | LANG = get_value("dogbin") 26 | 27 | # ████████████████████████████████ # 28 | 29 | @register(outgoing=True, pattern=r"^.paste(?: |$)([\s\S]*)") 30 | async def paste(pstl): 31 | """ .paste komutu metni doğrudan nekobine yapıştırır """ 32 | 33 | match = pstl.pattern_match.group(1).strip() 34 | reply_id = pstl.reply_to_msg_id 35 | 36 | if not match and not reply_id: 37 | await pstl.edit(LANG['ELON_SAYS']) 38 | return 39 | 40 | if match: 41 | message = match 42 | elif reply_id: 43 | message = (await pstl.get_reply_message()) 44 | if message.media: 45 | downloaded_file_name = await pstl.client.download_media( 46 | message, 47 | TEMP_DOWNLOAD_DIRECTORY, 48 | ) 49 | m_list = None 50 | with open(downloaded_file_name, "rb") as fd: 51 | m_list = fd.readlines() 52 | message = "" 53 | for m in m_list: 54 | message += m.decode("UTF-8") + "\r" 55 | os.remove(downloaded_file_name) 56 | else: 57 | message = message.message 58 | 59 | # Throwbin 60 | await pstl.edit(LANG['PASTING']) 61 | async with aiohttp.ClientSession(connector=aiohttp.TCPConnector(verify_ssl=False)) as session: 62 | async with session.get("https://open-apis-rest.up.railway.app/api/nekobin?text=" + message) as response: 63 | 64 | html = await response.text() 65 | html2 = json.loads(html) 66 | if html2["status"] == "OK": 67 | reply_text = LANG['PASTED'] + "\n\n" + LANG['URL'] + " " + html2["data"]["url"] 68 | await pstl.edit(reply_text) 69 | if BOTLOG: 70 | await pstl.client.send_message( 71 | BOTLOG_CHATID, 72 | f"Nekobine metin yapıştırma başarıyla yürütüldü", 73 | ) 74 | else: 75 | return await pstl.edit("__Sunucu ile ilgili bir sorun var. Daha sonra tekrar deneyin.__") 76 | 77 | 78 | @register(outgoing=True, pattern="^.getpaste ?(.*)") 79 | async def get_dogbin_content(event): 80 | """ .getpaste komutu Nekobin url içeriğini aktarır """ 81 | url = event.pattern_match.group(1) 82 | 83 | if "nekobin" not in url: 84 | return await event.edit(LANG["UNSUPPORTED_URL"]) 85 | 86 | await event.edit(LANG['DATA_CHECKING']) 87 | async with aiohttp.ClientSession(connector=aiohttp.TCPConnector(verify_ssl=False)) as session: 88 | async with session.get("https://open-apis-rest.up.railway.app/api/nekobinget?url=" + url) as response: 89 | 90 | html = await response.text() 91 | html2 = json.loads(html) 92 | if html2["status"] == "OK": 93 | await event.edit(LANG["DOGBIN_DATA"] + "\n\n" + html2["data"]) 94 | if BOTLOG: 95 | await event.client.send_message( 96 | BOTLOG_CHATID, 97 | LANG['DOGBIN_ENDED'], 98 | ) 99 | else: 100 | return await event.edit(LANG["DOGBIN_NOT_RESPOND"]) 101 | 102 | CmdHelp('paste').add_command( 103 | 'paste', '', 'Nekobin kullanarak yapıştırılmış veya kısaltılmış url oluşturma (https://nekobin.com)' 104 | ).add_command( 105 | 'getpaste', "nekobin url", 'Nekobin url içeriğini metne aktarır (https://nekobin.com)' 106 | ).add() -------------------------------------------------------------------------------- /userbot/modules/notes.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2019 The Raphielscape Company LLC. 2 | # 3 | # Licensed under the Raphielscape Public License, Version 1.c (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # 6 | 7 | # Asena UserBot - Yusuf Usta 8 | 9 | 10 | """ Not tutma komutlarını içeren UserBot modülüdür. """ 11 | 12 | from userbot import BOTLOG, BOTLOG_CHATID, CMD_HELP 13 | from userbot.events import register 14 | from asyncio import sleep 15 | from userbot.cmdhelp import CmdHelp 16 | 17 | # ██████ LANGUAGE CONSTANTS ██████ # 18 | 19 | from userbot.language import get_value 20 | LANG = get_value("notes") 21 | 22 | # ████████████████████████████████ # 23 | 24 | @register(outgoing=True, pattern="^.notes$") 25 | async def notes_active(svd): 26 | """ .notes komutu sohbette kaydedilmiş tüm notları listeler. """ 27 | try: 28 | from userbot.modules.sql_helper.notes_sql import get_notes 29 | except AttributeError: 30 | await svd.edit("`Bot Non-SQL modunda çalışıyor!!`") 31 | return 32 | message = LANG['NOT_FOUND'] 33 | notes = get_notes(svd.chat_id) 34 | for note in notes: 35 | if message == LANG['NOT_FOUND']: 36 | message = f"{LANG['NOTES']}:\n" 37 | message += "`#{}`\n".format(note.keyword) 38 | else: 39 | message += "`#{}`\n".format(note.keyword) 40 | await svd.edit(message) 41 | 42 | 43 | @register(outgoing=True, pattern=r"^.clear (\w*)") 44 | async def remove_notes(clr): 45 | """ .clear komutu istenilen notu siler. """ 46 | try: 47 | from userbot.modules.sql_helper.notes_sql import rm_note 48 | except AttributeError: 49 | await clr.edit("`Bot Non-SQL modunda çalışıyor!!`") 50 | return 51 | notename = clr.pattern_match.group(1) 52 | if rm_note(clr.chat_id, notename) is False: 53 | return await clr.edit(" **{}** `{}`".format(notename, LANG['CLEAR_NOT_FOUND'])) 54 | else: 55 | return await clr.edit( 56 | "**{}** `{}`".format(notename, LANG['CLEAR'])) 57 | 58 | 59 | @register(outgoing=True, pattern=r"^.save (\w*)") 60 | async def add_note(fltr): 61 | """ .save komutu bir sohbette not kaydeder. """ 62 | try: 63 | from userbot.modules.sql_helper.notes_sql import add_note 64 | except AttributeError: 65 | await fltr.edit("`Bot Non-SQL modunda çalışıyor!!`") 66 | return 67 | keyword = fltr.pattern_match.group(1) 68 | string = fltr.text.partition(keyword)[2] 69 | msg = await fltr.get_reply_message() 70 | msg_id = None 71 | if msg and msg.media and not string: 72 | if BOTLOG_CHATID: 73 | await fltr.client.send_message( 74 | BOTLOG_CHATID, f"#NOTE\ 75 | \nGrup ID: {fltr.chat_id}\ 76 | \nAnahtar kelime: {keyword}\ 77 | \n\nBu mesaj sohbette notu cevaplamak için kaydedildi, lütfen bu mesajı silmeyin!" 78 | ) 79 | msg_o = await fltr.client.forward_messages(entity=BOTLOG_CHATID, 80 | messages=msg, 81 | from_peer=fltr.chat_id, 82 | silent=True) 83 | msg_id = msg_o.id 84 | else: 85 | await fltr.edit( 86 | "`Bir medyayı not olarak kaydetmek için BOTLOG_CHATID değerinin ayarlanmış olması gereklidir.`" 87 | ) 88 | return 89 | elif fltr.reply_to_msg_id and not string: 90 | rep_msg = await fltr.get_reply_message() 91 | string = rep_msg.text 92 | success = "`{} {}. ` #{} `{}`" 93 | if add_note(str(fltr.chat_id), keyword, string, msg_id) is False: 94 | return await fltr.edit(success.format(LANG['SUCCESS'], 'güncellendi', keyword, LANG['CALL'])) 95 | else: 96 | return await fltr.edit(success.format(LANG['SUCCESS'], 'eklendi', keyword, LANG['CALL'])) 97 | 98 | 99 | @register(pattern=r"#\w*", 100 | disable_edited=True, 101 | disable_errors=True, 102 | ignore_unsafe=True) 103 | async def incom_note(getnt): 104 | """ Notların mantığı. """ 105 | try: 106 | if not (await getnt.get_sender()).bot: 107 | try: 108 | from userbot.modules.sql_helper.notes_sql import get_note 109 | except AttributeError: 110 | return 111 | notename = getnt.text[1:] 112 | note = get_note(getnt.chat_id, notename) 113 | message_id_to_reply = getnt.message.reply_to_msg_id 114 | if not message_id_to_reply: 115 | message_id_to_reply = None 116 | if note and note.f_mesg_id: 117 | msg_o = await getnt.client.get_messages(entity=BOTLOG_CHATID, 118 | ids=int( 119 | note.f_mesg_id)) 120 | await getnt.client.send_message(getnt.chat_id, 121 | msg_o.mesage, 122 | reply_to=message_id_to_reply, 123 | file=msg_o.media) 124 | elif note and note.reply: 125 | await getnt.client.send_message(getnt.chat_id, 126 | note.reply, 127 | reply_to=message_id_to_reply) 128 | except AttributeError: 129 | pass 130 | 131 | CmdHelp('notes').add_command( 132 | '#', None, 'Belirtilen notu çağırır.' 133 | ).add_command( 134 | 'save', ' ya da bir mesajı .save şeklinde yanıtlayarak kullanılır', 'Yanıtlanan mesajı ismiyle birlikte bir not olarak kaydeder. (Resimler, belgeler ve çıkartmalarda da çalışır.)' 135 | ).add_command( 136 | 'notes', None, 'Bir sohbetteki tüm notları çağırır.' 137 | ).add_command( 138 | 'clear', '', 'Belirtilen notu siler.' 139 | ).add() -------------------------------------------------------------------------------- /userbot/modules/ocr.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2019 The Raphielscape Company LLC. 2 | # 3 | # Licensed under the Raphielscape Public License, Version 1.c (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # 6 | 7 | # Asena UserBot - Yusuf Usta 8 | 9 | 10 | import os 11 | from requests import post 12 | from userbot import bot, OCR_SPACE_API_KEY, CMD_HELP, TEMP_DOWNLOAD_DIRECTORY 13 | from userbot.events import register 14 | from userbot.cmdhelp import CmdHelp 15 | 16 | # ██████ LANGUAGE CONSTANTS ██████ # 17 | 18 | from userbot.language import get_value 19 | LANG = get_value("ocr") 20 | 21 | # ████████████████████████████████ # 22 | 23 | async def ocr_space_file(filename, 24 | overlay=False, 25 | api_key=OCR_SPACE_API_KEY, 26 | language='tur'): 27 | """ OCR.space API yerel dosya ister. 28 | Python3.5 ve üzeri için - 2.7 üzerinde test edilmedi. 29 | :param filename: Dosya yolu ve adı. 30 | :param overlay: Cevabınızda OCR.space yerleşimi gerekli mi? 31 | Varsayılan olarak Hayır. 32 | :param api_key: OCR.space API key. 33 | varsayılan olarak 'merhabadünya'. 34 | :param language: OCR'de kullanılacak dil kodu. 35 | Mevcut dil kodlarının listesi burudan bulunabilir https://ocr.space/OCRAPI 36 | Varsayılan olarak 'tr'. 37 | :return: Sonuçlar JSON formatında gelir. 38 | """ 39 | 40 | payload = { 41 | 'isOverlayRequired': overlay, 42 | 'apikey': api_key, 43 | 'language': language, 44 | } 45 | with open(filename, 'rb') as f: 46 | r = post( 47 | 'https://api.ocr.space/parse/image', 48 | files={filename: f}, 49 | data=payload, 50 | ) 51 | return r.json() 52 | 53 | 54 | @register(pattern=r".ocr (.*)", outgoing=True) 55 | async def ocr(event): 56 | await event.edit(LANG['READING']) 57 | if not os.path.isdir(TEMP_DOWNLOAD_DIRECTORY): 58 | os.makedirs(TEMP_DOWNLOAD_DIRECTORY) 59 | lang_code = event.pattern_match.group(1) 60 | downloaded_file_name = await bot.download_media( 61 | await event.get_reply_message(), TEMP_DOWNLOAD_DIRECTORY) 62 | test_file = await ocr_space_file(filename=downloaded_file_name, 63 | language=lang_code) 64 | try: 65 | ParsedText = test_file["ParsedResults"][0]["ParsedText"] 66 | except BaseException: 67 | await event.edit(LANG['CANT_READ']) 68 | else: 69 | await event.edit(f"`{LANG['READ']}`\n\n{ParsedText}" 70 | ) 71 | os.remove(downloaded_file_name) 72 | 73 | CmdHelp('ocr').add_command( 74 | 'ocr', '', 'Metin ayıklamak için bir resme veya çıkartmaya cevap verin.' 75 | ).add_info( 76 | 'Dil kodlarını [buradan](https://ocr.space/ocrapi) alın.' 77 | ).add() -------------------------------------------------------------------------------- /userbot/modules/open_apis_game.py: -------------------------------------------------------------------------------- 1 | import aiohttp 2 | import asyncio 3 | import json 4 | import os 5 | import requests 6 | from userbot import CMD_HELP, bot 7 | from userbot.events import register 8 | from userbot.cmdhelp import CmdHelp 9 | # from userbot.language import get_value 10 | 11 | 12 | def download(url): 13 | response = requests.get(url) 14 | file = open("./avatar.jpg", "wb") 15 | file.write(response.content) 16 | file.close() 17 | return True 18 | 19 | @register(outgoing=True, pattern="^.game ?(.*)") 20 | async def apis(event): 21 | degerler = event.pattern_match.group(1) 22 | 23 | try: 24 | txt = degerler.split() 25 | game_old = txt[0] 26 | game = degerler 27 | except IndexError: 28 | return await event.edit("**Eksik Paramatreler!**\n\n**Örnek:** `game genshin`") 29 | 30 | await event.edit("__" + game + " Adlı oyunun sistem gereksinimleri toplanıyor..__") 31 | async with aiohttp.ClientSession(connector=aiohttp.TCPConnector(verify_ssl=False)) as session: 32 | async with session.get('https://open-apis-rest.up.railway.app/api/game_specs?game=' + game) as response: 33 | 34 | html = await response.text() 35 | html2 = json.loads(html) 36 | if html2["status"] == "OK": 37 | 38 | name = html2["data"]["game"]["name"] 39 | release_date = html2["data"]["game"]["release_date"] 40 | genre = html2["data"]["game"]["genre"] 41 | dev = html2["data"]["game"]["developer"] 42 | owner = html2["data"]["game"]["publisher"] 43 | avatar = html2["data"]["game"]["avatar"] 44 | 45 | sy_min_cpu = html2["data"]["system_requirements"]["minimum"]["cpu"] 46 | sy_min_gpu = html2["data"]["system_requirements"]["minimum"]["gpu"] 47 | sy_min_ram = html2["data"]["system_requirements"]["minimum"]["ram"] 48 | sy_min_hdd = html2["data"]["system_requirements"]["minimum"]["hdd"] 49 | sy_min_drx = html2["data"]["system_requirements"]["minimum"]["directx"] 50 | sy_min_os = html2["data"]["system_requirements"]["minimum"]["os"] 51 | 52 | sy_rc_cpu = html2["data"]["system_requirements"]["recommended"]["cpu"] 53 | sy_rc_gpu = html2["data"]["system_requirements"]["recommended"]["gpu"] 54 | sy_rc_ram = html2["data"]["system_requirements"]["recommended"]["ram"] 55 | sy_rc_hdd = html2["data"]["system_requirements"]["recommended"]["hdd"] 56 | sy_rc_drx = html2["data"]["system_requirements"]["recommended"]["directx"] 57 | sy_rc_os = html2["data"]["system_requirements"]["recommended"]["os"] 58 | 59 | popularity = html2["data"]["reviews"]["popularity"] 60 | graphics = html2["data"]["reviews"]["graphics"] 61 | design = html2["data"]["reviews"]["design"] 62 | gameplay = html2["data"]["reviews"]["gameplay"] 63 | sound = html2["data"]["reviews"]["sound"] 64 | music = html2["data"]["reviews"]["music"] 65 | innovations = html2["data"]["reviews"]["innovations"] 66 | overall = html2["data"]["reviews"]["overall"] 67 | 68 | download(avatar) 69 | await event.client.send_file( 70 | event.chat_id, './avatar.png', 71 | caption="__Oyun:__ " + name + 72 | "\n__Yayın Tarihi:__ " + release_date + 73 | "\n__Tür:__ " + genre + 74 | "\n__Geliştirici:__ " + dev + 75 | "\n__Sahip Firma:__ " + owner + 76 | "\n\n**Minimum Sistem Gereksinimleri:**" + 77 | "\n__CPU:__ " + sy_min_cpu + 78 | "\n__GPU:__ " + sy_min_gpu + 79 | "\n__RAM:__ " + sy_min_ram + 80 | "\n__HDD:__ " + sy_min_hdd + 81 | "\n__DirectX:__ " + sy_min_drx + 82 | "\n__OS:__ " + sy_min_os + 83 | "\n\n**Önerilen Sistem Gereksinimleri:**" + 84 | "\n__CPU:__ " + sy_rc_cpu + 85 | "\n__GPU:__ " + sy_rc_gpu + 86 | "\n__RAM:__ " + sy_rc_ram + 87 | "\n__HDD:__ " + sy_rc_hdd + 88 | "\n__DirectX:__ " + sy_rc_drx + 89 | "\n__OS:__ " + sy_rc_os + 90 | "\n\n**İncelemeler:**" + 91 | "\n__Popülerite:__ " + popularity + 92 | "\n__Grafik:__ " + graphics + 93 | "\n__Dizayn:__ " + design + 94 | "\n__Oynanış:__ " + gameplay + 95 | "\n__Ses:__ " + sound + 96 | "\n__Müzik:__ " + music + 97 | "\n__Yenilik:__ " + innovations + 98 | "\n__Genel:__ " + overall 99 | ) 100 | os.remove("./avatar.png") 101 | await event.delete() 102 | else: 103 | return await event.edit("__" + game + " Adında bir oyun bulunamadı.__") 104 | 105 | Help = CmdHelp('game') 106 | Help.add_command('game', 107 | '', 108 | 'Oyunun Sistem Gereksinimlerini Gösterir.', 109 | 'game genshin' 110 | ) 111 | Help.add_info("@phaticusthiccy tarafından yapılmıştır.") 112 | Help.add() 113 | -------------------------------------------------------------------------------- /userbot/modules/open_apis_similarity.py: -------------------------------------------------------------------------------- 1 | import aiohttp 2 | import asyncio 3 | import json 4 | import os 5 | from userbot import CMD_HELP, bot 6 | from userbot.events import register 7 | from userbot.cmdhelp import CmdHelp 8 | # from userbot.language import get_value 9 | 10 | 11 | @register(outgoing=True, pattern="^.benzerlik ?(.*)") 12 | async def apis(event): 13 | degerler = event.pattern_match.group(1) 14 | 15 | try: 16 | txt = degerler.split("&&") 17 | if txt[1].startswith(" "): 18 | txt[1] = txt[1].replace(" ", "", 1) 19 | 20 | if len(txt) != 2: 21 | return await event.edit("**Girilen Cümlede 2 Adet** `&&` **Sembolü Bulundu. Lütfen** `.asena benzerlik` **Yazıp Kullanımına Göz Atın.**") 22 | 23 | f1 = txt[0] 24 | f2 = txt[1] 25 | except IndexError: 26 | return await event.edit("**Eksik Paramatreler!**\n\n**Örnek:** `benzerlik cümle1 && cümle2`") 27 | 28 | async with aiohttp.ClientSession(connector=aiohttp.TCPConnector(verify_ssl=False)) as session: 29 | async with session.get('https://open-apis-rest.up.railway.app/api/similarity?text1=' + f1 + '&text2=' + f2) as response: 30 | 31 | html = await response.text() 32 | html2 = json.loads(html) 33 | if html2["status"] == "OK": 34 | sim = html2["data"]["similarity_percentage"] 35 | vurgu = html2["data"]["emphasis"]["emphasis"] 36 | sonuc = "**1. Cümle:** `" + txt[0] + "`" + "\n" + "**2. Cümle:** `" + txt[1] + "`" + "\n\n" + \ 37 | "**Benzerlik Oranı:** " + "`" + sim + "`" + \ 38 | "\n" + "**Vurgulanan Kelime:** `" + vurgu + "`" 39 | return await event.edit(sonuc) 40 | 41 | else: 42 | return await event.edit("__API İle İlgili Bir Sorun Var. Lütfen Destek Ekibine Bildirin.__") 43 | 44 | Help = CmdHelp('benzerlik') 45 | Help.add_command('benzerlik', 46 | '<1. Cümle> && <2. Cümle>', 47 | '2 Cümlenin Anlam Bakımından Ne Kadar Benzediğini Gösterir. (Yapay Zeka)', 48 | 'benzerlik Asena harika bir araç! && Asena kullanmak iyi bir seçenek!' 49 | ) 50 | Help.add_info("@phaticusthiccy tarafından yapılmıştır.") 51 | Help.add() 52 | -------------------------------------------------------------------------------- /userbot/modules/open_apis_textpro.py: -------------------------------------------------------------------------------- 1 | import aiohttp 2 | import asyncio 3 | import json 4 | import os 5 | import requests 6 | from userbot import CMD_HELP, bot 7 | from userbot.events import register 8 | from userbot.cmdhelp import CmdHelp 9 | # from userbot.language import get_value 10 | 11 | def download(url): 12 | response = requests.get(url) 13 | file = open("./tp.png", "wb") 14 | file.write(response.content) 15 | file.close() 16 | return True 17 | 18 | @register(outgoing=True, pattern="^.textpro ?(.*)") 19 | async def apis(event): 20 | degerler = event.pattern_match.group(1) 21 | 22 | try: 23 | txt = degerler.split() 24 | model = txt[0] 25 | text = degerler.replace(model, "") 26 | 27 | except IndexError: 28 | return await event.edit("**Eksik Paramatreler!**\n\n**Örnek:** `textpro neon Asena`\n\n__Stiller:__ `neon`, `neon2`, `devil`, `batman`, `led`, `yıldırım`, `bp`, `yaprak`, `ask`, `ask2`, `afis`, `glitch`") 29 | 30 | url = "" 31 | 32 | if model == "neon": 33 | url = "https://textpro.me/create-glowing-neon-light-text-effect-online-free-1061.html" 34 | elif model == "neon2": 35 | url = "https://textpro.me/neon-text-effect-online-963.html" 36 | elif model == "devil": 37 | url = "https://textpro.me/create-neon-devil-wings-text-effect-online-free-1014.html" 38 | elif model == "batman": 39 | url = "https://textpro.me/make-a-batman-logo-online-free-1066.html" 40 | elif model == "led": 41 | url = "https://textpro.me/color-led-display-screen-text-effect-1059.html" 42 | elif model == "yıldırım": 43 | url = "https://textpro.me/online-thunder-text-effect-generator-1031.html" 44 | elif model == "bp": 45 | url = "https://textpro.me/create-blackpink-logo-style-online-1001.html" 46 | elif model == "yaprak": 47 | url = "https://textpro.me/natural-leaves-text-effect-931.html" 48 | elif model == "ask": 49 | url = "https://textpro.me/free-advanced-glow-text-effect-873.html" 50 | elif model == "ask2": 51 | url = "https://textpro.me/create-neon-light-on-brick-wall-online-1062.html" 52 | elif model == "afis": 53 | url = "https://textpro.me/create-light-glow-sliced-text-effect-online-1068.html" 54 | elif model == "glitch": 55 | url = "https://textpro.me/create-impressive-glitch-text-effects-online-1027.html" 56 | 57 | else: 58 | return await event.edit("**Yanlış Paramatre!**\n\n**Örnek:** `textpro neon Asena`\n\n__Stiller:__ `neon`, `neon2`, `devil`, `batman`, `led`, `yıldırım`, `bp`, `yaprak`, `ask`, `ask2`, `afis`, `glitch`") 59 | 60 | await event.edit("__Fotoğraf Oluşturuluyor..__") 61 | async with aiohttp.ClientSession(connector=aiohttp.TCPConnector(verify_ssl=False)) as session: 62 | async with session.get('https://open-apis-rest.up.railway.app/api/textpro?url=' + url + '&text1=' + text) as response: 63 | 64 | html = await response.text() 65 | html2 = json.loads(html) 66 | if html2["status"] == "OK": 67 | img = html2["data"] 68 | download(img) 69 | await event.client.send_file(event.chat_id, './tp.png', caption="@AsenaUserBot ile Yüklendi.") 70 | os.remove("./tp.png") 71 | await event.delete() 72 | return True 73 | else: 74 | return await event.edit("Sunucu ile ilgili bir sorun var. Lütfen bunu destek ekibine bildirin.") 75 | 76 | Help = CmdHelp('textpro') 77 | Help.add_command('textpro', 78 | ' ', 79 | 'Farklı Stillerde Görseller Üretir. (Tüm stilleri görmek için boş bırakın)', 80 | 'textpro devil phaticusthiccy' 81 | ) 82 | Help.add_info("@phaticusthiccy tarafından yapılmıştır.") 83 | Help.add() 84 | -------------------------------------------------------------------------------- /userbot/modules/open_apis_tiktok.py: -------------------------------------------------------------------------------- 1 | import aiohttp 2 | import requests 3 | import asyncio 4 | import json 5 | import os 6 | from userbot import CMD_HELP, bot 7 | from userbot.events import register 8 | from userbot.cmdhelp import CmdHelp 9 | # from userbot.language import get_value 10 | 11 | 12 | @register(outgoing=True, pattern="^.tiktok ?(.*)") 13 | async def apis(event): 14 | degerler = event.pattern_match.group(1) 15 | 16 | try: 17 | txt = degerler.split() 18 | url = txt[0] 19 | except IndexError: 20 | return await event.edit("**Lütfen Bir Tiktok Bağlantısı Girin!**") 21 | 22 | await event.edit("__Video İndiriliyor..__") 23 | async with aiohttp.ClientSession(connector=aiohttp.TCPConnector(verify_ssl=False)) as session: 24 | async with session.get('https://open-apis-rest.up.railway.app/api/tiktok?url=' + url) as response: 25 | 26 | html = await response.text() 27 | html2 = json.loads(html) 28 | if html2["status"] == "OK": 29 | vid = html2["data"]["server1"]["video"] 30 | resp = requests.get(vid) 31 | with open("./tt.mp4", "wb") as f: 32 | f.write(resp.content) 33 | 34 | await event.client.send_file(event.chat_id, './tt.mp4', caption="@AsenaUserBot ile Yüklendi.") 35 | os.remove("./tt.mp4") 36 | await event.delete() 37 | return True 38 | else: 39 | return await event.edit("Lütfen Bağlantınızı Kontrol Edin. Sorun hala devam ediyorsa destek ekibine ulaşın.") 40 | 41 | Help = CmdHelp('tiktok') 42 | Help.add_command('tiktok', 43 | '', 44 | 'Tiktok üzerinden video indirir.', 45 | 'tiktok https://vm.tiktok.com/ZSeKGPhsV' 46 | ) 47 | Help.add_info("@phaticusthiccy tarafından yapılmıştır.") 48 | Help.add() 49 | -------------------------------------------------------------------------------- /userbot/modules/purge.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2019 The Raphielscape Company LLC. 2 | # 3 | # Licensed under the Raphielscape Public License, Version 1.c (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # 6 | 7 | # Asena UserBot - Yusuf Usta 8 | 9 | 10 | """ Gereksiz mesajları temizlemek için UserBot modülü (genellikle spam veya ot). """ 11 | 12 | from asyncio import sleep 13 | 14 | from telethon.errors import rpcbaseerrors 15 | 16 | from userbot import BOTLOG, BOTLOG_CHATID, CMD_HELP 17 | from userbot.events import register 18 | from userbot.cmdhelp import CmdHelp 19 | 20 | # ██████ LANGUAGE CONSTANTS ██████ # 21 | 22 | from userbot.language import get_value 23 | LANG = get_value("purge") 24 | 25 | # ████████████████████████████████ # 26 | 27 | @register(outgoing=True, pattern="^.purge$") 28 | async def fastpurger(purg): 29 | """ .purge komutu hedeflenen yanıttan başlayarak tüm mesajları temizler. """ 30 | chat = await purg.get_input_chat() 31 | msgs = [] 32 | itermsg = purg.client.iter_messages(chat, min_id=purg.reply_to_msg_id) 33 | count = 0 34 | 35 | if purg.reply_to_msg_id is not None: 36 | async for msg in itermsg: 37 | msgs.append(msg) 38 | count = count + 1 39 | msgs.append(purg.reply_to_msg_id) 40 | if len(msgs) == 100: 41 | await purg.client.delete_messages(chat, msgs) 42 | msgs = [] 43 | else: 44 | await purg.edit(LANG['NEED_MSG']) 45 | return 46 | 47 | if msgs: 48 | await purg.client.delete_messages(chat, msgs) 49 | done = await purg.client.send_message( 50 | purg.chat_id, LANG['PURGED'].format(str(count))) 51 | 52 | if BOTLOG: 53 | await purg.client.send_message( 54 | BOTLOG_CHATID, 55 | "Hedeflenen " + str(count) + " mesaj başarıyla silindi.") 56 | await sleep(2) 57 | await done.delete() 58 | 59 | 60 | @register(outgoing=True, pattern="^.purgeme") 61 | async def purgeme(delme): 62 | """ .purgeme komutu belirtilen miktarda kullanıcın mesajlarını siler. """ 63 | message = delme.text 64 | count = int(message[9:]) 65 | i = 1 66 | 67 | async for message in delme.client.iter_messages(delme.chat_id, 68 | from_user='me'): 69 | if i > count + 1: 70 | break 71 | i = i + 1 72 | await message.delete() 73 | 74 | smsg = await delme.client.send_message( 75 | delme.chat_id, 76 | LANG['PURGED_ME'].format(str(count)) 77 | ) 78 | if BOTLOG: 79 | await delme.client.send_message( 80 | BOTLOG_CHATID, 81 | "Hedeflenen " + str(count) + " mesaj başarıyla silindi.") 82 | await sleep(2) 83 | i = 1 84 | await smsg.delete() 85 | 86 | 87 | @register(outgoing=True, pattern="^.del$") 88 | async def delete_it(delme): 89 | """ .del komutu yanıtlanan mesajı siler. """ 90 | msg_src = await delme.get_reply_message() 91 | if delme.reply_to_msg_id: 92 | try: 93 | await msg_src.delete() 94 | await delme.delete() 95 | if BOTLOG: 96 | await delme.client.send_message( 97 | BOTLOG_CHATID, "Hedeflenen mesajın silinmesi başarılıyla tamamlandı") 98 | except rpcbaseerrors.BadRequestError: 99 | if BOTLOG: 100 | await delme.client.send_message( 101 | BOTLOG_CHATID, "Bu mesajı silemiyorum.") 102 | 103 | 104 | @register(outgoing=True, pattern="^.edit") 105 | async def editer(edit): 106 | """ .editme komutu son mesajınızı düzenler. """ 107 | message = edit.text 108 | chat = await edit.get_input_chat() 109 | self_id = await edit.client.get_peer_id('me') 110 | string = str(message[6:]) 111 | i = 1 112 | async for message in edit.client.iter_messages(chat, self_id): 113 | if i == 2: 114 | await message.edit(string) 115 | await edit.delete() 116 | break 117 | i = i + 1 118 | if BOTLOG: 119 | await edit.client.send_message(BOTLOG_CHATID, 120 | "Mesaj düzenleme sorgusu başarıyla yürütüldü") 121 | 122 | 123 | @register(outgoing=True, pattern="^.sd") 124 | async def selfdestruct(destroy): 125 | """ .sd komutu kendi kendine yok edilebilir mesajlar yapar. """ 126 | message = destroy.text 127 | counter = int(message[4:6]) 128 | text = str(destroy.text[6:]) 129 | await destroy.delete() 130 | smsg = await destroy.client.send_message(destroy.chat_id, text) 131 | await sleep(counter) 132 | await smsg.delete() 133 | if BOTLOG: 134 | await destroy.client.send_message(BOTLOG_CHATID, 135 | "sd sorgusu başarıyla tamamlandı") 136 | 137 | CmdHelp('purge').add_command( 138 | 'purge', None, 'Hedeflenen yanıttan başlayarak tüm mesajları temizler.' 139 | ).add_command( 140 | 'purgeme', '', 'Hedeflenen yanıttan başlayarak kendi mesajlarınızı temizler.' 141 | ).add_command( 142 | 'del', '', 'Yanıt verilen mesajı siler.' 143 | ).add_command( 144 | 'edit', '', 'Yanıt verdiğiniz mesajı yeni mesaj ile değiştirir.' 145 | ).add_command( 146 | 'sd', ' ', 'x saniye içinde kendini yok eden bir mesaj oluşturur.' 147 | ).add() -------------------------------------------------------------------------------- /userbot/modules/qrcode.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2019 The Raphielscape Company LLC. 2 | # 3 | # Licensed under the Raphielscape Public License, Version 1.c (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # 6 | 7 | # Asena UserBot - Yusuf Usta 8 | 9 | 10 | """ QR kodları ile ilgili komutları içeren UserBot modülü. """ 11 | 12 | import os 13 | import qrcode 14 | import barcode 15 | from barcode.writer import ImageWriter 16 | from urllib3 import PoolManager 17 | from bs4 import BeautifulSoup 18 | from userbot import CMD_HELP 19 | from userbot.events import register 20 | from userbot.cmdhelp import CmdHelp 21 | 22 | # ██████ LANGUAGE CONSTANTS ██████ # 23 | 24 | from userbot.language import get_value 25 | LANG = get_value("qrcode") 26 | 27 | # ████████████████████████████████ # 28 | 29 | @register(pattern=r"^.decode$", outgoing=True) 30 | async def parseqr(qr_e): 31 | """ .decode komutu cevap verilen fotoğraftan QR kodu / Barkod içeriğini alır """ 32 | downloaded_file_name = await qr_e.client.download_media( 33 | await qr_e.get_reply_message()) 34 | 35 | # QR kodunu çözmek için resmi ZXing web sayfasını ayrıştır 36 | files = {'f': open(downloaded_file_name, 'rb').read()} 37 | t_response = None 38 | 39 | try: 40 | http = PoolManager() 41 | t_response = http.request( 42 | 'POST', "https://zxing.org/w/decode", fields=files) 43 | t_response = t_response.data 44 | http.clear() 45 | except: 46 | pass 47 | 48 | os.remove(downloaded_file_name) 49 | if not t_response: 50 | await qr_e.edit(LANG['ERROR']) 51 | return 52 | soup = BeautifulSoup(t_response, "html.parser") 53 | qr_contents = soup.find_all("pre")[0].text 54 | await qr_e.edit(qr_contents) 55 | 56 | 57 | @register(pattern=r".barcode(?: |$)([\s\S]*)", outgoing=True) 58 | async def barcode_read(event): 59 | """ .barcode komutu verilen içeriği içeren bir barkod oluşturur. """ 60 | await event.edit(LANG['TRYING']) 61 | input_str = event.pattern_match.group(1) 62 | message = f"{LANG['USAGE']} `.barcode <{LANG['TEXT']}>`" 63 | reply_msg_id = event.message.id 64 | if input_str: 65 | message = input_str 66 | elif event.reply_to_msg_id: 67 | previous_message = await event.get_reply_message() 68 | reply_msg_id = previous_message.id 69 | if previous_message.media: 70 | downloaded_file_name = await event.client.download_media( 71 | previous_message) 72 | m_list = None 73 | with open(downloaded_file_name, "rb") as fd: 74 | m_list = fd.readlines() 75 | message = "" 76 | for m in m_list: 77 | message += m.decode("UTF-8") + "\r\n" 78 | os.remove(downloaded_file_name) 79 | else: 80 | message = previous_message.message 81 | else: 82 | event.edit("SÖZDİZİMİ: `.barcode `") 83 | return 84 | 85 | bar_code_type = "code128" 86 | try: 87 | bar_code_mode_f = barcode.get(bar_code_type, 88 | message, 89 | writer=ImageWriter()) 90 | filename = bar_code_mode_f.save(bar_code_type) 91 | await event.client.send_file(event.chat_id, 92 | filename, 93 | reply_to=reply_msg_id) 94 | os.remove(filename) 95 | except Exception as e: 96 | await event.edit("Lütfen `.barcode www.google.com` şeklinde(internet sitesi) kullanın. Herhangi bir mesajı barkod yapmak için `.makeqr` komutunu kullanabilirsiniz.") 97 | print(str(e)) 98 | return 99 | await event.delete() 100 | 101 | 102 | @register(pattern=r".makeqr(?: |$)([\s\S]*)", outgoing=True) 103 | async def make_qr(makeqr): 104 | """ .makeqr komutu verilen içeriği içeren bir QR kodu yapar. """ 105 | input_str = makeqr.pattern_match.group(1) 106 | message = f"{LANG['USAGE']}: `.makeqr <{LANG['TEXT']}>`" 107 | reply_msg_id = None 108 | if input_str: 109 | message = input_str 110 | elif makeqr.reply_to_msg_id: 111 | previous_message = await makeqr.get_reply_message() 112 | reply_msg_id = previous_message.id 113 | if previous_message.media: 114 | downloaded_file_name = await makeqr.client.download_media( 115 | previous_message) 116 | m_list = None 117 | with open(downloaded_file_name, "rb") as file: 118 | m_list = file.readlines() 119 | message = "" 120 | for media in m_list: 121 | message += media.decode("UTF-8") + "\r\n" 122 | os.remove(downloaded_file_name) 123 | else: 124 | message = previous_message.message 125 | 126 | qr = qrcode.QRCode( 127 | version=1, 128 | error_correction=qrcode.constants.ERROR_CORRECT_L, 129 | box_size=10, 130 | border=4, 131 | ) 132 | qr.add_data(message) 133 | qr.make(fit=True) 134 | img = qr.make_image(fill_color="black", back_color="white") 135 | img.save("img_file.webp", "PNG") 136 | await makeqr.client.send_file(makeqr.chat_id, 137 | "img_file.webp", 138 | reply_to=reply_msg_id) 139 | os.remove("img_file.webp") 140 | await makeqr.delete() 141 | 142 | CmdHelp('qrcode').add_command( 143 | 'barcode', '', 'Verilen içerikten bir barkod yapın.', 'barcode www.google.com' 144 | ).add_command( 145 | 'decode', '', 'Barkod veya QRCode çözmek için.' 146 | ).add_command( 147 | 'makeqr', '', 'Verilen içerikten bir QR kodu yapın.', 'makeqr www.google.com' 148 | ).add() -------------------------------------------------------------------------------- /userbot/modules/remove_bg.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2019 The Raphielscape Company LLC. 2 | # 3 | # Licensed under the Raphielscape Public License, Version 1.c (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # 6 | 7 | # Asena UserBot - Yusuf Usta 8 | 9 | # Prakasaka tarafından portlanmıştır. 10 | # 11 | 12 | import io 13 | import os 14 | import requests 15 | from userbot.events import register 16 | from telethon.tl.types import MessageMediaPhoto 17 | from userbot import CMD_HELP, REM_BG_API_KEY, TEMP_DOWNLOAD_DIRECTORY 18 | from userbot.cmdhelp import CmdHelp 19 | 20 | # ██████ LANGUAGE CONSTANTS ██████ # 21 | 22 | from userbot.language import get_value 23 | LANG = get_value("remove_bg") 24 | 25 | # ████████████████████████████████ # 26 | 27 | @register(outgoing=True, pattern="^.rbg(?: |$)(.*)") 28 | async def kbg(remob): 29 | """ .rbg komutu ile görüntünün arka planını kaldırın """ 30 | if REM_BG_API_KEY is None: 31 | await remob.edit( 32 | LANG['NEED_API_KEY'] 33 | ) 34 | return 35 | input_str = remob.pattern_match.group(1) 36 | message_id = remob.message.id 37 | if remob.reply_to_msg_id: 38 | message_id = remob.reply_to_msg_id 39 | reply_message = await remob.get_reply_message() 40 | await remob.edit(LANG['TRYING']) 41 | try: 42 | if isinstance( 43 | reply_message.media, MessageMediaPhoto 44 | ) or "image" in reply_message.media.document.mime_type.split('/'): 45 | downloaded_file_name = await remob.client.download_media( 46 | reply_message, TEMP_DOWNLOAD_DIRECTORY) 47 | await remob.edit(LANG['RBG']) 48 | output_file_name = await ReTrieveFile(downloaded_file_name) 49 | os.remove(downloaded_file_name) 50 | else: 51 | await remob.edit(LANG['CANT_RBG']) 52 | except Exception as e: 53 | await remob.edit(str(e)) 54 | return 55 | elif input_str: 56 | await remob.edit( 57 | f"`{LANG['ONLINE_RBG']}`\n{input_str}") 58 | output_file_name = await ReTrieveURL(input_str) 59 | else: 60 | await remob.edit(LANG['NEED']) 61 | return 62 | contentType = output_file_name.headers.get("content-type") 63 | if "image" in contentType: 64 | with io.BytesIO(output_file_name.content) as remove_bg_image: 65 | remove_bg_image.name = "removed_bg.png" 66 | await remob.client.send_file( 67 | remob.chat_id, 68 | remove_bg_image, 69 | caption=LANG['CAPTION'], 70 | force_document=True, 71 | reply_to=message_id) 72 | await remob.delete() 73 | else: 74 | await remob.edit("**Hata {}**\n`{}`".format(LANG['ERROR'], 75 | output_file_name.content.decode("UTF-8"))) 76 | 77 | 78 | async def ReTrieveFile(input_file_name): 79 | headers = { 80 | "X-API-Key": REM_BG_API_KEY, 81 | } 82 | files = { 83 | "image_file": (input_file_name, open(input_file_name, "rb")), 84 | } 85 | r = requests.post("https://api.remove.bg/v1.0/removebg", 86 | headers=headers, 87 | files=files, 88 | allow_redirects=True, 89 | stream=True) 90 | return r 91 | 92 | 93 | async def ReTrieveURL(input_url): 94 | headers = { 95 | "X-API-Key": REM_BG_API_KEY, 96 | } 97 | data = {"image_url": input_url} 98 | r = requests.post("https://api.remove.bg/v1.0/removebg", 99 | headers=headers, 100 | data=data, 101 | allow_redirects=True, 102 | stream=True) 103 | return r 104 | 105 | CmdHelp('rgb').add_command( 106 | 'rbg', '', 'remove.bg API kullanarak görüntülerin arka planını kaldırır.' 107 | ).add() -------------------------------------------------------------------------------- /userbot/modules/reverse.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2019 The Raphielscape Company LLC. 2 | # 3 | # Licensed under the Raphielscape Public License, Version 1.c (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # 6 | 7 | # Asena UserBot - Yusuf Usta 8 | 9 | # Teşekkürler @kandnub 10 | # 11 | 12 | """ Google'da görsel aramak için kullanılabilen UserBot modülü """ 13 | 14 | import io 15 | import os 16 | import urllib 17 | import requests 18 | from bs4 import BeautifulSoup 19 | import re 20 | from PIL import Image 21 | 22 | from userbot import bot, CMD_HELP 23 | from userbot.events import register 24 | from userbot.cmdhelp import CmdHelp 25 | 26 | # ██████ LANGUAGE CONSTANTS ██████ # 27 | 28 | from userbot.language import get_value 29 | LANG = get_value("reverse") 30 | 31 | # ████████████████████████████████ # 32 | 33 | opener = urllib.request.build_opener() 34 | useragent = 'Mozilla/5.0 (Linux; Android 9; SM-G960F Build/PPR1.180610.011; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/78.0.3904.70 Mobile Safari/537.36' 35 | opener.addheaders = [('User-agent', useragent)] 36 | 37 | 38 | @register(outgoing=True, pattern=r"^.reverse(?: |$)(\d*)") 39 | async def okgoogle(img): 40 | """ .reverse komutu Google'da görsel araması yapar """ 41 | if os.path.isfile("okgoogle.png"): 42 | os.remove("okgoogle.png") 43 | 44 | message = await img.get_reply_message() 45 | if message and message.media: 46 | photo = io.BytesIO() 47 | await bot.download_media(message, photo) 48 | else: 49 | await img.edit(LANG['NEED_REPLY']) 50 | return 51 | 52 | if photo: 53 | await img.edit(LANG['TRYING']) 54 | try: 55 | image = Image.open(photo) 56 | except OSError: 57 | await img.edit(LANG['INVALID_TYPE']) 58 | return 59 | name = "okgoogle.png" 60 | image.save(name, "PNG") 61 | image.close() 62 | # https://stackoverflow.com/questions/23270175/google-reverse-image-search-using-post-request#28792943 63 | searchUrl = 'https://www.google.com/searchbyimage/upload' 64 | multipart = { 65 | 'encoded_image': (name, open(name, 'rb')), 66 | 'image_content': '' 67 | } 68 | response = requests.post(searchUrl, 69 | files=multipart, 70 | allow_redirects=False) 71 | fetchUrl = response.headers['Location'] 72 | 73 | if response != 400: 74 | await img.edit(LANG['UPLOADED_TO_GOOGLE']) 75 | else: 76 | await img.edit(LANG['FUCKOFF']) 77 | return 78 | 79 | os.remove(name) 80 | match = await ParseSauce(fetchUrl + 81 | "&preferences?hl=en&fg=1#languages") 82 | guess = match['best_guess'] 83 | imgspage = match['similar_images'] 84 | 85 | if guess and imgspage: 86 | await img.edit(f"[{guess}]({fetchUrl})\n\n`{LANG['SEARCHING_PHOTO']}...`") 87 | else: 88 | await img.edit(LANG['NOT_FOUND']) 89 | return 90 | 91 | if img.pattern_match.group(1): 92 | lim = img.pattern_match.group(1) 93 | else: 94 | lim = 3 95 | images = await scam(match, lim) 96 | yeet = [] 97 | for i in images: 98 | k = requests.get(i) 99 | yeet.append(k.content) 100 | try: 101 | await img.client.send_file(entity=await 102 | img.client.get_input_entity(img.chat_id 103 | ), 104 | file=yeet, 105 | reply_to=img) 106 | except TypeError: 107 | pass 108 | await img.edit( 109 | f"[{guess}]({fetchUrl})\n\n[{LANG['NOT_FOUND']}]({imgspage})") 110 | 111 | 112 | async def ParseSauce(googleurl): 113 | """ İstediğiniz bilgi için HTML kodunu ayrıştırın / kazıyın. """ 114 | 115 | source = opener.open(googleurl).read() 116 | soup = BeautifulSoup(source, 'html.parser') 117 | 118 | results = {'similar_images': '', 'best_guess': ''} 119 | 120 | try: 121 | for similar_image in soup.findAll('input', {'class': 'gLFyf'}): 122 | url = 'https://www.google.com/search?tbm=isch&q=' + \ 123 | urllib.parse.quote_plus(similar_image.get('value')) 124 | results['similar_images'] = url 125 | except BaseException: 126 | pass 127 | 128 | for best_guess in soup.findAll('div', attrs={'class': 'r5a77d'}): 129 | results['best_guess'] = best_guess.get_text() 130 | 131 | return results 132 | 133 | 134 | async def scam(results, lim): 135 | 136 | single = opener.open(results['similar_images']).read() 137 | decoded = single.decode('utf-8') 138 | 139 | imglinks = [] 140 | counter = 0 141 | 142 | pattern = r'^,\[\"(.*[.png|.jpg|.jpeg])\",[0-9]+,[0-9]+\]$' 143 | oboi = re.findall(pattern, decoded, re.I | re.M) 144 | 145 | for imglink in oboi: 146 | counter += 1 147 | if not counter >= int(lim): 148 | imglinks.append(imglink) 149 | else: 150 | break 151 | 152 | return imglinks 153 | 154 | CmdHelp('reverse').add_command( 155 | 'reverse', '', 'Fotoğraf veya çıkartmaya yanıt vererek görüntüyü Google üzerniden arayabilirsiniz.' 156 | ).add() -------------------------------------------------------------------------------- /userbot/modules/rgb.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2019 The Raphielscape Company LLC. 2 | # 3 | # Licensed under the Raphielscape Public License, Version 1.c (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # 6 | 7 | # Asena UserBot - Yusuf Usta 8 | 9 | # @NaytSeyd tarafından portlanmıştır. 10 | # 11 | 12 | import io 13 | import os 14 | import random 15 | import textwrap 16 | 17 | from PIL import Image, ImageChops, ImageDraw, ImageFont 18 | from telethon.tl.types import InputMessagesFilterDocument 19 | from userbot.events import register 20 | from userbot import CMD_HELP, bot 21 | from userbot.cmdhelp import CmdHelp 22 | 23 | # ██████ LANGUAGE CONSTANTS ██████ # 24 | 25 | from userbot.language import get_value 26 | LANG = get_value("rgb") 27 | 28 | # ████████████████████████████████ 29 | 30 | @register(outgoing=True, pattern="^.rgb(?: |$)(.*)") 31 | async def sticklet(event): 32 | R = random.randint(0,256) 33 | G = random.randint(0,256) 34 | B = random.randint(0,256) 35 | 36 | # Giriş metnini al 37 | sticktext = event.pattern_match.group(1).strip() 38 | 39 | if len(sticktext) < 1: 40 | await event.edit(LANG['NEED_TEXT']) 41 | return 42 | 43 | # Komutu düzenle 44 | await event.edit(LANG['CONVERTING']) 45 | 46 | # https://docs.python.org/3/library/textwrap.html#textwrap.wrap 47 | sticktext = textwrap.wrap(sticktext, width=10) 48 | # Listeyi bir dizeye dönüştür 49 | sticktext = '\n'.join(sticktext) 50 | 51 | image = Image.new("RGBA", (512, 512), (255, 255, 255, 0)) 52 | draw = ImageDraw.Draw(image) 53 | fontsize = 230 54 | 55 | FONT_FILE = await get_font_file(event.client, "@FontArsiv") 56 | 57 | font = ImageFont.truetype(FONT_FILE, size=fontsize) 58 | 59 | while draw.multiline_textsize(sticktext, font=font) > (512, 512): 60 | fontsize -= 10 61 | font = ImageFont.truetype(FONT_FILE, size=fontsize) 62 | 63 | width, height = draw.multiline_textsize(sticktext, font=font) 64 | draw.multiline_text(((512-width)/2,(512-height)/2), sticktext, font=font, fill=(R, G, B)) 65 | 66 | image_stream = io.BytesIO() 67 | image_stream.name = "@resim.webp" 68 | 69 | def trim(im): 70 | bg = Image.new(im.mode, im.size, im.getpixel((0,0))) 71 | diff = ImageChops.difference(im, bg) 72 | diff = ImageChops.add(diff, diff, 2.0, -100) 73 | bbox = diff.getbbox() 74 | return im.crop(bbox) if bbox else im 75 | 76 | image = trim(image) 77 | image.save(image_stream, "WebP") 78 | image_stream.seek(0) 79 | 80 | # mesajı sil 81 | await event.delete() 82 | try: 83 | await event.client.send_file(event.chat_id, image_stream, reply_to=event.message.reply_to_msg_id) 84 | except: 85 | await event.edit("__Bu grupta sticker gönderimine izin verilmiyor.__") 86 | 87 | # Temizlik 88 | try: 89 | os.remove(FONT_FILE) 90 | except: 91 | pass 92 | 93 | 94 | async def get_font_file(client, channel_id): 95 | # Önce yazı tipi mesajlarını al 96 | font_file_message_s = await client.get_messages( 97 | entity=channel_id, 98 | filter=InputMessagesFilterDocument, 99 | # Bu işlem çok fazla kullanıldığında 100 | # "FLOOD_WAIT" yapmaya neden olabilir 101 | limit=None 102 | ) 103 | # Yazı tipi listesinden rastgele yazı tipi al 104 | # https://docs.python.org/3/library/random.html#random.choice 105 | font_file_message = random.choice(font_file_message_s) 106 | # Dosya yolunu indir ve geri dön 107 | return await client.download_media(font_file_message) 108 | 109 | CmdHelp('rgb').add_command( 110 | 'rbg', '', 'Metninizi RGB çıkartmaya dönüştürün.' 111 | ).add() -------------------------------------------------------------------------------- /userbot/modules/screencapture.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2019 The Raphielscape Company LLC. 2 | # 3 | # Licensed under the Raphielscape Public License, Version 1.c (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # 6 | 7 | # Asena UserBot - Yusuf Usta 8 | 9 | 10 | import io 11 | from re import match 12 | from selenium import webdriver 13 | from asyncio import sleep 14 | from selenium.webdriver.chrome.options import Options 15 | from userbot.events import register 16 | from userbot import GOOGLE_CHROME_BIN, CHROME_DRIVER, CMD_HELP 17 | from userbot.cmdhelp import CmdHelp 18 | 19 | # ██████ LANGUAGE CONSTANTS ██████ # 20 | 21 | from userbot.language import get_value 22 | LANG = get_value("screencapture") 23 | 24 | # ████████████████████████████████ 25 | 26 | @register(pattern=r".ss (.*)", outgoing=True) 27 | async def capture(url): 28 | """ .ss komutu, belirttiğin herhangi bir siteden ekran görüntüsü alır ve sohbete gönderir. """ 29 | await url.edit(LANG['TRYING']) 30 | chrome_options = Options() 31 | chrome_options.add_argument("--disable-infobars") 32 | chrome_options.add_argument("--headless") 33 | chrome_options.add_argument("--test-type") 34 | chrome_options.add_argument("--disable-features=VizDisplayCompositor") 35 | chrome_options.add_argument("--disable-browser-side-navigation") 36 | chrome_options.add_argument('--ignore-certificate-errors') 37 | chrome_options.add_argument("--disable-dev-shm-usage") 38 | chrome_options.add_argument("--no-sandbox") 39 | chrome_options.add_argument('--disable-gpu') 40 | driver = webdriver.Chrome(options=chrome_options) 41 | input_str = url.pattern_match.group(1) 42 | link_match = match(r'\bhttps?://.*\.\S+', input_str) 43 | if link_match: 44 | link = link_match.group() 45 | else: 46 | await url.edit(LANG['INVALID_URL']) 47 | return 48 | driver.get(link) 49 | height = driver.execute_script( 50 | "return Math.max(document.body.scrollHeight, document.body.offsetHeight, document.documentElement.clientHeight, document.documentElement.scrollHeight, document.documentElement.offsetHeight);" 51 | ) 52 | width = driver.execute_script( 53 | "return Math.max(document.body.scrollWidth, document.body.offsetWidth, document.documentElement.clientWidth, document.documentElement.scrollWidth, document.documentElement.offsetWidth);" 54 | ) 55 | driver.set_window_size(width + 125, height + 125) 56 | wait_for = height / 1000 57 | await url.edit(f"{LANG['TAKING']}\ 58 | \n`{LANG['HEIGHT']}: {height} {LANG['PIXEL']}`\ 59 | \n`{LANG['WIDTH']}: {width} {LANG['PIXEL']}`" + 60 | LANG['WAIT'] % str(wait_for)) 61 | await sleep(int(wait_for)) 62 | im_png = driver.get_screenshot_as_png() 63 | # Sayfanın ekran görüntüsü kaydedilir. 64 | driver.close() 65 | message_id = url.message.id 66 | if url.reply_to_msg_id: 67 | message_id = url.reply_to_msg_id 68 | with io.BytesIO(im_png) as out_file: 69 | out_file.name = "ekran_goruntusu.png" 70 | await url.edit(LANG['UPLOADING']) 71 | await url.client.send_file(url.chat_id, 72 | out_file, 73 | caption=input_str, 74 | force_document=True, 75 | reply_to=message_id) 76 | 77 | CmdHelp('ss').add_command( 78 | 'ss', '', 'Belirtilen web sitesinden bir ekran görüntüsü alır ve gönderir.', 'ss https://fusuf.codes' 79 | ).add() -------------------------------------------------------------------------------- /userbot/modules/shazam.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2020 Yusuf Usta. 2 | # 3 | # Licensed under the GPL-3.0 License; 4 | # you may not use this file except in compliance with the License. 5 | # 6 | 7 | # Asena UserBot - Yusuf Usta 8 | # Telegram @Fusuf 9 | 10 | # Coded by @Fusuf 11 | 12 | from pydub import AudioSegment 13 | from json import dumps 14 | from userbot.events import register 15 | from .shazam_helper.communication import recognize_song_from_signature 16 | from .shazam_helper.algorithm import SignatureGenerator 17 | from requests import get 18 | from os import remove 19 | import urllib.parse 20 | from userbot.cmdhelp import CmdHelp 21 | 22 | @register(outgoing=True, pattern="^.shazam") 23 | async def shazam(event): 24 | if not event.is_reply: 25 | return await event.edit('`Lütfen bir ses dosyasına yanıt verin!`') 26 | else: 27 | await event.edit('`⬇️ Ses dosyası indiriliyor...`') 28 | reply_message = await event.get_reply_message() 29 | dosya = await reply_message.download_media() 30 | 31 | await event.edit('`🛠 Ses dosyası fingerprint formatına çeviriliyor...`') 32 | audio = AudioSegment.from_file(dosya) 33 | audio = audio.set_sample_width(2) 34 | audio = audio.set_frame_rate(16000) 35 | audio = audio.set_channels(1) 36 | 37 | signature_generator = SignatureGenerator() 38 | signature_generator.feed_input(audio.get_array_of_samples()) 39 | 40 | signature_generator.MAX_TIME_SECONDS = 12 41 | if audio.duration_seconds > 12 * 3: 42 | signature_generator.samples_processed += 16000 * (int(audio.duration_seconds / 2) - 6) 43 | 44 | results = '{"error": "Not found"}' 45 | sarki = None 46 | await event.edit('`🎧 🎤 Shazamlanıyor...`') 47 | while True: 48 | signature = signature_generator.get_next_signature() 49 | if not signature: 50 | sarki = results 51 | break 52 | results = recognize_song_from_signature(signature) 53 | if results['matches']: 54 | sarki = results 55 | break 56 | else: 57 | await event.edit(f'`İlk {(signature_generator.samples_processed / 16000)} saniyede hiçbir şey bulunamadı... Biraz daha deniyorum.`') 58 | 59 | if not 'track' in sarki: 60 | return await event.edit('`Üzgünüm Shazam verdiniğiniz sesi anlamadı 😔. Biraz daha açık ses iletir misiniz?`') 61 | await event.edit('`✅ Şarkıyı buldum... Bilgiler getiriliyor...`') 62 | Caption = f'**Şarkı:** [{sarki["track"]["title"]}]({sarki["track"]["url"]})\n' 63 | if 'artists' in sarki['track']: 64 | Caption += f'**Sanatçı(lar):** [{sarki["track"]["subtitle"]}](https://www.shazam.com/artist/{sarki["track"]["artists"][0]["id"]})\n' 65 | else: 66 | Caption += f'**Sanatçı(lar):** `{sarki["track"]["subtitle"]}`\n' 67 | 68 | if 'genres'in sarki['track']: 69 | Caption += f'**Tür:** `{sarki["track"]["genres"]["primary"]}`\n' 70 | 71 | if sarki["track"]["sections"][0]["type"] == "SONG": 72 | for metadata in sarki["track"]["sections"][0]["metadata"]: 73 | Caption += f'**{"Yıl" if metadata["title"] == "Sorti" else metadata["title"]}:** `{metadata["text"]}`\n' 74 | 75 | Caption += '\n**Müzik Platformları:** ' 76 | for provider in sarki['track']['hub']['providers']: 77 | if provider['actions'][0]['uri'].startswith('spotify:track'): 78 | Url = provider['actions'][0]['uri'].replace( 79 | 'spotify:track:', 'http://open.spotify.com/track/' 80 | ) 81 | elif provider['actions'][0]['uri'].startswith('intent:#Intent;action=android.media.action.MEDIA_PLAY_FROM_SEARCH'): 82 | Url = f'https://open.spotify.com/search/' + urllib.parse.quote(sarki["track"]["subtitle"] + ' - ' + sarki["track"]["title"]) 83 | elif provider['actions'][0]['uri'].startswith('deezer'): 84 | Url = provider['actions'][0]['uri'].replace( 85 | 'deezer-query://', 'https://' 86 | ) 87 | else: 88 | Url = provider['actions'][0]['uri'] 89 | Caption += f'[{provider["type"].capitalize()}]({Url}) ' 90 | for section in sarki['track']['sections']: 91 | if section['type'] == 'VIDEO': 92 | if 'youtubeurl' in section: 93 | Youtube = get(section['youtubeurl']).json() 94 | else: 95 | return 96 | 97 | Caption += f'\n**Klip Videosu:** [Youtube]({Youtube["actions"][0]["uri"]})' 98 | 99 | if 'images' in sarki["track"] and len(sarki["track"]["images"]) >= 1: 100 | await event.delete() 101 | await event.client.send_file( 102 | event.chat_id, 103 | sarki["track"]["images"]["coverarthq"] if 'coverarthq' in sarki["track"]["images"] else sarki["track"]["images"]["background"], 104 | caption=Caption, 105 | reply_to=reply_message 106 | ) 107 | else: 108 | await event.edit(Caption) 109 | remove(dosya) 110 | 111 | CmdHelp('shazam').add_command( 112 | 'shazam', '', 'Yanıt verdiğiniz ses dosyasını Shazamda arar.' 113 | ).add() -------------------------------------------------------------------------------- /userbot/modules/shazam_helper/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yusufusta/AsenaUserBot/d850bae0f8491911465fb5f54e1692b0b9f112de/userbot/modules/shazam_helper/__init__.py -------------------------------------------------------------------------------- /userbot/modules/shazam_helper/communication.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | #-*- encoding: Utf-8 -*- 3 | from uuid import uuid5, getnode, NAMESPACE_DNS, NAMESPACE_URL 4 | from random import seed, random, choice 5 | from pytz import all_timezones 6 | from requests import get, post 7 | from base64 import b64encode 8 | from locale import getlocale 9 | from json import dumps 10 | from time import time 11 | 12 | from .signature_format import DecodedMessage 13 | from .user_agent import USER_AGENTS 14 | 15 | locale = (getlocale()[0] or 'tr_TR').split('.')[0] 16 | 17 | first_uuid = str(uuid5(NAMESPACE_DNS, str(getnode()))).upper() 18 | second_uuid = str(uuid5(NAMESPACE_URL, str(getnode()))) 19 | 20 | def recognize_song_from_signature(signature : DecodedMessage) -> dict: 21 | 22 | # Même si Macron ne veut pas, nous on est là 23 | 24 | fuzz = random() * 15.3 - 7.65 25 | 26 | seed(getnode()) 27 | 28 | return post('https://amp.shazam.com/discovery/v5/fr/FR/android/-/tag/' + first_uuid + '/' + second_uuid, params = { 29 | 'sync': 'true', 30 | 'webv3': 'true', 31 | 'sampling': 'true', 32 | 'connected': '', 33 | 'shazamapiversion': 'v3', 34 | 'sharehub': 'true', 35 | 'video': 'v3' 36 | }, headers = { 37 | 'Content-Type': 'application/json', 38 | 'User-Agent': choice(USER_AGENTS), 39 | 'Content-Language': 'tr_TR' 40 | }, json = { 41 | "geolocation": { 42 | "altitude": random() * 400 + 100 + fuzz, 43 | "latitude": random() * 180 - 90 + fuzz, 44 | "longitude": random() * 360 - 180 + fuzz 45 | }, 46 | "signature": { 47 | "samplems": int(signature.number_samples / signature.sample_rate_hz * 1000), 48 | "timestamp": int(time() * 1000), 49 | "uri": signature.encode_to_uri() 50 | }, 51 | "timestamp": int(time() * 1000), 52 | "timezone": choice([timezone for timezone in all_timezones if 'Europe/' in timezone]) 53 | }).json() 54 | 55 | 56 | if __name__ == '__main__': 57 | 58 | print(dumps(recognize_song_from_signature(DecodedMessage.decode_from_uri('data:audio/vnd.shazam.sig;base64,gCX+ynzKnegoBQAAAJwRlAAAAAAAAAAAAAAAAAAAABgAAAAAAAAAAACGAQAAAHwAAAAAQCgFAABAAANgeAAAACdVdK4MAT15RAgN3XWPCjsqeFUPHjR5JQ4VQXh5CR6/dF0OS3h2zg0MvHaHD1FneFgMEtdmRQ4PZ2z4DhF2dZIMNHZwTQ834XZIDAOkaYwQBqpqLA8wVHKtDCWfczEPNGF90AwZXnmqCRPEejgJBY18xA8nGnDzDEEAA2ByAQAAGVlxRRkJinLDGgazd8QQAbN0aCsBOm5iJQoXbXwWBQRsBRMDyHY6Hh9fc88QBt1qaSgIdXeLIQUGdgcmBRxwsRYBRnU8Hgo7anIsBBJxpSQCNXT5FR9ja1MdAkt2iBIK+3QwJgZTdWwZDNFq0xUMG3OqIQNOeDMtJzhv6R4AaG4wKwVDd84XAb50UScDi24/HgllbRgZDz5tliwFWXIDFQB+cQkjITltLRQDpHYcGAEIc8QnAQluqB8SIHMFGRE3bmocBiVxuCoIw3HOFgCZdD4tIoB0ER4VSWzWJQ/CbYQcAYhyvCoKKnv/GAksbc4eJ/d9PSUBg3nrGAFxcSstLeJwkSYKF3QrHgAyb/olDzRvOCAAB3k2LRPhcYIsASlz/RIA0G9MJBgWcB0cAc5wjyUGCnNhGQSVd/EmA9B0uhoIl3IYLQE4cFImFZJ1RR4GonRPKAHBeIgUFWlsEB8II4AKEQiSdpAhFAtpLB4BZmSFKQAAQgADYIsBAAAMA3IWPAWTcoo2DiRwiE0BwnDpMgZecVNLAfpxkUMAVnQJSALmb88zCqd03jcABHLvTgZDb7w/ANJw+08T+3ISPhKGcH9DD6VzyzIA9XKaRTV3bnIvATRysjwC5XG7OAmNcT8yBEBwhD8PL3R/MwDNcBttEMRy7DImfHvBMwb2dL87Dl91Jm5O/XTIZADKcwVrAQJzEl4Oa3RdVgEIeck9ATR6+UkGrnbvVAMPdRpQAQV0ZTgB+3bHMRSEeMU6Ez5+ckoAM324VgUFfYg8BZ90r0Qf7H8zMgPWdXE2Aeh7kU8BfHgAQwHxe6dLAHl4SlgIEX9rPg6denRGE+l5+0oCr4KWMQWxebRLDax/cDwB93mESRN5e0BMAq6Cbj8JMoR7PgBbenNXA858zkoI5H36SA43et5FE/h50TERoHcbTwH4eNg0AdZ3TToL1HeaOACEeNQ8APqBNEEBqXc/TgZ8ebBNATeDvUBbKWuJPAHhYTBiBbdtDUsBkmW0XgICdL44AB1r/FQSeWu7OgBDAANghgEAAAv0aDh4ACtneoYBcGbUjwA0Zy6dALtoQqca4mfRcgHUZhSGAepqEKQKZmp6cADXZwabAeRlqpEFLmq3cVYWbv5wFHZof3cAimZphwANZjOeAU9rQKcIv2WscSX0aMCcABRq0J8APWZVrQFzaoCFAKNsh5gB6myJdgzCaQJ7DwJwWosAJWqQjwCnb5KSAPptCZwB4G56fwZ9bhmVDp9rU3cWBW3DrgcgazCbBkFt3ZIT+Wm5qA2zaXJ+ALVpF5YA8mnBmQFKaz+KAGZs65ESWmxvhACIafeqAbZqQHEAA20ffADaao+kAc5q+XQAHGpGkMLkYkylDMlrBHIWUmRUdgMxZWWPA8tr2a4J8mY2eQD4ai2bBAdq0ZITDGhLhgBUZl2eAFhng6gCfGLIgQtKZ4xwGc1j5ZsBK2QBeQFQanV0AfRjsaEBeGItiQEDZeF8DS9kDHoSe2UsdwFtZU5+CmFpLngOZGQ4hw0rXOeOAJ1gmagB4F4DmwEJYQKACANd6J4VuFJtrAAA')), indent = 4, ensure_ascii = False)) -------------------------------------------------------------------------------- /userbot/modules/snips.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2019 The Raphielscape Company LLC. 2 | # 3 | # Licensed under the Raphielscape Public License, Version 1.c (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # 6 | 7 | # Asena UserBot - Yusuf Usta 8 | 9 | 10 | """ Küresel notlar tutmak için yapılmış olan UserBot modülü. """ 11 | 12 | from userbot.events import register 13 | from userbot import CMD_HELP, BOTLOG_CHATID 14 | from userbot.cmdhelp import CmdHelp 15 | 16 | # ██████ LANGUAGE CONSTANTS ██████ # 17 | 18 | from userbot.language import get_value 19 | LANG = get_value("snips") 20 | 21 | # ████████████████████████████████ 22 | 23 | @register(outgoing=True, 24 | pattern=r"\$\w*", 25 | ignore_unsafe=True, 26 | disable_errors=True) 27 | async def on_snip(event): 28 | """ Snip mantığı. """ 29 | try: 30 | from userbot.modules.sql_helper.snips_sql import get_snip 31 | except AttributeError: 32 | return 33 | name = event.text[1:] 34 | snip = get_snip(name) 35 | message_id_to_reply = event.message.reply_to_msg_id 36 | if not message_id_to_reply: 37 | message_id_to_reply = None 38 | if snip and snip.f_mesg_id: 39 | await event.delete() 40 | msg_o = await event.client.get_messages(entity=BOTLOG_CHATID, 41 | ids=int(snip.f_mesg_id)) 42 | await event.client.send_message(event.chat_id, 43 | msg_o.message, 44 | reply_to=message_id_to_reply, 45 | file=msg_o.media) 46 | elif snip and snip.reply: 47 | await event.client.send_message(event.chat_id, 48 | snip.reply, 49 | reply_to=message_id_to_reply) 50 | 51 | 52 | @register(outgoing=True, pattern="^.snip (\w*)") 53 | async def on_snip_save(event): 54 | """ .snip komutu gelecekte kullanılmak üzere snips kaydeder. """ 55 | try: 56 | from userbot.modules.sql_helper.snips_sql import add_snip 57 | except AtrributeError: 58 | await event.edit(LANG['NO_SQL']) 59 | return 60 | keyword = event.pattern_match.group(1) 61 | string = event.text.partition(keyword)[2] 62 | msg = await event.get_reply_message() 63 | msg_id = None 64 | if msg and msg.media and not string: 65 | if BOTLOG_CHATID: 66 | await event.client.send_message( 67 | BOTLOG_CHATID, f"#SNIP\ 68 | \nKELIME: {keyword}\ 69 | \n\nAşağıdaki mesaj snip için veri olarak kaydedilir, lütfen silmeyin !!" 70 | ) 71 | msg_o = await event.client.forward_messages( 72 | entity=BOTLOG_CHATID, 73 | messages=msg, 74 | from_peer=event.chat_id, 75 | silent=True) 76 | msg_id = msg_o.id 77 | else: 78 | await event.edit( 79 | LANG['NEED_BOTLOG'] 80 | ) 81 | return 82 | elif event.reply_to_msg_id and not string: 83 | rep_msg = await event.get_reply_message() 84 | string = rep_msg.text 85 | success = "`Snip {}. {}:` **${}** `" 86 | if add_snip(keyword, string, msg_id) is False: 87 | await event.edit(success.format(LANG['UPDATED'], LANG['USAGE'], keyword)) 88 | else: 89 | await event.edit(success.format(LANG['SAVED'], LANG['USAGE'], keyword)) 90 | 91 | 92 | @register(outgoing=True, pattern="^.snips$") 93 | async def on_snip_list(event): 94 | """ .snips komutu sizin tarafınızdan kaydedilen snip'leri listeler. """ 95 | try: 96 | from userbot.modules.sql_helper.snips_sql import get_snips 97 | except AttributeError: 98 | await event.edit("`SQL dışı modda çalışıyor!`") 99 | return 100 | 101 | message = LANG['NO_SNIP'] 102 | all_snips = get_snips() 103 | for a_snip in all_snips: 104 | if message == LANG['NO_SNIP']: 105 | message = f"{LANG['SNIPS']}:\n" 106 | message += f"`${a_snip.snip}`\n" 107 | else: 108 | message += f"`${a_snip.snip}`\n" 109 | 110 | await event.edit(message) 111 | 112 | 113 | @register(outgoing=True, pattern="^.remsnip (\w*)") 114 | async def on_snip_delete(event): 115 | """ .remsnip komutu belirlenini snipi siler. """ 116 | try: 117 | from userbot.modules.sql_helper.snips_sql import remove_snip 118 | except AttributeError: 119 | await event.edit("`SQL dışı modda çalışıyor!`") 120 | return 121 | name = event.pattern_match.group(1) 122 | if remove_snip(name) is True: 123 | await event.edit(f"`Snip:` **{name}** `{LANG['DELETED']}`") 124 | else: 125 | await event.edit(f"`Snip:` **{name}** `{LANG['NOT_FOUND']}` ") 126 | 127 | CmdHelp('snips').add_command( 128 | '$', None, 'Snipi çağırır.' 129 | ).add_command( 130 | 'snip', ' ', 'Bir snip (küresel not) olarak kaydeder. (Resimler, dokümanlar ve çıkartmalar ile çalışır !)' 131 | ).add_command( 132 | 'snips', None, 'Kaydedilen tüm snip\'leri listeler.' 133 | ).add_command( 134 | 'remsnip', '', 'Belirtilen snip\'i siler.' 135 | ).add() -------------------------------------------------------------------------------- /userbot/modules/song.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2020 Yusuf Usta. 2 | # 3 | # Licensed under the GPL-3.0 License; 4 | # you may not use this file except in compliance with the License. 5 | # 6 | 7 | # Asena UserBot - Yusuf Usta 8 | 9 | import datetime 10 | import asyncio 11 | from telethon import events 12 | from telethon.errors.rpcerrorlist import YouBlockedUserError 13 | from telethon.tl.functions.account import UpdateNotifySettingsRequest 14 | from userbot import bot, CMD_HELP 15 | from userbot.events import register 16 | import os 17 | import subprocess 18 | import glob 19 | from random import randint 20 | from userbot.cmdhelp import CmdHelp 21 | 22 | # ██████ LANGUAGE CONSTANTS ██████ # 23 | 24 | from userbot.language import get_value 25 | LANG = get_value("song") 26 | 27 | # ████████████████████████████████ # 28 | 29 | @register(outgoing=True, pattern="^.deez(\d*|)(?: |$)(.*)") 30 | async def deezl(event): 31 | if event.fwd_from: 32 | return 33 | sira = event.pattern_match.group(1) 34 | if sira == '': 35 | sira = 0 36 | else: 37 | sira = int(sira) 38 | 39 | sarki = event.pattern_match.group(2) 40 | if len(sarki) < 1: 41 | if event.is_reply: 42 | sarki = await event.get_reply_message().text 43 | else: 44 | await event.edit(LANG['GIVE_ME_SONG']) 45 | 46 | await event.edit(LANG['SEARCHING']) 47 | chat = "@DeezerMusicBot" 48 | async with bot.conversation(chat) as conv: 49 | try: 50 | mesaj = await conv.send_message(str(randint(31,62))) 51 | sarkilar = await conv.get_response() 52 | await mesaj.edit(sarki) 53 | sarkilar = await conv.get_response() 54 | except YouBlockedUserError: 55 | await event.reply(LANG['BLOCKED_DEEZER']) 56 | return 57 | await event.client.send_read_acknowledge(conv.chat_id) 58 | if sarkilar.audio: 59 | await event.client.send_read_acknowledge(conv.chat_id) 60 | await event.client.send_message(event.chat_id, LANG['UPLOADED_WITH'], file=sarkilar.message) 61 | await event.delete() 62 | elif sarkilar.buttons[0][0].text == "No results": 63 | await event.edit(LANG['NOT_FOUND']) 64 | else: 65 | await sarkilar.click(sira) 66 | sarki = await conv.wait_event(events.NewMessage(incoming=True,from_users=595898211)) 67 | await event.client.send_read_acknowledge(conv.chat_id) 68 | await event.client.send_message(event.chat_id, f"`{sarkilar.buttons[sira][0].text}` | " + LANG['UPLOADED_WITH'], file=sarki.message) 69 | await event.delete() 70 | 71 | @register(outgoing=True, pattern="^.song(?: |$)(.*)") 72 | async def port_song(event): 73 | if event.fwd_from: 74 | return 75 | 76 | cmd = event.pattern_match.group(1) 77 | if len(cmd) < 1: 78 | await event.edit(LANG['UPLOADED_WITH']) 79 | 80 | reply_to_id = event.message.id 81 | if event.reply_to_msg_id: 82 | reply_to_id = event.reply_to_msg_id 83 | 84 | await event.edit(LANG['SEARCHING_SPOT']) 85 | dosya = os.getcwd() 86 | os.system(f"spotdl --song {cmd} -f {dosya}") 87 | await event.edit(LANG['DOWNLOADED']) 88 | 89 | l = glob.glob("*.mp3") 90 | if len(l) >= 1: 91 | await event.edit(LANG['UPLOADING']) 92 | await event.client.send_file( 93 | event.chat_id, 94 | l[0], 95 | force_document=True, 96 | allow_cache=False, 97 | reply_to=reply_to_id 98 | ) 99 | await event.delete() 100 | else: 101 | await event.edit(LANG['NOT_FOUND']) 102 | return 103 | os.system("rm -rf *.mp3") 104 | subprocess.check_output("rm -rf *.mp3",shell=True) 105 | 106 | @register(outgoing=True, pattern="^.songpl ?(.*)") 107 | async def songpl(event): 108 | if event.fwd_from: 109 | return 110 | DELAY_BETWEEN_EDITS = 0.3 111 | PROCESS_RUN_TIME = 100 112 | cmd = event.pattern_match.group(1) 113 | 114 | if len(cmd) < 1: 115 | await event.edit(LANG['USAGE_PL']) 116 | 117 | reply_to_id = event.message.id 118 | if event.reply_to_msg_id: 119 | reply_to_id = event.reply_to_msg_id 120 | await event.edit(LANG['SEARCHING_PL']) 121 | dosya = os.getcwd() + "/playlist/" + "pl.pl" 122 | klasor = os.getcwd() + "/playlist/" 123 | sonuc = os.system(f"spotdl --playlist {cmd} --write-to=\"{dosya}\"") 124 | sonuc2 = os.system(f"spotdl --list {dosya} -f {klasor}") 125 | await event.edit(LANG['DOWNLOADED']) 126 | l = glob.glob(f"{klasor}/*.mp3") 127 | i = 0 128 | if len(l) >= 1: 129 | while i < len(l): 130 | await event.reply(LANG['SENDING_SONGS'] + l[i]) 131 | await event.client.send_file( 132 | event.chat_id, 133 | l[i], 134 | force_document=True, 135 | allow_cache=False, 136 | caption=cmd, 137 | reply_to=reply_to_id 138 | ) 139 | else: 140 | await event.edit(LANG['NOT_FOUND_PL']) 141 | return 142 | os.system(f"rm -rf {klasor}/*.mp3") 143 | subprocess.check_output(f"rm -rf {klasor}/*.mp3",shell=True) 144 | os.system(f"rm -rf {klasor}/*.pl") 145 | subprocess.check_output(f"rm -rf {klasor}/*.pl",shell=True) 146 | 147 | CmdHelp('song').add_command( 148 | 'deez', '<şarkı ismi/youtube/spotify/soundcloud>', 'Birçok siteden şarkıyı arayıp, şarkıyı indirir.' 149 | ).add_command( 150 | 'song', '<şarkı ismi/youtube/spotify>', 'Şarkı indirir.' 151 | ).add_command( 152 | 'songpl', '', 'Spotify Playlist\'inden şarkı indirir' 153 | ).add() -------------------------------------------------------------------------------- /userbot/modules/sozluk.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2019 The Raphielscape Company LLC. 2 | # 3 | # Licensed under the Raphielscape Public License, Version 1.c (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # 6 | 7 | # Asena UserBot - Yusuf Usta 8 | 9 | # Turkish word meaning. Only Turkish. Coded @By_Azade, Asena uyarlaması @qulec 10 | # 11 | 12 | import requests 13 | 14 | import aiohttp 15 | import asyncio 16 | import json 17 | 18 | from userbot import CMD_HELP 19 | from userbot.events import register 20 | from bs4 import BeautifulSoup 21 | import os 22 | from json import loads 23 | from userbot.cmdhelp import CmdHelp 24 | 25 | def searchTureng_tr(word): 26 | url="https://tureng.com/tr/turkce-ingilizce/"+word 27 | try: 28 | answer = requests.get(url) 29 | except: 30 | return "No connection" 31 | soup = BeautifulSoup(answer.content, 'html.parser') 32 | trlated='{} Kelimesinin Anlamı/Anlamları:\n\n'.format(word) 33 | try: 34 | table = soup.find('table') 35 | td = table.find_all('td', attrs={'lang':'en'}) 36 | # print(td) 37 | for val in td[0:5]: 38 | trlated = '{}👉 {}\n'.format(trlated , val.text ) 39 | return trlated 40 | except: 41 | return "Sonuç bulunamadı" 42 | 43 | @register(outgoing=True, pattern="^.tureng ?(.*)") 44 | async def tureng(event): 45 | input_str = event.pattern_match.group(1) 46 | result = searchTureng_tr(input_str) 47 | await event.edit(result) 48 | 49 | def getSimilarWords(kelime, limit = 5): 50 | benzerler = [] 51 | if not os.path.exists('autocomplete.json'): 52 | words = requests.get(f'https://sozluk.gov.tr/autocomplete.json') 53 | open('autocomplete.json', 'a+').write(words.text) 54 | words = words.json() 55 | else: 56 | words = loads(open('autocomplete.json', 'r').read()) 57 | 58 | for word in words: 59 | if word['madde'].startswith(kelime) and not word['madde'] == kelime: 60 | if len(benzerler) > limit: 61 | break 62 | benzerler.append(word['madde']) 63 | benzerlerStr = "" 64 | for benzer in benzerler: 65 | if not benzerlerStr == "": 66 | benzerlerStr += ", " 67 | benzerlerStr += f"`{benzer}`" 68 | return benzerlerStr 69 | 70 | @register(outgoing=True, pattern="^.tdk ?(.*)") 71 | async def tdk(event): 72 | inp = event.pattern_match.group(1) 73 | await event.edit('**Bekle!**\n__Sözlükte arıyorum...__') 74 | async with aiohttp.ClientSession(connector=aiohttp.TCPConnector(verify_ssl=False)) as session: 75 | async with session.get('https://open-apis-rest.up.railway.app/api/tdk?word=' + str(inp)) as response: 76 | 77 | html = await response.text() 78 | html2 = json.loads(html) 79 | if html2["status"] == "OK": 80 | SAVE = "./soz.mp3" 81 | resp = requests.get(html2["data"]["ses"]) 82 | with open(SAVE, "wb") as f: 83 | f.write(resp.content) 84 | 85 | song = await event.client.send_file(event.chat_id, "./soz.mp3", voice_note=True) 86 | await event.client.send_message(event.chat_id, "**Kelime:** " + "__" + inp + "__" + "\n**Anlamı:** " + "__" + html2["data"]["anlam"] + "__" + "\n**Atasözü:** " + "__" + html2["data"]["atasozu"] + "__", reply_to=song, link_preview=False) 87 | await event.delete() 88 | else: 89 | return await event.edit(f'__Kelimeniz({inp}) Büyük Türkçe Sözlük\'te Bulunamadı!__') 90 | 91 | @register(outgoing=True, pattern="^.tdk2 ?(.*)") 92 | async def tdk(event): 93 | inp = event.pattern_match.group(1) 94 | await event.edit('**Bekle!**\n__Sözlükte arıyorum...__') 95 | response = requests.get(f'https://sozluk.gov.tr/gts?ara={inp}').json() 96 | if 'error' in response: 97 | await event.edit(f'**Kelimeniz({inp}) Büyük Türkçe Sözlük\'te Bulunamadı!**') 98 | words = getSimilarWords(inp) 99 | if not words == '': 100 | return await event.edit(f'__Kelimeniz({inp}) Büyük Türkçe Sözlük\'te Bulunamadı!__\n\n**Benzer Kelimeler:** {words}') 101 | else: 102 | anlamlarStr = "" 103 | for anlam in response[0]["anlamlarListe"]: 104 | anlamlarStr += f"\n**{anlam['anlam_sira']}.**" 105 | if ('ozelliklerListe' in anlam) and ((not anlam["ozelliklerListe"][0]["tam_adi"] == None) or (not anlam["ozelliklerListe"][0]["tam_adi"] == '')): 106 | anlamlarStr += f"__({anlam['ozelliklerListe'][0]['tam_adi']})__" 107 | anlamlarStr += f' ```{anlam["anlam"]}```' 108 | 109 | if response[0]["cogul_mu"] == '0': 110 | cogul = '❌' 111 | else: 112 | cogul = '✅' 113 | 114 | if response[0]["ozel_mi"] == '0': 115 | ozel = '❌' 116 | else: 117 | ozel = '✅' 118 | 119 | 120 | await event.edit(f'**Kelime:** `{inp}`\n\n**Çoğul Mu:** {cogul}\n**Özel Mi:** {ozel}\n\n**Anlamlar:**{anlamlarStr}') 121 | words = getSimilarWords(inp) 122 | if not words == '': 123 | return await event.edit(f'**Kelime:** `{inp}`\n\n**Çoğul Mu:** `{cogul}`\n**Özel Mi:** {ozel}\n\n**Anlamlar:**{anlamlarStr}' + f'\n\n**Benzer Kelimeler:** {words}') 124 | 125 | 126 | CmdHelp('sozluk').add_command( 127 | 'tdk', '', 'Verdiğiniz kelimeyi TDK Sözlükte arar.' 128 | ).add_command( 129 | 'tdk2', '', 'Kelimeyi TDK Sözlükte arar. (Daha Kapsamlı)' 130 | ).add_command( 131 | 'tureng', '', 'Verdiğiniz kelimeyi Tureng Sözlükte arar.' 132 | ).add() -------------------------------------------------------------------------------- /userbot/modules/spammer.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2019 The Raphielscape Company LLC. 2 | # 3 | # Licensed under the Raphielscape Public License, Version 1.c (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # 6 | 7 | # Asena UserBot - Yusuf Usta 8 | 9 | 10 | import asyncio 11 | import threading 12 | 13 | from userbot import BOTLOG, BOTLOG_CHATID, CMD_HELP 14 | from userbot.events import register 15 | from userbot.cmdhelp import CmdHelp 16 | 17 | @register(outgoing=True, pattern="^.tspam") 18 | async def tmeme(e): 19 | message = e.text 20 | messageSplit = message.split(" ", 1) 21 | tspam = str(messageSplit[1]) 22 | message = tspam.replace(" ", "") 23 | for letter in message: 24 | await e.respond(letter) 25 | await e.delete() 26 | if BOTLOG: 27 | await e.client.send_message( 28 | BOTLOG_CHATID, 29 | "#TSPAM \n\n" 30 | "TSpam başarıyla gerçekleştirildi" 31 | ) 32 | 33 | @register(outgoing=True, pattern="^.spam") 34 | async def spammer(e): 35 | if not e.text[0].isalpha() and e.text[0] not in ("/", "#", "@", "!"): 36 | message = e.text 37 | messageSplit = message.split(" ", 2) 38 | counter = int(messageSplit[1]) 39 | spam_message = str(messageSplit[2]) 40 | await asyncio.wait([e.respond(spam_message) for i in range(counter)]) 41 | await e.delete() 42 | if BOTLOG: 43 | await e.client.send_message( 44 | BOTLOG_CHATID, 45 | "#SPAM \n\n" 46 | "Spam başarıyla gerçekleştirildi" 47 | ) 48 | 49 | @register(outgoing=True, pattern="^.bigspam") 50 | async def bigspam(e): 51 | if not e.text[0].isalpha() and e.text[0] not in ("/", "#", "@", "!"): 52 | message = e.text 53 | messageSplit = message.split(" ", 2) 54 | counter = int(messageSplit[1]) 55 | spam_message = str(messageSplit[2]) 56 | for i in range(1, counter): 57 | await e.respond(spam_message) 58 | await e.delete() 59 | if BOTLOG: 60 | await e.client.send_message( 61 | BOTLOG_CHATID, 62 | "#BIGSPAM \n\n" 63 | "Bigspam başarıyla gerçekleştirildi" 64 | ) 65 | 66 | 67 | @register(outgoing=True, pattern="^.picspam") 68 | async def tiny_pic_spam(e): 69 | if not e.text[0].isalpha() and e.text[0] not in ("/", "#", "@", "!"): 70 | message = e.text 71 | text = message.split() 72 | counter = int(text[1]) 73 | link = str(text[2]) 74 | for i in range(1, counter): 75 | await e.client.send_file(e.chat_id, link) 76 | await e.delete() 77 | if BOTLOG: 78 | await e.client.send_message( 79 | BOTLOG_CHATID, 80 | "#PICSPAM \n\n" 81 | "PicSpam başarıyla gerçekleştirildi" 82 | ) 83 | 84 | 85 | @register(outgoing=True, pattern="^.delayspam") 86 | async def delayspammer(e): 87 | # Teşekkürler @ReversedPosix 88 | if not e.text[0].isalpha() and e.text[0] not in ("/", "#", "@", "!"): 89 | message = e.text 90 | messageSplit= message.split(" ", 3) 91 | spam_delay = float(messageSplit[1]) 92 | counter = int(messageSplit[2]) 93 | spam_message = str(messageSplit[3]) 94 | from userbot.events import register 95 | await e.delete() 96 | delaySpamEvent = threading.Event() 97 | for i in range(1, counter): 98 | await e.respond(spam_message) 99 | delaySpamEvent.wait(spam_delay) 100 | if BOTLOG: 101 | await e.client.send_message( 102 | BOTLOG_CHATID, 103 | "#DelaySPAM \n\n" 104 | "DelaySpam başarıyla gerçekleştirildi" 105 | ) 106 | 107 | CmdHelp('spammer').add_command( 108 | 'tspam', '', 'Verilen mesajı tek tek göndererek spam yapar.' 109 | ).add_command( 110 | 'spam', ' ', 'Verilen miktarda spam gönderir.' 111 | ).add_command( 112 | 'bigspam', ' ', 'Verilen miktarda spam gönderir.' 113 | ).add_command( 114 | 'picspam', ' ', 'Verilen miktarda resimli spam gönderir.' 115 | ).add_command( 116 | 'delayspam', ' ', 'Verilen miktar ve verilen gecikme ile gecikmeli spam yapar.' 117 | ).add_warning( 118 | 'Sorumluluk size aittir!!' 119 | ).add() -------------------------------------------------------------------------------- /userbot/modules/sql_helper/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yusufusta/AsenaUserBot/d850bae0f8491911465fb5f54e1692b0b9f112de/userbot/modules/sql_helper/.DS_Store -------------------------------------------------------------------------------- /userbot/modules/sql_helper/__init__.py: -------------------------------------------------------------------------------- 1 | from sqlalchemy import create_engine 2 | from sqlalchemy.ext.declarative import declarative_base 3 | from sqlalchemy.orm import sessionmaker, scoped_session 4 | from userbot import DB_URI 5 | 6 | BASE = declarative_base() 7 | 8 | 9 | def start() -> scoped_session: 10 | engine = create_engine(DB_URI) 11 | BASE.metadata.bind = engine 12 | BASE.metadata.create_all(engine) 13 | return scoped_session(sessionmaker(bind=engine, autoflush=False)) 14 | 15 | 16 | SESSION = start() 17 | -------------------------------------------------------------------------------- /userbot/modules/sql_helper/blacklist_sql.py: -------------------------------------------------------------------------------- 1 | import threading 2 | from sqlalchemy import func, distinct, Column, String, UnicodeText 3 | try: 4 | from userbot.modules.sql_helper import SESSION, BASE 5 | except ImportError: 6 | raise AttributeError 7 | 8 | 9 | class BlackListFilters(BASE): 10 | __tablename__ = "blacklist" 11 | chat_id = Column(String(14), primary_key=True) 12 | trigger = Column(UnicodeText, primary_key=True, nullable=False) 13 | 14 | def __init__(self, chat_id, trigger): 15 | self.chat_id = str(chat_id) # ensure string 16 | self.trigger = trigger 17 | 18 | def __repr__(self): 19 | return "" % (self.trigger, self.chat_id) 20 | 21 | def __eq__(self, other): 22 | return bool(isinstance(other, BlackListFilters) 23 | and self.chat_id == other.chat_id 24 | and self.trigger == other.trigger) 25 | 26 | 27 | BlackListFilters.__table__.create(checkfirst=True) 28 | 29 | BLACKLIST_FILTER_INSERTION_LOCK = threading.RLock() 30 | 31 | CHAT_BLACKLISTS = {} 32 | 33 | 34 | def add_to_blacklist(chat_id, trigger): 35 | with BLACKLIST_FILTER_INSERTION_LOCK: 36 | blacklist_filt = BlackListFilters(str(chat_id), trigger) 37 | 38 | SESSION.merge(blacklist_filt) # merge to avoid duplicate key issues 39 | SESSION.commit() 40 | CHAT_BLACKLISTS.setdefault(str(chat_id), set()).add(trigger) 41 | 42 | 43 | def rm_from_blacklist(chat_id, trigger): 44 | with BLACKLIST_FILTER_INSERTION_LOCK: 45 | blacklist_filt = SESSION.query(BlackListFilters).get((str(chat_id), trigger)) 46 | if blacklist_filt: 47 | if trigger in CHAT_BLACKLISTS.get(str(chat_id), set()): # sanity check 48 | CHAT_BLACKLISTS.get(str(chat_id), set()).remove(trigger) 49 | 50 | SESSION.delete(blacklist_filt) 51 | SESSION.commit() 52 | return True 53 | 54 | SESSION.close() 55 | return False 56 | 57 | 58 | def get_chat_blacklist(chat_id): 59 | return CHAT_BLACKLISTS.get(str(chat_id), set()) 60 | 61 | 62 | def num_blacklist_filters(): 63 | try: 64 | return SESSION.query(BlackListFilters).count() 65 | finally: 66 | SESSION.close() 67 | 68 | 69 | def num_blacklist_chat_filters(chat_id): 70 | try: 71 | return SESSION.query(BlackListFilters.chat_id).filter(BlackListFilters.chat_id == str(chat_id)).count() 72 | finally: 73 | SESSION.close() 74 | 75 | 76 | def num_blacklist_filter_chats(): 77 | try: 78 | return SESSION.query(func.count(distinct(BlackListFilters.chat_id))).scalar() 79 | finally: 80 | SESSION.close() 81 | 82 | 83 | def __load_chat_blacklists(): 84 | global CHAT_BLACKLISTS 85 | try: 86 | chats = SESSION.query(BlackListFilters.chat_id).distinct().all() 87 | for (chat_id,) in chats: # remove tuple by ( ,) 88 | CHAT_BLACKLISTS[chat_id] = [] 89 | 90 | all_filters = SESSION.query(BlackListFilters).all() 91 | for x in all_filters: 92 | CHAT_BLACKLISTS[x.chat_id] += [x.trigger] 93 | 94 | CHAT_BLACKLISTS = {x: set(y) for x, y in CHAT_BLACKLISTS.items()} 95 | 96 | finally: 97 | SESSION.close() 98 | 99 | 100 | __load_chat_blacklists() 101 | -------------------------------------------------------------------------------- /userbot/modules/sql_helper/filter_sql.py: -------------------------------------------------------------------------------- 1 | try: 2 | from userbot.modules.sql_helper import SESSION, BASE 3 | except ImportError: 4 | raise AttributeError 5 | from sqlalchemy import Column, UnicodeText, Numeric, String 6 | 7 | 8 | class Filters(BASE): 9 | __tablename__ = "filters" 10 | chat_id = Column(String(14), primary_key=True) 11 | keyword = Column(UnicodeText, primary_key=True, nullable=False) 12 | reply = Column(UnicodeText) 13 | f_mesg_id = Column(Numeric) 14 | 15 | def __init__(self, chat_id, keyword, reply, f_mesg_id): 16 | self.chat_id = str(chat_id) 17 | self.keyword = keyword 18 | self.reply = reply 19 | self.f_mesg_id = f_mesg_id 20 | 21 | def __eq__(self, other): 22 | return bool( 23 | isinstance(other, Filters) and self.chat_id == other.chat_id 24 | and self.keyword == other.keyword) 25 | 26 | 27 | Filters.__table__.create(checkfirst=True) 28 | 29 | 30 | def get_filter(chat_id, keyword): 31 | try: 32 | return SESSION.query(Filters).get((str(chat_id), keyword)) 33 | finally: 34 | SESSION.close() 35 | 36 | 37 | def get_filters(chat_id): 38 | try: 39 | return SESSION.query(Filters).filter( 40 | Filters.chat_id == str(chat_id)).all() 41 | finally: 42 | SESSION.close() 43 | 44 | 45 | def add_filter(chat_id, keyword, reply, f_mesg_id): 46 | to_check = get_filter(chat_id, keyword) 47 | if not to_check: 48 | adder = Filters(str(chat_id), keyword, reply, f_mesg_id) 49 | SESSION.add(adder) 50 | SESSION.commit() 51 | return True 52 | else: 53 | rem = SESSION.query(Filters).get((str(chat_id), keyword)) 54 | SESSION.delete(rem) 55 | SESSION.commit() 56 | adder = Filters(str(chat_id), keyword, reply, f_mesg_id) 57 | SESSION.add(adder) 58 | SESSION.commit() 59 | return False 60 | 61 | 62 | def remove_filter(chat_id, keyword): 63 | to_check = get_filter(chat_id, keyword) 64 | if not to_check: 65 | return False 66 | else: 67 | rem = SESSION.query(Filters).get((str(chat_id), keyword)) 68 | SESSION.delete(rem) 69 | SESSION.commit() 70 | return True 71 | -------------------------------------------------------------------------------- /userbot/modules/sql_helper/galeri_sql.py: -------------------------------------------------------------------------------- 1 | import threading 2 | from sqlalchemy import func, distinct, Column, String, Integer, UnicodeText 3 | try: 4 | from userbot.modules.sql_helper import SESSION, BASE 5 | except ImportError: 6 | raise AttributeError 7 | 8 | 9 | class Galeri(BASE): 10 | __tablename__ = "galeri" 11 | 12 | g_id = Column(Integer, autoincrement=True, primary_key=True, nullable=False) 13 | foto = Column(UnicodeText, nullable=False) 14 | 15 | def __init__(self, foto): 16 | self.foto = foto 17 | 18 | def __repr__(self): 19 | return "" % (self.g_id, self.foto) 20 | 21 | def __eq__(self, other): 22 | return bool(isinstance(other, Galeri) 23 | and self.foto == other.foto 24 | and self.g_id == other.g_id) 25 | 26 | 27 | Galeri.__table__.create(checkfirst=True) 28 | 29 | KOMUT_INSERTION_LOCK = threading.RLock() 30 | TUM_GALERI = SESSION.query(Galeri).all() 31 | 32 | def ekle_foto(foto): 33 | with KOMUT_INSERTION_LOCK: 34 | try: 35 | SESSION.query(Galeri).filter(Galeri.foto == foto).delete() 36 | except: 37 | pass 38 | 39 | ekleme = Galeri(foto) 40 | SESSION.merge(ekleme) 41 | SESSION.commit() 42 | 43 | 44 | def getir_foto(): 45 | global TUM_GALERI 46 | TUM_GALERI = SESSION.query(Galeri).all() 47 | 48 | def sil_foto(gid): 49 | try: 50 | SESSION.query(Galeri).filter(Galeri.g_id == gid).delete() 51 | SESSION.commit() 52 | except Exception as e: 53 | return e 54 | return True 55 | -------------------------------------------------------------------------------- /userbot/modules/sql_helper/gban_sql.py: -------------------------------------------------------------------------------- 1 | try: 2 | from userbot.modules.sql_helper import SESSION, BASE 3 | except ImportError: 4 | raise AttributeError 5 | 6 | from sqlalchemy import Column, String, UnicodeText 7 | 8 | 9 | class GBan(BASE): 10 | __tablename__ = "gban" 11 | sender = Column(String(14), primary_key=True) 12 | 13 | def __init__(self, sender): 14 | self.sender = str(sender) 15 | 16 | 17 | GBan.__table__.create(checkfirst=True) 18 | 19 | 20 | def is_gbanned (sid): 21 | try: 22 | sonuc = SESSION.query(GBan).filter(GBan.sender == sid).first() 23 | return sonuc.sender 24 | except: 25 | return False 26 | 27 | def gbanlist(): 28 | try: 29 | return SESSION.query(GBan).all() 30 | except BaseException: 31 | return None 32 | finally: 33 | SESSION.close() 34 | 35 | 36 | def gban(sender): 37 | try: 38 | adder = GBan(str(sender)) 39 | SESSION.add(adder) 40 | SESSION.commit() 41 | except: 42 | return False 43 | 44 | 45 | def ungban(sender): 46 | rem = SESSION.query(GBan).get((str(sender))) 47 | if rem: 48 | SESSION.delete(rem) 49 | SESSION.commit() 50 | -------------------------------------------------------------------------------- /userbot/modules/sql_helper/globals.py: -------------------------------------------------------------------------------- 1 | try: 2 | from userbot.modules.sql_helper import SESSION, BASE 3 | except ImportError: 4 | raise AttributeError 5 | 6 | from sqlalchemy import Column, String, UnicodeText 7 | 8 | 9 | class Globals(BASE): 10 | __tablename__ = "globals" 11 | variable = Column(String, primary_key=True, nullable=False) 12 | value = Column(UnicodeText, primary_key=True, nullable=False) 13 | 14 | def __init__(self, variable, value): 15 | self.variable = str(variable) 16 | self.value = value 17 | 18 | 19 | Globals.__table__.create(checkfirst=True) 20 | 21 | 22 | def gvarstatus(variable): 23 | try: 24 | return SESSION.query(Globals).filter( 25 | Globals.variable == str(variable)).first().value 26 | except BaseException: 27 | return None 28 | finally: 29 | SESSION.close() 30 | 31 | 32 | def addgvar(variable, value): 33 | if SESSION.query(Globals).filter( 34 | Globals.variable == str(variable)).one_or_none(): 35 | delgvar(variable) 36 | adder = Globals(str(variable), value) 37 | SESSION.add(adder) 38 | SESSION.commit() 39 | 40 | 41 | def delgvar(variable): 42 | rem = SESSION.query(Globals).filter(Globals.variable == str(variable))\ 43 | .delete(synchronize_session="fetch") 44 | if rem: 45 | SESSION.commit() 46 | -------------------------------------------------------------------------------- /userbot/modules/sql_helper/gmute_sql.py: -------------------------------------------------------------------------------- 1 | try: 2 | from userbot.modules.sql_helper import SESSION, BASE 3 | except ImportError: 4 | raise AttributeError 5 | 6 | from sqlalchemy import Column, String, UnicodeText 7 | 8 | 9 | class GMute(BASE): 10 | __tablename__ = "gmute" 11 | sender = Column(String(14), primary_key=True) 12 | 13 | def __init__(self, sender): 14 | self.sender = str(sender) 15 | 16 | 17 | GMute.__table__.create(checkfirst=True) 18 | 19 | 20 | def is_gmuted(sender_id): 21 | try: 22 | return SESSION.query(GMute).filter(GMute.sender == str(sender_id)).all() 23 | except BaseException: 24 | return None 25 | finally: 26 | SESSION.close() 27 | 28 | def gmute(sender): 29 | adder = GMute(str(sender)) 30 | SESSION.add(adder) 31 | SESSION.commit() 32 | 33 | def gmutelist(): 34 | try: 35 | return SESSION.query(GMute).all() 36 | except BaseException: 37 | return None 38 | finally: 39 | SESSION.close() 40 | 41 | 42 | def ungmute(sender): 43 | rem = SESSION.query(GMute).get((str(sender))) 44 | if rem: 45 | SESSION.delete(rem) 46 | SESSION.commit() 47 | -------------------------------------------------------------------------------- /userbot/modules/sql_helper/goodbye_sql.py: -------------------------------------------------------------------------------- 1 | try: 2 | from userbot.modules.sql_helper import SESSION, BASE 3 | except ImportError: 4 | raise AttributeError 5 | 6 | from sqlalchemy import BigInteger, Column, Numeric, String, UnicodeText 7 | 8 | 9 | class Goodbye(BASE): 10 | __tablename__ = "goodbye" 11 | chat_id = Column(String(14), primary_key=True) 12 | previous_goodbye = Column(BigInteger) 13 | reply = Column(UnicodeText) 14 | f_mesg_id = Column(Numeric) 15 | 16 | def __init__(self, chat_id, previous_goodbye, reply, f_mesg_id): 17 | self.chat_id = str(chat_id) 18 | self.previous_goodbye = previous_goodbye 19 | self.reply = reply 20 | self.f_mesg_id = f_mesg_id 21 | 22 | 23 | Goodbye.__table__.create(checkfirst=True) 24 | 25 | 26 | def get_goodbye(chat_id): 27 | try: 28 | return SESSION.query(Goodbye).get(str(chat_id)) 29 | finally: 30 | SESSION.close() 31 | 32 | 33 | def get_current_goodbye_settings(chat_id): 34 | try: 35 | return SESSION.query(Goodbye).filter( 36 | Goodbye.chat_id == str(chat_id)).one() 37 | except BaseException: 38 | return None 39 | finally: 40 | SESSION.close() 41 | 42 | 43 | def add_goodbye_setting(chat_id, previous_goodbye, reply, f_mesg_id): 44 | to_check = get_goodbye(chat_id) 45 | if not to_check: 46 | adder = Goodbye(chat_id, previous_goodbye, reply, f_mesg_id) 47 | SESSION.add(adder) 48 | SESSION.commit() 49 | return True 50 | else: 51 | rem = SESSION.query(Goodbye).get(str(chat_id)) 52 | SESSION.delete(rem) 53 | SESSION.commit() 54 | adder = Goodbye(chat_id, previous_goodbye, reply, f_mesg_id) 55 | SESSION.commit() 56 | return False 57 | 58 | 59 | def rm_goodbye_setting(chat_id): 60 | try: 61 | rem = SESSION.query(Goodbye).get(str(chat_id)) 62 | if rem: 63 | SESSION.delete(rem) 64 | SESSION.commit() 65 | return True 66 | except BaseException: 67 | return False 68 | 69 | 70 | def update_previous_goodbye(chat_id, previous_goodbye): 71 | row = SESSION.query(Goodbye).get(str(chat_id)) 72 | row.previous_goodbye = previous_goodbye 73 | SESSION.commit() 74 | -------------------------------------------------------------------------------- /userbot/modules/sql_helper/keep_read_sql.py: -------------------------------------------------------------------------------- 1 | try: 2 | from userbot.modules.sql_helper import SESSION, BASE 3 | except ImportError: 4 | raise AttributeError 5 | 6 | from sqlalchemy import Column, String 7 | 8 | 9 | class KRead(BASE): 10 | __tablename__ = "kread" 11 | groupid = Column(String(14), primary_key=True) 12 | 13 | def __init__(self, sender): 14 | self.groupid = str(sender) 15 | 16 | 17 | KRead.__table__.create(checkfirst=True) 18 | 19 | 20 | def is_kread(): 21 | try: 22 | return SESSION.query(KRead).all() 23 | except BaseException: 24 | return None 25 | finally: 26 | SESSION.close() 27 | 28 | 29 | def kread(chat): 30 | adder = KRead(str(chat)) 31 | SESSION.add(adder) 32 | SESSION.commit() 33 | 34 | 35 | def unkread(chat): 36 | rem = SESSION.query(KRead).get((str(chat))) 37 | if rem: 38 | SESSION.delete(rem) 39 | SESSION.commit() 40 | -------------------------------------------------------------------------------- /userbot/modules/sql_helper/lydia_sql.py: -------------------------------------------------------------------------------- 1 | from sqlalchemy import Column, UnicodeText, LargeBinary, Numeric 2 | from userbot.modules.sql_helper import SESSION, BASE 3 | 4 | 5 | class LydiaAI(BASE): 6 | __tablename__ = "lydia_ai" 7 | user_id = Column(Numeric, primary_key=True) 8 | chat_id = Column(Numeric, primary_key=True) 9 | session_id = Column(UnicodeText) 10 | session_expires = Column(Numeric) 11 | 12 | def __init__( 13 | self, 14 | user_id, 15 | chat_id, 16 | session_id, 17 | session_expires 18 | ): 19 | self.user_id = user_id 20 | self.chat_id = chat_id 21 | self.session_id = session_id 22 | self.session_expires = session_expires 23 | 24 | 25 | LydiaAI.__table__.create(checkfirst=True) 26 | 27 | 28 | def get_s(user_id, chat_id): 29 | try: 30 | return SESSION.query(LydiaAI).get((user_id, chat_id)) 31 | except: 32 | return None 33 | finally: 34 | SESSION.close() 35 | 36 | 37 | def get_all_s(): 38 | try: 39 | return SESSION.query(LydiaAI).all() 40 | except: 41 | return None 42 | finally: 43 | SESSION.close() 44 | 45 | 46 | def add_s( 47 | user_id, 48 | chat_id, 49 | session_id, 50 | session_expires 51 | ): 52 | adder = SESSION.query(LydiaAI).get((user_id, chat_id)) 53 | if adder: 54 | adder.session_id = session_id 55 | adder.session_expires = session_expires 56 | else: 57 | adder = LydiaAI( 58 | user_id, 59 | chat_id, 60 | session_id, 61 | session_expires 62 | ) 63 | SESSION.add(adder) 64 | SESSION.commit() 65 | 66 | 67 | def remove_s( 68 | user_id, 69 | chat_id 70 | ): 71 | note = SESSION.query(LydiaAI).get((user_id, chat_id)) 72 | if note: 73 | SESSION.delete(note) 74 | SESSION.commit() 75 | -------------------------------------------------------------------------------- /userbot/modules/sql_helper/mesaj_sql.py: -------------------------------------------------------------------------------- 1 | import threading 2 | from sqlalchemy import func, distinct, Column, String, UnicodeText 3 | try: 4 | from userbot.modules.sql_helper import SESSION, BASE 5 | except ImportError: 6 | raise AttributeError 7 | 8 | 9 | class Mesajlar(BASE): 10 | __tablename__ = "mesaj" 11 | komut = Column(UnicodeText, primary_key=True, nullable=False) 12 | mesaj = Column(UnicodeText, primary_key=True, nullable=False) 13 | 14 | def __init__(self, komut, mesaj): 15 | self.komut = komut # ensure string 16 | self.mesaj = mesaj 17 | 18 | def __repr__(self): 19 | return "" % (self.komut, self.mesaj) 20 | 21 | def __eq__(self, other): 22 | return bool(isinstance(other, Mesajlar) 23 | and self.komut == other.komut 24 | and self.mesaj == other.mesaj) 25 | 26 | 27 | Mesajlar.__table__.create(checkfirst=True) 28 | 29 | KOMUT_INSERTION_LOCK = threading.RLock() 30 | 31 | def ekle_mesaj(komut, mesaj): 32 | with KOMUT_INSERTION_LOCK: 33 | try: 34 | SESSION.query(Mesajlar).filter(Mesajlar.komut == komut).delete() 35 | except: 36 | pass 37 | 38 | komut = Mesajlar(komut, mesaj) 39 | SESSION.merge(komut) 40 | SESSION.commit() 41 | 42 | 43 | def getir_mesaj(komu): 44 | try: 45 | MESAJ = SESSION.query(Mesajlar).filter(Mesajlar.komut == komu).first() 46 | return MESAJ.mesaj 47 | except: 48 | return False 49 | 50 | 51 | def sil_mesaj(komu): 52 | try: 53 | SESSION.query(Mesajlar).filter(Mesajlar.komut == komu).delete() 54 | SESSION.commit() 55 | except Exception as e: 56 | return e 57 | return True 58 | -------------------------------------------------------------------------------- /userbot/modules/sql_helper/notes_sql.py: -------------------------------------------------------------------------------- 1 | try: 2 | from userbot.modules.sql_helper import SESSION, BASE 3 | except ImportError: 4 | raise AttributeError 5 | from sqlalchemy import Column, UnicodeText, Numeric, String 6 | 7 | 8 | class Notes(BASE): 9 | __tablename__ = "notes" 10 | chat_id = Column(String(14), primary_key=True) 11 | keyword = Column(UnicodeText, primary_key=True, nullable=False) 12 | reply = Column(UnicodeText) 13 | f_mesg_id = Column(Numeric) 14 | 15 | def __init__(self, chat_id, keyword, reply, f_mesg_id): 16 | self.chat_id = str(chat_id) 17 | self.keyword = keyword 18 | self.reply = reply 19 | self.f_mesg_id = f_mesg_id 20 | 21 | 22 | Notes.__table__.create(checkfirst=True) 23 | 24 | 25 | def get_note(chat_id, keyword): 26 | try: 27 | return SESSION.query(Notes).get((str(chat_id), keyword)) 28 | finally: 29 | SESSION.close() 30 | 31 | 32 | def get_notes(chat_id): 33 | try: 34 | return SESSION.query(Notes).filter(Notes.chat_id == str(chat_id)).all() 35 | finally: 36 | SESSION.close() 37 | 38 | 39 | def add_note(chat_id, keyword, reply, f_mesg_id): 40 | to_check = get_note(chat_id, keyword) 41 | if not to_check: 42 | adder = Notes(str(chat_id), keyword, reply, f_mesg_id) 43 | SESSION.add(adder) 44 | SESSION.commit() 45 | return True 46 | else: 47 | rem = SESSION.query(Notes).get((str(chat_id), keyword)) 48 | SESSION.delete(rem) 49 | SESSION.commit() 50 | adder = Notes(str(chat_id), keyword, reply, f_mesg_id) 51 | SESSION.add(adder) 52 | SESSION.commit() 53 | return False 54 | 55 | 56 | def rm_note(chat_id, keyword): 57 | to_check = get_note(chat_id, keyword) 58 | if not to_check: 59 | return False 60 | else: 61 | rem = SESSION.query(Notes).get((str(chat_id), keyword)) 62 | SESSION.delete(rem) 63 | SESSION.commit() 64 | return True 65 | -------------------------------------------------------------------------------- /userbot/modules/sql_helper/pm_permit_sql.py: -------------------------------------------------------------------------------- 1 | try: 2 | from userbot.modules.sql_helper import SESSION, BASE 3 | except ImportError: 4 | raise AttributeError 5 | from sqlalchemy import Column, String, UnicodeText, Boolean, Integer, distinct, func 6 | 7 | 8 | class PMPermit(BASE): 9 | __tablename__ = "pmpermit" 10 | chat_id = Column(String(14), primary_key=True) 11 | 12 | def __init__(self, chat_id): 13 | self.chat_id = str(chat_id) # ensure string 14 | 15 | 16 | PMPermit.__table__.create(checkfirst=True) 17 | 18 | 19 | def is_approved(chat_id): 20 | try: 21 | return SESSION.query(PMPermit).filter( 22 | PMPermit.chat_id == str(chat_id)).one() 23 | except BaseException: 24 | return None 25 | finally: 26 | SESSION.close() 27 | 28 | 29 | def approve(chat_id): 30 | adder = PMPermit(str(chat_id)) 31 | SESSION.add(adder) 32 | SESSION.commit() 33 | 34 | 35 | def dissprove(chat_id): 36 | rem = SESSION.query(PMPermit).get(str(chat_id)) 37 | if rem: 38 | SESSION.delete(rem) 39 | SESSION.commit() 40 | -------------------------------------------------------------------------------- /userbot/modules/sql_helper/quick_phrases_sql.py: -------------------------------------------------------------------------------- 1 | try: 2 | from userbot.modules.sql_helper import SESSION, BASE 3 | except ImportError: 4 | raise AttributeError 5 | 6 | from sqlalchemy import Column, String, UnicodeText 7 | 8 | 9 | class QuickPhrase(BASE): 10 | __tablename__ = "quickphrases" 11 | resp = Column(String(10), primary_key=True) 12 | phrase = Column(UnicodeText, primary_key=True) 13 | 14 | def __init__(self, resp, phrase): 15 | self.phrase = str(phrase) 16 | self.resp = str(resp) 17 | 18 | 19 | QuickPhrase.__table__.create(checkfirst=True) 20 | 21 | 22 | def get_phrases(resp): 23 | try: 24 | return SESSION.query(QuickPhrase).filter(QuickPhrase.resp == str(resp)).all() 25 | finally: 26 | SESSION.close() 27 | 28 | 29 | def add_phrase(resp, phrase): 30 | adder = QuickPhrase(str(resp), phrase) 31 | SESSION.add(adder) 32 | SESSION.commit() 33 | 34 | 35 | def remove_phrase(resp, phrase): 36 | rem = SESSION.query(QuickPhrase).get((str(resp),str(phrase))) 37 | if rem: 38 | SESSION.delete(rem) 39 | SESSION.commit() 40 | -------------------------------------------------------------------------------- /userbot/modules/sql_helper/snips_sql.py: -------------------------------------------------------------------------------- 1 | try: 2 | from userbot.modules.sql_helper import SESSION, BASE 3 | except ImportError: 4 | raise AttributeError 5 | 6 | from sqlalchemy import Column, UnicodeText, LargeBinary, Numeric 7 | 8 | 9 | class Snips(BASE): 10 | __tablename__ = "snips" 11 | snip = Column(UnicodeText, primary_key=True) 12 | reply = Column(UnicodeText) 13 | f_mesg_id = Column(Numeric) 14 | 15 | def __init__(self, snip, reply, f_mesg_id): 16 | self.snip = snip 17 | self.reply = reply 18 | self.f_mesg_id = f_mesg_id 19 | 20 | 21 | Snips.__table__.create(checkfirst=True) 22 | 23 | 24 | def get_snip(keyword): 25 | try: 26 | return SESSION.query(Snips).get(keyword) 27 | finally: 28 | SESSION.close() 29 | 30 | 31 | def get_snips(): 32 | try: 33 | return SESSION.query(Snips).all() 34 | finally: 35 | SESSION.close() 36 | 37 | 38 | def add_snip(keyword, reply, f_mesg_id): 39 | to_check = get_snip(keyword) 40 | if not to_check: 41 | adder = Snips(keyword, reply, f_mesg_id) 42 | SESSION.add(adder) 43 | SESSION.commit() 44 | return True 45 | else: 46 | rem = SESSION.query(Snips).filter(Snips.snip == keyword) 47 | SESSION.delete(rem) 48 | SESSION.commit() 49 | adder = Snips(keyword, reply, f_mesg_id) 50 | SESSION.add(adder) 51 | SESSION.commit() 52 | return False 53 | 54 | 55 | def remove_snip(keyword): 56 | to_check = get_snip(keyword) 57 | if not to_check: 58 | return False 59 | else: 60 | rem = SESSION.query(Snips).filter(Snips.snip == keyword) 61 | rem.delete() 62 | SESSION.commit() 63 | return True 64 | -------------------------------------------------------------------------------- /userbot/modules/sql_helper/spam_mute_sql.py: -------------------------------------------------------------------------------- 1 | try: 2 | from userbot.modules.sql_helper import SESSION, BASE 3 | except ImportError: 4 | raise AttributeError 5 | 6 | from sqlalchemy import Column, String 7 | 8 | 9 | class Mute(BASE): 10 | __tablename__ = "muted" 11 | chat_id = Column(String(14), primary_key=True) 12 | sender = Column(String(14), primary_key=True) 13 | 14 | def __init__(self, chat_id, sender): 15 | self.chat_id = str(chat_id) # ensure string 16 | self.sender = str(sender) 17 | 18 | 19 | Mute.__table__.create(checkfirst=True) 20 | 21 | 22 | def is_muted(chat_id): 23 | try: 24 | return SESSION.query(Mute).filter(Mute.chat_id == str(chat_id)).all() 25 | except BaseException: 26 | return None 27 | finally: 28 | SESSION.close() 29 | 30 | 31 | def mute(chat_id, sender): 32 | adder = Mute(str(chat_id), str(sender)) 33 | SESSION.add(adder) 34 | SESSION.commit() 35 | 36 | 37 | def unmute(chat_id, sender): 38 | rem = SESSION.query(Mute).get(((str(chat_id)), (str(sender)))) 39 | if rem: 40 | SESSION.delete(rem) 41 | SESSION.commit() 42 | -------------------------------------------------------------------------------- /userbot/modules/sql_helper/warn_sql.py: -------------------------------------------------------------------------------- 1 | # WARN PLUGIN # 2 | # CODED BY YUSUF USTA # 3 | 4 | import threading 5 | from sqlalchemy import func, distinct, Column, String, UnicodeText, Integer 6 | try: 7 | from userbot.modules.sql_helper import SESSION, BASE 8 | except ImportError: 9 | raise AttributeError 10 | 11 | 12 | class Warns(BASE): 13 | __tablename__ = "warns" 14 | user_id = Column(Integer, primary_key=True) 15 | num_warn = Column(Integer, default=0) 16 | 17 | def __init__(self, user_id, num_warn): 18 | self.user_id = user_id # ensure string 19 | self.num_warn = num_warn 20 | 21 | def __repr__(self): 22 | return "" % (self.uid, self.warn) 23 | 24 | def __eq__(self, other): 25 | return bool(isinstance(other, Warns) 26 | and self.user_id == other.user_id 27 | and self.num_warn == other.num_warn) 28 | 29 | 30 | Warns.__table__.create(checkfirst=True) 31 | 32 | KOMUT_INSERTION_LOCK = threading.RLock() 33 | 34 | def ekle_warn(userid): 35 | with KOMUT_INSERTION_LOCK: 36 | try: 37 | UYARI = SESSION.query(Warns).filter(Warns.user_id == userid).first() 38 | wsayi = int(UYARI.num_warn) 39 | SESSION.query(Warns).filter(Warns.user_id == userid).delete() 40 | except: 41 | wsayi = 0 42 | 43 | wsayi += 1 44 | komut = Warns(userid, wsayi) 45 | SESSION.merge(komut) 46 | SESSION.commit() 47 | 48 | def getir_warn(userid): 49 | try: 50 | UYARI = SESSION.query(Warns).filter(Warns.user_id == userid).first() 51 | return UYARI.num_warn 52 | except: 53 | return 0 54 | 55 | 56 | def sil_warn(userid): 57 | try: 58 | wsayi = SESSION.query(Warns).filter(Warns.user_id == userid).first().num_warn 59 | if wsayi == 0: 60 | return False 61 | nsayi = wsayi - 1 62 | SESSION.query(Warns).filter(Warns.user_id == userid).delete() 63 | 64 | uyari = Warns(userid, nsayi) 65 | SESSION.merge(uyari) 66 | SESSION.commit() 67 | return True 68 | except: 69 | return False 70 | return True 71 | 72 | def toplu_sil_warn(userid): 73 | try: 74 | uyari = Warns(userid, 0) 75 | SESSION.merge(uyari) 76 | SESSION.commit() 77 | except: 78 | return False 79 | return True 80 | -------------------------------------------------------------------------------- /userbot/modules/sql_helper/welcome_sql.py: -------------------------------------------------------------------------------- 1 | try: 2 | from userbot.modules.sql_helper import SESSION, BASE 3 | except ImportError: 4 | raise AttributeError 5 | 6 | from sqlalchemy import BigInteger, Column, Numeric, String, UnicodeText 7 | 8 | 9 | class Welcome(BASE): 10 | __tablename__ = "welcome" 11 | chat_id = Column(String(14), primary_key=True) 12 | previous_welcome = Column(BigInteger) 13 | reply = Column(UnicodeText) 14 | f_mesg_id = Column(Numeric) 15 | 16 | def __init__(self, chat_id, previous_welcome, reply, f_mesg_id): 17 | self.chat_id = str(chat_id) 18 | self.previous_welcome = previous_welcome 19 | self.reply = reply 20 | self.f_mesg_id = f_mesg_id 21 | 22 | 23 | Welcome.__table__.create(checkfirst=True) 24 | 25 | 26 | def get_welcome(chat_id): 27 | try: 28 | return SESSION.query(Welcome).get(str(chat_id)) 29 | finally: 30 | SESSION.close() 31 | 32 | 33 | def get_current_welcome_settings(chat_id): 34 | try: 35 | return SESSION.query(Welcome).filter( 36 | Welcome.chat_id == str(chat_id)).one() 37 | except BaseException: 38 | return None 39 | finally: 40 | SESSION.close() 41 | 42 | 43 | def add_welcome_setting(chat_id, previous_welcome, reply, f_mesg_id): 44 | to_check = get_welcome(chat_id) 45 | if not to_check: 46 | adder = Welcome(chat_id, previous_welcome, reply, f_mesg_id) 47 | SESSION.add(adder) 48 | SESSION.commit() 49 | return True 50 | else: 51 | rem = SESSION.query(Welcome).get(str(chat_id)) 52 | SESSION.delete(rem) 53 | SESSION.commit() 54 | adder = Welcome(chat_id, previous_welcome, reply, f_mesg_id) 55 | SESSION.commit() 56 | return False 57 | 58 | 59 | def rm_welcome_setting(chat_id): 60 | try: 61 | rem = SESSION.query(Welcome).get(str(chat_id)) 62 | if rem: 63 | SESSION.delete(rem) 64 | SESSION.commit() 65 | return True 66 | except BaseException: 67 | return False 68 | 69 | 70 | def update_previous_welcome(chat_id, previous_welcome): 71 | row = SESSION.query(Welcome).get(str(chat_id)) 72 | row.previous_welcome = previous_welcome 73 | SESSION.commit() 74 | -------------------------------------------------------------------------------- /userbot/modules/tagall.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2019 The Raphielscape Company LLC. 2 | # 3 | # Licensed under the Raphielscape Public License, Version 1.c (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # 6 | 7 | # Asena UserBot - Yusuf Usta 8 | 9 | # @NaytSeyd tarafından portlanmıştır. 10 | # 11 | 12 | from telethon.tl.types import ChannelParticipantsAdmins 13 | from userbot import CMD_HELP, bot 14 | from userbot.events import register 15 | from userbot.cmdhelp import CmdHelp 16 | 17 | @register(outgoing=True, pattern="^.tagall$") 18 | async def _(event): 19 | if event.fwd_from: 20 | return 21 | mentions = "@tag" 22 | chat = await event.get_input_chat() 23 | leng = 0 24 | async for x in bot.iter_participants(chat): 25 | if leng < 4092: 26 | mentions += f"[\u2063](tg://user?id={x.id})" 27 | leng += 1 28 | await event.reply(mentions) 29 | await event.delete() 30 | 31 | @register(outgoing=True, pattern="^.admin") 32 | async def _(event): 33 | if event.fwd_from: 34 | return 35 | mentions = "@admin" 36 | chat = await event.get_input_chat() 37 | async for x in bot.iter_participants(chat, filter=ChannelParticipantsAdmins): 38 | mentions += f"[\u2063](tg://user?id={x.id})" 39 | reply_message = None 40 | if event.reply_to_msg_id: 41 | reply_message = await event.get_reply_message() 42 | await reply_message.reply(mentions) 43 | else: 44 | await event.reply(mentions) 45 | await event.delete() 46 | 47 | CmdHelp('tagall').add_command( 48 | 'tagall', None, 'Bu komutu kullandığınızda sohbet içerisinde ki herkesi etiketler.' 49 | ).add_command( 50 | 'admin', None, 'Bu komutu kullandığınızda sohbet içerisinde ki yöneticileri etiketler.' 51 | ).add() -------------------------------------------------------------------------------- /userbot/modules/weather.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2019 The Raphielscape Company LLC. 2 | # 3 | # Licensed under the Raphielscape Public License, Version 1.c (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # 6 | 7 | # Asena UserBot - Yusuf Usta 8 | 9 | 10 | """Bir bölgenin hava durumunu gösterir.""" 11 | 12 | import json 13 | from requests import get 14 | from datetime import datetime 15 | from pytz import country_timezones as c_tz 16 | from pytz import timezone as tz 17 | from pytz import country_names as c_n 18 | 19 | from userbot import CMD_HELP, WEATHER_DEFCITY 20 | from userbot import OPEN_WEATHER_MAP_APPID as OWM_API 21 | from userbot.events import register 22 | from userbot.cmdhelp import CmdHelp 23 | 24 | # ===== CONSTANT ===== 25 | # ██████ LANGUAGE CONSTANTS ██████ # 26 | 27 | from userbot.language import (get_value, LANGUAGE_JSON) 28 | LANG = get_value("weather") 29 | 30 | # ████████████████████████████████ # 31 | 32 | if WEATHER_DEFCITY: 33 | DEFCITY = WEATHER_DEFCITY 34 | else: 35 | DEFCITY = None 36 | # ==================== 37 | 38 | 39 | async def get_tz(con): 40 | """ Verilen ülkenin zaman dilimini alır. """ 41 | """ @aragon12 ve @zakaryan2004'e teşekkürler. """ 42 | for c_code in c_n: 43 | if con == c_n[c_code]: 44 | return tz(c_tz[c_code][0]) 45 | try: 46 | if c_n[con]: 47 | return tz(c_tz[con][0]) 48 | except KeyError: 49 | return 50 | 51 | 52 | @register(outgoing=True, pattern="^.weather(?: |$)(.*)") 53 | async def get_weather(weather): 54 | """ .weather komutu bir bölgenin hava durumunu OpenWeatherMap üzerinden alır. """ 55 | 56 | if not OWM_API: 57 | await weather.edit( 58 | LANG['NEED_API_KEY']) 59 | return 60 | 61 | APPID = OWM_API 62 | 63 | if not weather.pattern_match.group(1): 64 | CITY = DEFCITY 65 | if not CITY: 66 | await weather.edit( 67 | LANG['NO_CITY'] 68 | ) 69 | return 70 | else: 71 | CITY = weather.pattern_match.group(1) 72 | 73 | timezone_countries = { 74 | timezone: country 75 | for country, timezones in c_tz.items() for timezone in timezones 76 | } 77 | 78 | if "," in CITY: 79 | newcity = CITY.split(",") 80 | if len(newcity[1]) == 2: 81 | CITY = newcity[0].strip() + "," + newcity[1].strip() 82 | else: 83 | country = await get_tz((newcity[1].strip()).title()) 84 | try: 85 | countrycode = timezone_countries[f'{country}'] 86 | except KeyError: 87 | await weather.edit(LANG['INVALID_COUNTRY']) 88 | return 89 | CITY = newcity[0].strip() + "," + countrycode.strip() 90 | 91 | url = f'https://api.openweathermap.org/data/2.5/weather?q={CITY}&appid={APPID}&lang={LANGUAGE_JSON["LANGCODE"]}' 92 | request = get(url) 93 | result = json.loads(request.text) 94 | 95 | if request.status_code != 200: 96 | await weather.edit(LANG['INVALID_COUNTRY']) 97 | return 98 | 99 | cityname = result['name'] 100 | curtemp = result['main']['temp'] 101 | humidity = result['main']['humidity'] 102 | min_temp = result['main']['temp_min'] 103 | max_temp = result['main']['temp_max'] 104 | desc = result['weather'][0] 105 | if "description" in desc and len(desc['description']) > 0: 106 | desc = desc['description'] 107 | else: 108 | desc = desc['main'] 109 | country = result['sys']['country'] 110 | sunrise = result['sys']['sunrise'] 111 | sunset = result['sys']['sunset'] 112 | wind = result['wind']['speed'] 113 | winddir = result['wind']['deg'] 114 | 115 | ctimezone = tz(c_tz[country][0]) 116 | time = datetime.now(ctimezone).strftime("%A, %I:%M %p") 117 | fullc_n = c_n[f"{country}"] 118 | 119 | dirs = ["N", "NE", "E", "SE", "S", "SW", "W", "NW"] 120 | 121 | div = (360 / len(dirs)) 122 | funmath = int((winddir + (div / 2)) / div) 123 | findir = dirs[funmath % len(dirs)] 124 | kmph = str(wind * 3.6).split(".") 125 | mph = str(wind * 2.237).split(".") 126 | 127 | def fahrenheit(f): 128 | temp = str(((f - 273.15) * 9 / 5 + 32)).split(".") 129 | return temp[0] 130 | 131 | def celsius(c): 132 | temp = str((c - 273.15)).split(".") 133 | return temp[0] 134 | 135 | def sun(unix): 136 | xx = datetime.fromtimestamp(unix, tz=ctimezone).strftime("%I:%M %p") 137 | return xx 138 | 139 | await weather.edit( 140 | f"**{LANG['TEMP']}:** `{celsius(curtemp)}°C | {fahrenheit(curtemp)}°F`\n" 141 | + 142 | f"**{LANG['MIN_TEMP']}:** `{celsius(min_temp)}°C | {fahrenheit(min_temp)}°F`\n" 143 | + 144 | f"**{LANG['MAX_TEMP']}:** `{celsius(max_temp)}°C | {fahrenheit(max_temp)}°F`\n" 145 | + f"**{LANG['HUMIDITY']}:** `{humidity}%`\n" + 146 | f"**{LANG['WIND_SPEED']}:** `{kmph[0]} kmh | {mph[0]} mph, {findir}`\n" + 147 | f"**{LANG['SUNRISE']}:** `{sun(sunrise)}`\n" + 148 | f"**{LANG['SUNSET']}:** `{sun(sunset)}`\n\n" + f"**{desc}**\n" + 149 | f"`{cityname}, {fullc_n}`\n" + f"`{time}`") 150 | 151 | CmdHelp('weather').add_command( 152 | 'weather', '<şehir>', 'Bir bölgenin hava durumunu verir.' 153 | ).add() -------------------------------------------------------------------------------- /userbot/modules/www.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2019 The Raphielscape Company LLC. 2 | # 3 | # Licensed under the Raphielscape Public License, Version 1.c (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # 6 | 7 | # Asena UserBot - Yusuf Usta 8 | 9 | 10 | """ Internet ile alakalı bilgileri edinmek için kullanılan UserBot modülüdür. """ 11 | 12 | from datetime import datetime 13 | 14 | import speedtest 15 | from telethon import functions 16 | from userbot import CMD_HELP 17 | from userbot.events import register 18 | from userbot.cmdhelp import CmdHelp 19 | 20 | # ██████ LANGUAGE CONSTANTS ██████ # 21 | 22 | from userbot.language import get_value 23 | LANG = get_value("www") 24 | 25 | # ████████████████████████████████ # 26 | 27 | @register(outgoing=True, pattern="^.speed$") 28 | async def speedtst(spd): 29 | """ .speed komutu sunucu hızını tespit etmek için SpeedTest kullanır. """ 30 | await spd.edit(LANG['SPEED']) 31 | test = speedtest.Speedtest() 32 | 33 | test.get_best_server() 34 | test.download() 35 | test.upload() 36 | result = test.results.dict() 37 | 38 | await spd.edit("`" 39 | f"{LANG['STARTED_TIME']}" 40 | f"{result['timestamp']} \n\n" 41 | f"{LANG['DOWNLOAD_SPEED']}" 42 | f"{speed_convert(result['download'])} \n" 43 | f"{LANG['UPLOAD_SPEED']}" 44 | f"{speed_convert(result['upload'])} \n" 45 | "Ping: " 46 | f"{result['ping']} \n" 47 | f"{LANG['ISP']}" 48 | f"{result['client']['isp']}" 49 | "`") 50 | 51 | 52 | def speed_convert(size): 53 | """ 54 | Merhaba Asena, baytları okuyamıyor musun? 55 | """ 56 | power = 2**10 57 | zero = 0 58 | units = {0: '', 1: 'Kb/s', 2: 'Mb/s', 3: 'Gb/s', 4: 'Tb/s'} 59 | while size > power: 60 | size /= power 61 | zero += 1 62 | return f"{round(size, 2)} {units[zero]}" 63 | 64 | 65 | @register(outgoing=True, pattern="^.dc$") 66 | async def neardc(event): 67 | """ .dc komutu en yakın datacenter bilgisini verir. """ 68 | result = await event.client(functions.help.GetNearestDcRequest()) 69 | await event.edit(f"Şehir : `{result.country}`\n" 70 | f"En yakın datacenter : `{result.nearest_dc}`\n" 71 | f"Şu anki datacenter : `{result.this_dc}`") 72 | 73 | 74 | @register(outgoing=True, pattern="^.ping$") 75 | async def pingme(pong): 76 | """ .ping komutu userbotun ping değerini herhangi bir sohbette gösterebilir. """ 77 | start = datetime.now() 78 | await pong.edit("`Pong!`") 79 | end = datetime.now() 80 | duration = (end - start).microseconds / 1000 81 | await pong.edit("`Pong!\n%sms`" % (duration)) 82 | 83 | CmdHelp('www').add_command( 84 | 'speed', None, 'Bir speedtest uygular ve sonucu gösterir.' 85 | ).add_command( 86 | 'dc', None, 'Sunucunuza en yakın datacenter\'ı gösterir.' 87 | ).add_command( 88 | 'ping', None, 'Botun ping değerini gösterir.' 89 | ).add() -------------------------------------------------------------------------------- /windows_startup_script.py: -------------------------------------------------------------------------------- 1 | from telethon import TelegramClient 2 | API_KEY="Bunu buraya yazın" 3 | API_HASH="Bunu buraya yazın" 4 | #my.telegram.org adresinden alın 5 | bot = TelegramClient('userbot',API_KEY,API_HASH) 6 | bot.start() 7 | 8 | #Bu komut dosyası botunuzu çalıştırmaz, sadece bir oturum oluşturur. 9 | --------------------------------------------------------------------------------