def controls(self, event):
if event.type == pg.KEYDOWN:
bt = pg.key.get_pressed()
if bt[pg.K_SPACE] and self.on_ground:
self.jump()
elif bt[pg.K_d]:
self.walk("right")
elif bt[pg.K_a]:
self.walk('left')
elif bt[pg.K_w]:
self.jerk()
elif event.type == pg.MOUSEBUTTONDOWN:
print("attack")
self.attack()
else:
self.animation("base")
for event in pg.event.get():
do_event(event)
from selenium import webdriver
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument("--no-sandbox")
chrome_options.add_argument("--headless")
chrome_options.add_argument("--disable-gpu")
browser = webdriver.Chrome(options=chrome_options)
try:
browser.get("https://www.google.com")
print("Page title was '{}'".format(browser.title))
finally:
browser.quit()
app.exec_()
# Main class
class MainClass():
def __init__(self):
# этот webdriver передаётся в другие классы. можно считать, что он "главный"
self.webdriver = None
self.number_of_class = "Main"
class SubClass(MainClass):
def __init__(self, number):
self.number_of_class = number
webdrivers = [SubClass("first_class"), SubClass("second_class"), SubClass("third_class")]
updater = Updater(TOKEN, use_context=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: Updater.__init__() got an unexpected keyword argument 'use_context'
updater = Updater(TOKEN)
pip install python-telegram-bot==13.7
client = texttospeech.TextToSpeechClient()
credentials = service_account.Credentials.from_service_account_file('C:\Programmirovanie\IDE\Microsoft VS Code\exctazy_bot\skript_anonimka\goggletexttospeech-96f1ecee0681.json')
client = texttospeech.TextToSpeechClient(credentials=credentials)
button = tk.Button(window, text="Change/Assign prices", command= lambda: price(1, 2))
def main_func():
some code...
if __ name__ == "__main__":
main_func()
pysimplegui open file dialog
очень много подходящих результатовtext = sg.popup_get_file('Please enter a file name')
sg.popup('Results', 'The value returned from popup_get_file', text)
1. Как можно переслать пост из канала всем участникам, а не только определённым по ID через бота в ЛС?
| id | user_id | message |
| -- | ------- | ---------------------------------------- |
| 1 | 12345 | Привет, наша утренняя рассылка новостей |
| 2 | 67890 | Привет, от тебя давно не было активности |
2. Как можно отправить случайный пост из канала участнику при взаимодействии с кнопкой через бота в ЛС?
from aiogram import types, Dispatcher
from createbot import dp, shieldbot
import keyboards
from random import choice
posts = [<id постов>]
chat_id = <id канала>
@dp.message_handler(commands=['random_post', 'lucky'])
async def random_channel_post(message: types.Message):
await shieldbot.forward_message(chat_id=message.from_user.id, from_chat_id=chat_id, message_id=choice(posts))
routes = web.RouteTableDef()
@routes.post('/websocket')
async def websocketUp(request):
try:
<здесь открываем сокет>
print("Сокет открыт")
return web.Response(text="success")
except:
print("Ошибка открытия сокета")
return web.Response(text="error")
app = web.Application()
app.add_routes(routes)
web.run_app(app)