inflearn logo
강의

강의

N
챌린지

챌린지

멘토링

멘토링

N
클립

클립

로드맵

로드맵

지식공유

파이썬으로 구현하는 거래 자동화 봇 (챗봇)

알림을 위한 텔레그램 봇 연동

텔레그램 api 연동

685

김정용

작성한 질문수 2

0

--inflearn_telegram.py ------------

import telegram

my_token = '796750774:AAFjR6ckBvyejTA9lB20TBXloi9qOydNIAA'

bot = telegram.Bot(token = my_token)

chat_id = '684872243'

message = '반갑습니다.'

bot.sendMessage(chat_id=chat_id, text=message)

--파이참 error 내용-----------------------

C:asdataAnaconda3python.exe C:/asdata/madegopax/inflearn_telegram.py

Traceback (most recent call last):

File "C:/asdata/madegopax/inflearn_telegram.py", line 4, in

bot = telegram.Bot(token = my_token)

AttributeError: module 'telegram' has no attribute 'Bot'

Process finished with exit code 1

--웹부라우저에서 실행------

https://api.telegram.org/bot796750774:AAFjR6ckBvyejTA9lB20TBXloi9qOydNIAA/getupdates

{ "ok": true, "result": [{ "update_id": 843898929,

"message": { "message_id": 5, "from": { "id": 684872243, "is_bot": false, "first_name": " uc815 uc6a9", "last_name": " uae40", "language_code ":"ko-KR "},"chat ": {"id ": 684872243,"first_name ":" uc815 uc6a9 ","last_name ":" uae40 ","type ":"private "}} 날짜 ": 1540610570,"text ":"hellow "}}, {"update_id ": 843898930,

"message": "{"message_id ": 6"from ": {"id ": 684872243,"is_bot ": false,"first_name ":" uc815 uc6a9 ","last_name ":" uae40 ","language_code ":"ko-KR "},"chat ": {"id ": 684872243,"first_name ":" uc815 uc6a9 ","last_name ":" uae40 ","type ":"private "}} 날짜 ": 1540610592,"text ":"frend "}}, {"update_id ": 843898931,

"message": "{"message_id ": 7"from ": {"id ": 684872243,"is_bot ": false,"first_name ":" uc815 uc6a9 ","last_name ":" uae40 ","language_code ":"ko-KR "},"chat ": {"id ": 684872243,"first_name ":" uc815 uc6a9 ","last_name ":" uae40 ","type ":"private "}} 날짜 ": 1540625698,"text ":"hellow "}}}}}--inflearn_telegram.py ------------

import telegram

my_token = '796750774:AAFjR6ckBvyejTA9lB20TBXloi9qOydNIAA'

bot = telegram.Bot(token = my_token)

chat_id = '684872243'

message = '반갑습니다.'

bot.sendMessage(chat_id=chat_id, text=message)

--파이참 error 내용-----------------------

C:asdataAnaconda3python.exe C:/asdata/madegopax/inflearn_telegram.py

Traceback (most recent call last):

File "C:/asdata/madegopax/inflearn_telegram.py", line 4, in

bot = telegram.Bot(token = my_token)

AttributeError: module 'telegram' has no attribute 'Bot'

Process finished with exit code 1

--웹부라우저에서 실행------

https://api.telegram.org/bot796750774:AAFjR6ckBvyejTA9lB20TBXloi9qOydNIAA/getupdates

{ "ok": true, "result": [{ "update_id": 843898929,

"message": { "message_id": 5, "from": { "id": 684872243, "is_bot": false, "first_name": " uc815 uc6a9", "last_name": " uae40", "language_code ":"ko-KR "},"chat ": {"id ": 684872243,"first_name ":" uc815 uc6a9 ","last_name ":" uae40 ","type ":"private "}} 날짜 ": 1540610570,"text ":"hellow "}}, {"update_id ": 843898930,

"message": "{"message_id ": 6"from ": {"id ": 684872243,"is_bot ": false,"first_name ":" uc815 uc6a9 ","last_name ":" uae40 ","language_code ":"ko-KR "},"chat ": {"id ": 684872243,"first_name ":" uc815 uc6a9 ","last_name ":" uae40 ","type ":"private "}} 날짜 ": 1540610592,"text ":"frend "}}, {"update_id ": 843898931,

"message": "{"message_id ": 7"from ": {"id ": 684872243,"is_bot ": false,"first_name ":" uc815 uc6a9 ","last_name ":" uae40 ","language_code ":"ko-KR "},"chat ": {"id ": 684872243,"first_name ":" uc815 uc6a9 ","last_name ":" uae40 ","type ":"private "}} 날짜 ": 1540625698,"text ":"hellow "}}}}}

python chatbot

답변 1

0

Gunhee Lee

telegram모듈이 없거나 참조를 잘못 하고있을 때 나오는 현상입니다.

현재 구동하고있는 환경 (venv or 전역) 에 제대로 telegram 패키지가 설치 돼 있는지 확인해주세요.

그래도 안되신다면

pip uninstall python-telegram-bot telegram

pip install python-telegram-bot

이 커맨드를 실행해 봐 주세요.

혹시 그래도 안되신다면 다시 질문 부탁드립니다.

감사합니다.

업비트나 빗썸에서도 구현 가능한가요?

0

298

0

이 강의 지금도 적용되나요?

0

272

0

매수를 계속 반복해서 합니다.

0

463

1

똑같이 하는데 매수가 안됩니다.

0

449

3

강의 좋아요

0

477

0

글씨 크기 좀 키워줘요

0

311

0

매수는 되었는데 매도가 안되네요

0

771

2

수량을 조절하려면 어디를 고쳐야 하나요?

0

363

2

TA-Lib가 정상적인 설치가 안되면 조건값을 수정해도 백테스팅 결과가 동일하게 나오나요?

0

390

1

수업에서 제공한 코드로 백테스트 할 때, 오류가 발생합니다.

0

412

2

안녕하세요, 제가 url 이 404가 나오는 데 원인이 찾기 힘들어서 이렇게 질문 올립니다!

0

312

2

30분 기준으로 캔들을 천 개 가져오는데 start가 왜 start = int(now_time)-60*60*1000*1000 인가요?

0

238

0

주문을 넣었을 때 주문체결이 되지 않는 경우는 어떻게 하나요?

0

321

0

Local variable 'is_buy' value is not used

0

696

3

talib 다운로드는 어떻게 합니까?

0

690

1

telegram관련 모듈을 모두 삭제하시고 재 설치해도 이전 질문과 같은 현상

0

417

2

telegram bot 관련 - 최근에 작동을 안합니다.

0

1672

3

잔고가 없는데도 매수 주문이 계속 일어납니다.

0

393

1

분할매수는 어떻게 적용해야 하나요?

0

323

1

inflearn.py 파일은 강의 내용에 없었는데 무슨 내용인지 에러가 납니다.

0

324

3

chat_id 알기 위해 텔레그램 API 접속하면 에러

0

562

1

inflearn_buy.py 실행시 errorMessage: 'Not authorized' 나타납니다.

0

278

3

inflearn.py 실행 에러

1

386

2

pip install requests

0

307

1