├── README.md ├── telebot_advance-main ├── README.md └── main.py └── LICENSE /README.md: -------------------------------------------------------------------------------- 1 | # TelebotAdvance -------------------------------------------------------------------------------- /telebot_advance-main/README.md: -------------------------------------------------------------------------------- 1 | # telebot_advance -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 mahdieslaminet 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /telebot_advance-main/main.py: -------------------------------------------------------------------------------- 1 | import json 2 | import requests 3 | 4 | def exist(x, y): 5 | return x.count(y) - 1 6 | 7 | def sendphoto(id, photo): 8 | api_token = "YOUR_API_TOKEN" # Replace with your actual API token 9 | url = f"https://api.telegram.org/bot{api_token}/sendPhoto" 10 | data = { 11 | "chat_id": id, 12 | "photo": photo 13 | } 14 | response = requests.get(url, params=data) 15 | 16 | def sender(id, message, keyboard): 17 | api_token = "YOUR_API_TOKEN" # Replace with your actual API token 18 | url = f"https://api.telegram.org/bot{api_token}/sendmessage" 19 | data = { 20 | "chat_id": id, 21 | "text": message, 22 | "reply_markup": json.dumps({"inline_keyboard": keyboard}) 23 | } 24 | response = requests.get(url, params=data) 25 | 26 | data = input() 27 | 28 | with open('exam.json', 'w') as file: 29 | file.write(data) 30 | 31 | datacod = json.loads(data) 32 | 33 | if "callback_query" in data: 34 | id = datacod["callback_query"]["from"]["id"] 35 | callback = datacod["callback_query"]["data"] 36 | photo_url = f"https://server.com/bots/img/{callback}.jpg" 37 | sendphoto(id, photo_url) 38 | else: 39 | id = datacod["message"]["from"]["id"] 40 | message = datacod["message"]["text"] 41 | text = "با درود. جهت ثبت نام در کلاس های مورد نظر عدد مربوطه را انتخاب کنید" 42 | keyboard = [ 43 | [ 44 | {"text": "مشاهده دوره های آموزشی", "callback_data": '1'}, 45 | {"text": "ثبت نام در دوره آموزشی", "callback_data": '2'} 46 | ], 47 | [ 48 | {"text": "لغو ثبت نام", "callback_data": '3'}, 49 | {"text": "لغو ثبت نام", "callback_data": '4'} 50 | ], 51 | [ 52 | {"text": "ثبت نام تست آزمون", "callback_data": '5'}, 53 | {"text": "ثبت نام کارگاه", "callback_data": '6'} 54 | ] 55 | ] 56 | sender(id, text, keyboard) 57 | --------------------------------------------------------------------------------