Arti0mka / Projekt1pository

This my new repository. :) Ha-ha ha
0 stars 0 forks source link

сделай кнопки #15

Closed ihsinme closed 3 years ago

ihsinme commented 3 years ago

извини что из за меня идет торможение. надеюсь скоро вернемся в работу. пока что почитай про телеграм ботов и сделай бот который выводит кнопки и дает возможность их нажимать.

почитай в гугле

Arti0mka commented 3 years ago

Can you please tell me how to make buttons?

Arti0mka commented 3 years ago

I can't find it. I honestly searched.

ihsinme commented 3 years ago

почитай про телеграм ботов и сделай бот который выводит кнопки и дает возможность их нажимать.

I think you should have asked. and where to read? and I would answer on google.

https://www.google.com/search?q=google+telegram+bot+buttons+python&sxsrf=ALeKk02--0Lu1lxcR3va8nE9EIHKUmnVLw:1609765309404&lr=lang_ru&sa=X&ved=2ahUKEwjH38CLq4LuAhUGxRQKHXXMBXwQuAF6BAgIEDQ&biw=1366&bih=657

Arti0mka commented 3 years ago

Can you tell me I entered the code on the buttons, but it did not work for me. What should I do?

ihsinme commented 3 years ago

firstly you must remember that the example must be inserted into your program, where there are keys of your bot, etc. secondly, the question must contain a kind of error. thirdly, give an example of your program that you want to run.

and only then can I help you.

Arti0mka commented 3 years ago

An example of my program is a calendar or cities where I want to go. Can you help?

ihsinme commented 3 years ago

of course I can help you. but first, make your program file in your repository, call it tele2.py. run in gipod and copy the error messages.

then I can look at both the file and the error.

read my answers carefully.

Arti0mka commented 3 years ago

What would I create a file, I need to click go to file?

Arti0mka commented 3 years ago

A file to do through? Commit directly to the main branch. or Create a new branch for this commit and start a pull request.

ihsinme commented 3 years ago

go to file is go to file. and to create a file is to add a file

Commit directly to the main branch.

Arti0mka commented 3 years ago

I made a file you can see?

ihsinme commented 3 years ago

Yes, I see. I do not even seem to be bad. but now let's figure it out.

this line @ bot.message_handler (content_types = ['text']) says that all messages will be processed by the function that is declared immediately below it and messages will be text and will be sent to the message variable. and you have your function under it

def get_text_messages (message):

and the calendar function lies at the end and does not receive anything, which means it is not called.

let's do this remove all functions from tic-tac-toe. under @ bot.message_handler (content_types = ['text']) place def get_calendar (message):

Then, in theory, any of your messages should get a calendar.

Arti0mka commented 3 years ago

That is, I have to complete everything before the start of the calendar command?

Arti0mka commented 3 years ago

And replace this function bot.message_handler (content_types = ['text']) on this def get_text_messages (message):

Arti0mka commented 3 years ago

Here is a program

import os
import sys
import subprocess
import telebot
import time
#pip3 install pytelegrambotapi --upgrade
#pip3 install python-telegram-bot --upgrade

bot = telebot.TeleBot('1287725214:AAEPpUk4MmCQOl5FDBs5IiF3zzNRQXHnB6Q')
def get_calendar(message):
        now = datetime.datetime.now() #Текущая дата
        chat_id = message.chat.id
        date = (now.year,now.month)
        current_shown_dates[chat_id] = date #Сохраним текущую дату в словарь
        markup = create_calendar(now.year,now.month)
        bot.send_message(message.chat.id, "Пожалйста, выберите дату", reply_markup=markup)

bot.polling(none_stop=True, interval=0) 
Arti0mka commented 3 years ago

Here are the error lines Traceback (most recent call last): File "/workspace/Projekt1pository/tele2.py", line 4, in import telebot ModuleNotFoundError: No module named 'telebot'

ihsinme commented 3 years ago

you forgot to install

pip3 install pytelegrambotapi --upgrade
Arti0mka commented 3 years ago

Uncle Sergey can you please tell me how to move forward in solving this problem.

Arti0mka commented 3 years ago

Can you tell me what the error is?

import os
import sys
import subprocess
import telebot
import time
#pip3 install pytelegrambotapi --upgrade
#pip3 install python-telegram-bot --upgrade

bot = telebot.TeleBot('1287725214:AAEPpUk4MmCQOl5FDBs5IiF3zzNRQXHnB6Q')

@bot.message_handler(commands=['calendar'])
def get_calendar(message):
    now = datetime.datetime.now() #Текущая дата
    chat_id = message.chat.id
    date = (now.year,now.month)
    current_shown_dates[chat_id] = date #Сохраним текущую дату в словарь
    markup = create_calendar(now.year,now.month)
    bot.send_message(message.chat.id, "Пожалйста, выберите дату", reply_markup=markup)
    bot.answer_callback_query(call.id, text="Дата выбрана")

bot.polling(none_stop=True, interval=0) 
Arti0mka commented 3 years ago

Sorry for not writing for so long.

ihsinme commented 3 years ago

I have bad news for you. 1.I had error 2021-01-08 20: 51: 22,369 (init.py:510 MainThread) ERROR - TeleBot: "A request to the Telegram API was unsuccessful. Error code: 400. Description: Bad Request: can ' t parse reply keyboard markup JSON object "it can say that telegram does not support this project now. 2.therefore, when choosing an article, carefully look at the date, https://habr.com/ru/post/335886/ the date of article is 2017.

  1. start over, look for a more recent article and start implementing it.
Arti0mka commented 3 years ago

Thank you

ihsinme commented 3 years ago

I gave you a simple example. he is in PR, accept and work.

simple working example. figure out how it works and what it does. if you can't start the keyboard in 40 minutes, ask for a hint.

Arti0mka commented 3 years ago

It gives me such errors. What should I do?

unresolved import 'telebot'Python (unresolved-import) [4, 8]
unresolved import 'telebot'Python (unresolved-import) [6, 6]
ihsinme commented 3 years ago

you forgot to install

pip3 install pytelegrambotapi --upgrade

How many times will I write the same thing?

Arti0mka commented 3 years ago

Can you please give me a hint?

ihsinme commented 3 years ago

let's get in touch in the evening

Arti0mka commented 3 years ago

Ok!