HOME FORUMS MEMBERS RECENT POSTS LOG IN  
× Авторизация
Имя пользователя:
Пароль:
Нет аккаунта? Регистрация
Баннер 1   Баннер 2
НОВЫЕ ТОРГОВАЯ НОВОСТИ ЧАТ
loading...
Скрыть
Вернуться   ANTICHAT > ПРОГРАММИРОВАНИЕ > Общие вопросы программирования
   
Ответ
 
Опции темы Поиск в этой теме Опции просмотра

  #11  
Старый 03.01.2024, 15:52
Dickson
Участник форума
Регистрация: 31.12.2022
Сообщений: 201
С нами: 1774087

Репутация: 33
По умолчанию

Цитата:
Сообщение от swap commends  

а как реализовать что бы после нажатия на кнопку, отправлялось сообщение в тг?
code:

Цитата:
Сообщение от Спойлер  


test.py:





Код:
import
cv2
import
pyautogui
import
numpy
as
np
import
time
import
telegram
import
asyncio

bot
=
telegram
.
Bot
(
token
=
'token tg'
)
chat_id
=
'chat id tg'
# Загрузка изображений
img_vosem
=
cv2
.
imread
(
'vosem.png'
,
0
)
img_dva
=
cv2
.
imread
(
'dva.png'
,
0
)
async
def
send_message_async
(
chat_id
,
message
)
:
await
bot
.
send_message
(
chat_id
=
chat_id
,
text
=
message
)
def
locate_image
(
template
,
threshold
=
0.8
)
:
screenshot
=
pyautogui
.
screenshot
(
)
screenshot
=
np
.
array
(
screenshot
)
screenshot
=
cv2
.
cvtColor
(
screenshot
,
cv2
.
COLOR_RGB2BGR
)
screenshot_gray
=
cv2
.
cvtColor
(
screenshot
,
cv2
.
COLOR_BGR2GRAY
)
result
=
cv2
.
matchTemplate
(
screenshot_gray
,
template
,
cv2
.
TM_CCOEFF_NORMED
)
min_val
,
max_val
,
min_loc
,
max_loc
=
cv2
.
minMaxLoc
(
result
)
if
max_val
>=
threshold
:
return
(
max_loc
[
0
]
,
max_loc
[
1
]
)
else
:
return
None
async
def
main
(
)
:
while
True
:
vosem_loc
=
locate_image
(
img_vosem
)
if
vosem_loc
:
message
=
f"Нашел 8. Корды:{vosem_loc}"
await
send_message_async
(
chat_id
,
message
)
time
.
sleep
(
5
)
pyautogui
.
press
(
'8'
)
time
.
sleep
(
5
)
dva_loc
=
locate_image
(
img_dva
)
if
dva_loc
:
message
=
f"Нашел 2. Корды:{dva_loc}"
await
send_message_async
(
chat_id
,
message
)
time
.
sleep
(
5
)
pyautogui
.
press
(
'2'
)
time
.
sleep
(
5
)
loop
=
asyncio
.
get_event_loop
(
)
loop
.
run_until_complete
(
main
(
)
)


 
Ответить с цитированием

  #12  
Старый 04.01.2024, 22:13
swap commends
Познающий
Регистрация: 02.03.2023
Сообщений: 50
С нами: 1685939

Репутация: 13
По умолчанию

Цитата:
Сообщение от teensik  

Цитата:
Сообщение от teensik  

bot = telegram.Bot(token='token tg')
AttributeError: module 'telegram' has no attribute 'Bot'

Цитата:
Сообщение от teensik  

# Загрузка изображений
img_vosem = cv2.imread('vosem.png', 0)
img_dva = cv2.imread('dva.png', 0)
я же могу тут вставить адресс скриншота где у меня он лежит?
 
Ответить с цитированием

  #13  
Старый 05.01.2024, 01:43
Dickson
Участник форума
Регистрация: 31.12.2022
Сообщений: 201
С нами: 1774087

Репутация: 33
По умолчанию

Цитата:
Сообщение от swap commends  

AttributeError: module 'telegram' has no attribute 'Bot'
pip install python-telegram-bot

Цитата:
Сообщение от swap commends  

я же могу тут вставить адресс скриншота где у меня он лежит?
скрин должен лежать там же, где и скрипт, просто замени название
 
Ответить с цитированием

  #14  
Старый 05.01.2024, 16:55
swap commends
Познающий
Регистрация: 02.03.2023
Сообщений: 50
С нами: 1685939

Репутация: 13
По умолчанию

Python:





Код:
import
cv2
import
pyautogui
import
numpy
as
np
import
time
import
telegram
import
asyncio

bot
=
telegram
.
Bot
(
token
=
'---'
)
chat_id
=
'chat id tg'
# Загрузка изображений
img_accept
=
cv2
.
imread
(
'accept.png'
,
0
)
img_ready
=
cv2
.
imread
(
'ready.png'
,
0
)
async
def
send_message_async
(
chat_id
,
message
)
:
await
bot
.
send_message
(
chat_id
=
chat_id
,
text
=
message
)
def
locate_image
(
template
,
threshold
=
0.8
)
:
screenshot
=
pyautogui
.
screenshot
(
)
screenshot
=
np
.
array
(
screenshot
)
screenshot
=
cv2
.
cvtColor
(
screenshot
,
cv2
.
COLOR_RGB2BGR
)
screenshot_gray
=
cv2
.
cvtColor
(
screenshot
,
cv2
.
COLOR_BGR2GRAY
)
result
=
cv2
.
matchTemplate
(
screenshot_gray
,
template
,
cv2
.
TM_CCOEFF_NORMED
)
min_val
,
max_val
,
min_loc
,
max_loc
=
cv2
.
minMaxLoc
(
result
)
if
max_val
>=
threshold
:
return
(
max_loc
[
0
]
,
max_loc
[
1
]
)
else
:
return
None
async
def
main
(
)
:
while
True
:
accept_loc
=
locate_image
(
img_accept
)
if
accept_loc
:
message
=
f"Нашел игру. Корды:{accept_loc}"
await
send_message_async
(
chat_id
,
message
)
await
asyncio
.
sleep
(
5
)
pyautogui
.
press
(
'ready'
)
await
asyncio
.
sleep
(
5
)
ready_loc
=
locate_image
(
img_ready
)
if
ready_loc
:
message
=
f"Нашел готовность. Корды:{ready_loc}"
await
send_message_async
(
chat_id
,
message
)
await
asyncio
.
sleep
(
5
)
pyautogui
.
press
(
'ready'
)
await
asyncio
.
sleep
(
5
)
asyncio
.
run
(
main
(
)
)


Цитата:

Exception ignored in:
Traceback (most recent call last):
File "C:\Users\adm1n\AppData\Local\Programs\Python\Pyth on310\lib\asyncio\proactor_events.py", line 116, in __del__
File "C:\Users\adm1n\AppData\Local\Programs\Python\Pyth on310\lib\asyncio\proactor_events.py", line 108, in close
File "C:\Users\adm1n\AppData\Local\Programs\Python\Pyth on310\lib\asyncio\base_events.py", line 745, in call_soon
File "C:\Users\adm1n\AppData\Local\Programs\Python\Pyth on310\lib\asyncio\base_events.py", line 510, in _check_closed
RuntimeError: Event loop is closed
 
Ответить с цитированием

  #15  
Старый 05.01.2024, 18:56
Dickson
Участник форума
Регистрация: 31.12.2022
Сообщений: 201
С нами: 1774087

Репутация: 33
По умолчанию

Цитата:
Сообщение от swap commends  

Python:





Код:
import
cv2
import
pyautogui
import
numpy
as
np
import
time
import
telegram
import
asyncio

bot
=
telegram
.
Bot
(
token
=
'---'
)
chat_id
=
'chat id tg'
# Загрузка изображений
img_accept
=
cv2
.
imread
(
'accept.png'
,
0
)
img_ready
=
cv2
.
imread
(
'ready.png'
,
0
)
async
def
send_message_async
(
chat_id
,
message
)
:
await
bot
.
send_message
(
chat_id
=
chat_id
,
text
=
message
)
def
locate_image
(
template
,
threshold
=
0.8
)
:
screenshot
=
pyautogui
.
screenshot
(
)
screenshot
=
np
.
array
(
screenshot
)
screenshot
=
cv2
.
cvtColor
(
screenshot
,
cv2
.
COLOR_RGB2BGR
)
screenshot_gray
=
cv2
.
cvtColor
(
screenshot
,
cv2
.
COLOR_BGR2GRAY
)
result
=
cv2
.
matchTemplate
(
screenshot_gray
,
template
,
cv2
.
TM_CCOEFF_NORMED
)
min_val
,
max_val
,
min_loc
,
max_loc
=
cv2
.
minMaxLoc
(
result
)
if
max_val
>=
threshold
:
return
(
max_loc
[
0
]
,
max_loc
[
1
]
)
else
:
return
None
async
def
main
(
)
:
while
True
:
accept_loc
=
locate_image
(
img_accept
)
if
accept_loc
:
message
=
f"Нашел игру. Корды:{accept_loc}"
await
send_message_async
(
chat_id
,
message
)
await
asyncio
.
sleep
(
5
)
pyautogui
.
press
(
'ready'
)
await
asyncio
.
sleep
(
5
)
ready_loc
=
locate_image
(
img_ready
)
if
ready_loc
:
message
=
f"Нашел готовность. Корды:{ready_loc}"
await
send_message_async
(
chat_id
,
message
)
await
asyncio
.
sleep
(
5
)
pyautogui
.
press
(
'ready'
)
await
asyncio
.
sleep
(
5
)
asyncio
.
run
(
main
(
)
)

дай тг свой
 
Ответить с цитированием
Ответ





Здесь присутствуют: 1 (пользователей: 0 , гостей: 1)
 


Быстрый переход




ANTICHAT ™ © 2001- Antichat Kft.

×

Создать сделку

Продавец: ник или ID

Название сделки:

Сумма USDT:

Срок сделки, дней:

Кто платит комиссию:

Условия сделки:

После создания сделки средства будут зарезервированы в холде до завершения сделки.

×

Мои сделки

Загрузка...
×

Сделка


Загрузка чата...