DiscordBOTを動かすためのコード修正
Q&A
Closed
解決したいこと
どの部分のプログラムコードが間違っているのかを知りたいです。
実際に書いているプログラムコード
```import tweepy
import requests
import json
from config import CONFIG
auth = tweepy.OAuthHandler("APIKey", "APIKey Secret")
auth.set_access_token("Access Token", "Access Token Secret")
APIインスタンスを作成
api = tweepy.API(auth, wait_on_rate_limit=True, wait_on_limit_notify=True)
webhook_url = CONFIG[""]
フォローしているユーザーのwatch_listを作成
followee_ids = api.friends_ids(screen_name=api.me().screen_name)
watch_list = [str(user_id) for user_id in followee_ids]
watch_list.append(str(api.me().id))
デフォルトのアクセスレベルではfollowには5000人まで指定できるため
assert(len(watch_list) <= 5000)
class MyStreamListener(tweepy.StreamListener):
def on_status(self, status):
# @ツイートは表示しない.
if "@" in status.text:
pass
else:
# ユーザーの情報を取得
user_id = status.user.id
user = api.get_user(user_id)
main_content = {
'username': status.user.name,
'avatar_url': user.profile_image_url_https,
'content': status.text
}
headers = {'Content-Type': 'application/json'}
response=requests.post(webhook_url, json.dumps(main_content), headers=headers)
print('-------------------------------------------')
print('name:' + status.user.name)
print(status.text)
myStreamListener = MyStreamListener()
myStream = tweepy.Stream(auth=api.auth, listener=myStreamListener)
myStream.filter(follow=watch_list)```
エラーコード
PS C:\Users\touky> & C:/Users/touky/AppData/Local/Programs/Python/Python310/python.exe c:/Users/touky/Desktop/alfareactorBOT/twi-cord.py
Traceback (most recent call last):
File "c:\Users\touky\Desktop\alfareactorBOT\twi-cord.py", line 9, in <module>
api = tweepy.API(auth, wait_on_rate_limit=True, wait_on_limit_notify=True)
TypeError: API.__init__() got an unexpected keyword argument 'wait_on_limit_notify'
画像
自分で試したこと
Qiita以外のネット記事等も参考に4つのKey("APIKey", "APIKey Secret")("Access Token", "Access Token Secret")を再発行し記載したり(書き直し)、+部分を削除したりしました。