import telebot
from pathlib import Path
import os
import datetime
import time
from docx2pdf import convert
from random import randint
from docxtpl import DocxTemplate
today = datetime.datetime.today()
today = today.strftime("%d.%m.%Y")
document_path = Path(__file__).parent / "olinmasin.docx"
doc = DocxTemplate(document_path)
bot = telebot.TeleBot("5889042982:AAFmpFq8xtH9r2ZTH21Sq3MPJEQwVns0Wyk")
channel_id = "@testinformation2023"
@bot.message_handler(commands=['start'])
def start_message(message):
    bot.delete_message(message.chat.id, message.message_id)
    global m
    global d
    with open("xulosa.jpg", "rb")as f:
        m = bot.send_photo(message.chat.id, f, caption=f"🇺🇿 <b>Ассалому алайкум!</b> <i>Коррупцион холат бўйича мурожаат қолдириш учун қуйидаги саволларга жавоб беринг</i>\n----------------------------------------------------------------\n🇷🇺 <b>Здравствуйте!</b> <i>Пожалуйста, напишите заявление по делу о коррупции</i>", parse_mode="HTML")
    with open("phone.jpg", "rb")as f:
        d = bot.send_photo(message.chat.id, f, caption=f"🇺🇿 <b>Телефон рақамингизни киритинг</b>\n--------------------------------------------------------------------------------\n🇷🇺 <b>Введите номер телефона</b>:", parse_mode="HTML")
    bot.register_next_step_handler(message, get_phone)
def get_phone(message):
    bot.delete_message(message.chat.id, message.message_id)
    bot.delete_message(message.chat.id, m.id)
    bot.delete_message(message.chat.id, d.id)
    global s
    global phone
    phone = message.text
    with open("fish.jpg", "rb")as f:
        s = bot.send_photo(message.chat.id, f, caption=f"🇺🇿 <b>Исми шарифингиз (Тўлиқ)</b> \n--------------------------------------------------------------------------------\n🇷🇺 <b>Назовите Ваше полное имя</b>:", parse_mode="HTML")
    bot.register_next_step_handler(message, get_surname)
    
def get_surname(message):
    bot.delete_message(message.chat.id, message.message_id)
    bot.delete_message(message.chat.id, s.id)
    global fio
    global g
    global h
    fio = message.text
    with open("taminot.jpg", "rb")as f:
        g = bot.send_photo(message.chat.id, f, caption=f"1. «Тошкент шаҳар сув таъминоти» МЧЖ\n2. «Андижон сув таъминоти» МЧЖ\n3. «Бухоро сув таъминоти» МЧЖ\n4. «Жиззах сув таъминоти» МЧЖ\n5. «Қашқадарё сув таъминоти» МЧЖ\n6. «Навоий сув таъминоти» МЧЖ\n7. «Наманган сув таъминоти» МЧЖ\n8. «Самарқанд сув таъминоти» МЧЖ\n9. «Сурхондарё сув таъминоти» МЧЖ\n10. «Сирдарё сув таъминоти» МЧЖ\n11. «Тошкент сув таъминоти» МЧЖ\n12. «Фарғона сув таъминоти» МЧЖ\n13. «Хоразм сув таъминоти» МЧЖ\n14. «Қорақалпоқ сув таъминоти» МЧЖ\n15. «Мусаффо оби ҳаёт» МЧЖ\n16. «Дамхўжа сув таъминоти» МЧЖ\n17. «Чимган - Чорвоқ сув таъминоти»\n18. «Ўзсувтаъминот» АЖ", parse_mode="HTML")
    h = bot.send_message(message.chat.id, "🇺🇿 Мурожаат қайси сув таъминотига даҳлдор? Рақамни киритинг. \n----------------------------------------------------------------\n🇷🇺 К какому водоканалу относится ваша заявка?:")
    bot.register_next_step_handler(message, ijro)
    
def ijro(message):
    bot.delete_message(message.chat.id, message.message_id)
    bot.delete_message(message.chat.id, g.id)
    bot.delete_message(message.chat.id, h.id)
    global ijrochi
    global w
    ijrochi = message.text
    if ijrochi == "1":
        ijrochi = "«Тошкент шаҳар сув таъминоти» МЧЖ"
    elif ijrochi == "2":
        ijrochi = "«Андижон сув таъминоти» МЧЖ"
    elif ijrochi == "3":
        ijrochi = "«Бухоро сув таъминоти» МЧЖ"
    elif ijrochi == "4":
        ijrochi = "«Жиззах сув таъминоти» МЧЖ"
    elif ijrochi == "5":
        ijrochi = "«Қашқадарё сув таъминоти» МЧЖ"
    elif ijrochi == "6":
        ijrochi = "«Навоий сув таъминоти» МЧЖ"
    elif ijrochi == "7":
        ijrochi = "«Наманган сув таъминоти» МЧЖ"
    elif ijrochi == "8":
        ijrochi = "«Самарқанд сув таъминоти» МЧЖ"
    elif ijrochi == "9":
        ijrochi = "«Сурхондарё сув таъминоти» МЧЖ"
    elif ijrochi == "10":
        ijrochi = "«Сирдарё сув таъминоти» МЧЖ"
    elif ijrochi == "11":
        ijrochi = "«Тошкент сув таъминоти» МЧЖ"
    elif ijrochi == "12":
        ijrochi = "«Фарғона сув таъминоти» МЧЖ"
    elif ijrochi == "13":
        ijrochi = "«Хоразм сув таъминоти» МЧЖ"
    elif ijrochi == "14":
        ijrochi = "«Қорақалпоқ сув таъминоти» МЧЖ"
    elif ijrochi == "15":
        ijrochi = "«Мусаффо оби ҳаёт» МЧЖ"
    elif ijrochi == "16":
        ijrochi = "«Дамхўжа сув таъминоти» МЧЖ"
    elif ijrochi == "17":
        ijrochi = "«Чимган - Чорвоқ сув таъминоти» МЧЖ"
    elif ijrochi == "18":
        ijrochi = "«Ўзсувтаъминот» АЖ"
    with open("karta.jpg", "rb")as f:
        w = bot.send_photo(message.chat.id, f, caption=f"🇺🇿 <b>‼️ Тўлиқ уй манзилингиз</b>\n<i> Масалан: Тошкент вилояти, Тошкент тумани, Абдуллаев МФЙ, А.Абдуллаев кўчаси 10-уй 55-кв</i> \n--------------------------------------------------------------------------------\n🇷🇺 <b>‼️ Адрес проживания</b>\n<i>Например: Ташкентский область, Ташкентский район, Абдуллаев КФЙ, улица А.Абдуллаев дом 10, кв-55</i>", parse_mode="HTML")
    # bot.send_message(message.chat.id, "Напишите свое заявление:")
    bot.register_next_step_handler(message, get_address)

def get_address(message):
    bot.delete_message(message.chat.id, message.message_id)
    bot.delete_message(message.chat.id, w.id)
    global manzil
    global j
    manzil = message.text
    with open("ariza.jpg", "rb")as f:
        j = bot.send_photo(message.chat.id, f, caption=f"🇺🇿 <b>Қисқача мазмунда аризангизни матн кўринишида ёзиб қолдиринг</b>\n<i>(‼️‼️ СУРАТ, АУДИО ЁЗУВ ВА ҲУЖЖАТЛАРНИ БОТ ҚАБУЛ ҚИЛМАЙДИ.)</i> \n--------------------------------------------------------------------------------\n🇷🇺 <b>Напишите свое заявление</b>\n<i>(‼️‼️ ТОЛЬКО ТЕКСТ, ДРУГИЕ ФОРМАТЫ НЕ ПРИНИМАЕТСЯ)</i>:", parse_mode="HTML")
    bot.register_next_step_handler(message, get_statement)
    
    
def get_statement(message):
    bot.delete_message(message.chat.id, message.message_id)
    bot.delete_message(message.chat.id, j.id)
    global p
    ariza = message.text
    name = "Ўзсувтаъминот АЖ Коррупцияга қарши курашиш бошқармаси"
    result = {}
    arizaraqami = randint(1, 100000)
    result["phone"] = phone
    result["name"] = name
    result["fio"] = fio
    result["manzil"] = manzil
    result["ijrochi"] = ijrochi
    result["ariza"] = ariza
    result["arizaraqami"] = arizaraqami
    result["today"] = today
    doc.render(result)
    out_path = f"{arizaraqami}-мурожаат.docx"
    doc.save(out_path)
    os.system("cls")
    with open(f"{arizaraqami}-мурожаат.docx", "rb")as f:
        bot.send_document(channel_id, f, caption=f"🇺🇿 <i>Мурожаат тартиб рақами:</i> <b>{arizaraqami}</b>\n<i>Ижрочи ташкилот:</i><b> {ijrochi}</b>\n<i>Муроожаат қабул қилинган сана:</i> <b>{today}</b>\n<i>Муҳлати:</i> <b>ўн беш кун</b> ичида, қўшимча ўрганиш ва (ёки) текшириш, қўшимча ҳужжатларни сўраб олиш талаб этилганда эса, <b>бир ойгача бўлган  муддат</b>да кўриб чиқилади.\n<b>(28-модда; Ўзбекистон Республикасининг 2017-йил 11-сентябрдаги ЎРҚ-445-сонли Қонуни)</b>", parse_mode="HTML")
    with open("result.jpg", "rb")as f:
        bot.send_photo(channel_id, f, caption=f"🇺🇿 <b>‼️‼️‼️ {ijrochi} - Ўрганиб чиқилсин ва ижро учун қабул қилинсин ‼️‼️‼️</b>", parse_mode="HTML")
    with open("result2.jpg", "rb")as f:
        p = bot.send_photo(message.chat.id, f, caption=f"🇺🇿 <b>‼️‼️‼️ {ijrochi}га муваффақиятли юборилди - ўрганиш учун қабул қилинди.</b>\n🇷🇺 <b>‼️‼️‼️ Успешно отправлено на {ijrochi}</b>\n\n💧💦 /start 💦💧\n\n", parse_mode="HTML")
    os.system("cls")
    print("МУРОЖААТ ҚАБУЛ ҚИЛИНДИ")
    time.sleep(20)
    bot.delete_message(message.chat.id, p.id)
    
bot.polling(none_stop=True, interval=0, timeout=1000000) 

Python Online Compiler

Write, Run & Share Python code online using OneCompiler's Python online compiler for free. It's one of the robust, feature-rich online compilers for python language, supporting both the versions which are Python 3 and Python 2.7. Getting started with the OneCompiler's Python editor is easy and fast. The editor shows sample boilerplate code when you choose language as Python or Python2 and start coding.

Taking inputs (stdin)

OneCompiler's python online editor supports stdin and users can give inputs to programs using the STDIN textbox under the I/O tab. Following is a sample python program which takes name as input and print your name with hello.

import sys
name = sys.stdin.readline()
print("Hello "+ name)

About Python

Python is a very popular general-purpose programming language which was created by Guido van Rossum, and released in 1991. It is very popular for web development and you can build almost anything like mobile apps, web apps, tools, data analytics, machine learning etc. It is designed to be simple and easy like english language. It's is highly productive and efficient making it a very popular language.

Tutorial & Syntax help

Loops

1. If-Else:

When ever you want to perform a set of operations based on a condition IF-ELSE is used.

if conditional-expression
    #code
elif conditional-expression
    #code
else:
    #code

Note:

Indentation is very important in Python, make sure the indentation is followed correctly

2. For:

For loop is used to iterate over arrays(list, tuple, set, dictionary) or strings.

Example:

mylist=("Iphone","Pixel","Samsung")
for i in mylist:
    print(i)

3. While:

While is also used to iterate a set of statements based on a condition. Usually while is preferred when number of iterations are not known in advance.

while condition  
    #code 

Collections

There are four types of collections in Python.

1. List:

List is a collection which is ordered and can be changed. Lists are specified in square brackets.

Example:

mylist=["iPhone","Pixel","Samsung"]
print(mylist)

2. Tuple:

Tuple is a collection which is ordered and can not be changed. Tuples are specified in round brackets.

Example:

myTuple=("iPhone","Pixel","Samsung")
print(myTuple)

Below throws an error if you assign another value to tuple again.

myTuple=("iPhone","Pixel","Samsung")
print(myTuple)
myTuple[1]="onePlus"
print(myTuple)

3. Set:

Set is a collection which is unordered and unindexed. Sets are specified in curly brackets.

Example:

myset = {"iPhone","Pixel","Samsung"}
print(myset)

4. Dictionary:

Dictionary is a collection of key value pairs which is unordered, can be changed, and indexed. They are written in curly brackets with key - value pairs.

Example:

mydict = {
    "brand" :"iPhone",
    "model": "iPhone 11"
}
print(mydict)

Supported Libraries

Following are the libraries supported by OneCompiler's Python compiler

NameDescription
NumPyNumPy python library helps users to work on arrays with ease
SciPySciPy is a scientific computation library which depends on NumPy for convenient and fast N-dimensional array manipulation
SKLearn/Scikit-learnScikit-learn or Scikit-learn is the most useful library for machine learning in Python
PandasPandas is the most efficient Python library for data manipulation and analysis
DOcplexDOcplex is IBM Decision Optimization CPLEX Modeling for Python, is a library composed of Mathematical Programming Modeling and Constraint Programming Modeling