aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnInternetTroll <lucafulger@gmail.com>2020-07-28 17:41:47 +0000
committerAnInternetTroll <lucafulger@gmail.com>2020-07-28 17:41:47 +0000
commit00da19bb448cd303fd1c70c9c639496ff16d8a91 (patch)
tree2c49ebe54c7e65a3cd69872b79d6800465bd4ca4
parent4c157a51515d788b4319af2e7227c60a86e6bccd (diff)
downloadsteve-bot-00da19bb448cd303fd1c70c9c639496ff16d8a91.tar
steve-bot-00da19bb448cd303fd1c70c9c639496ff16d8a91.tar.gz
steve-bot-00da19bb448cd303fd1c70c9c639496ff16d8a91.tar.bz2
steve-bot-00da19bb448cd303fd1c70c9c639496ff16d8a91.tar.lz
steve-bot-00da19bb448cd303fd1c70c9c639496ff16d8a91.tar.xz
steve-bot-00da19bb448cd303fd1c70c9c639496ff16d8a91.tar.zst
steve-bot-00da19bb448cd303fd1c70c9c639496ff16d8a91.zip
BUG: cannot send message
-rwxr-xr-x[-rw-r--r--]cogs/twitter.py38
-rwxr-xr-xcustom_commands.json2
2 files changed, 24 insertions, 16 deletions
diff --git a/cogs/twitter.py b/cogs/twitter.py
index d321ca3..668169c 100644..100755
--- a/cogs/twitter.py
+++ b/cogs/twitter.py
@@ -1,37 +1,45 @@
+import json
from discord.ext import commands, tasks
import discord
import tweepy
+import asyncio
-class MyStreamListener(tweepy.StreamListener):
+class StreamListener(tweepy.StreamListener):
def on_error(self, status_code):
if status_code == 420:
+ print("Rate limit reached. ")
#returning False in on_error disconnects the stream
return False
- def on_status(self, status):
- if hasattr(status, "retweeted_status"): # Check if Retweet
- try:
- print(status.retweeted_status.extended_tweet["full_text"])
- except AttributeError:
- print(status.retweeted_status.text)
- else:
- try:
- print(status.extended_tweet["full_text"])
- except AttributeError:
- print(status.text)
+ def on_data(self, data):
+ global channelTweet
+ data = json.loads(data)
+ tweetUser = data['user']['screen_name']
+ tweetID = data['id_str']
+ tweetLink = f'https://twitter.com/{tweetUser}/status/{tweetID}'
+ loop = asyncio.get_event_loop()
+ try:
+ loop.run_until_complete(channelTweet.send(tweetLink))
+ finally:
+ loop.run_until_complete(loop.shutdown_asyncgens())
+ loop.close()
+ #print(json.dumps(data, indent='\t'))
class Twitter(commands.Cog):
def __init__(self, bot):
self.bot = bot
+ global channelTweet
+ channelTweet = self.bot.get_channel(737713121447378965)
+
auth = tweepy.OAuthHandler(self.bot.config['twitter']['consumer_key'], self.bot.config['twitter']['consumer_secret'])
auth.set_access_token(self.bot.config['twitter']['access_token'], self.bot.config['twitter']['access_token_secret'])
api = tweepy.API(auth)
- myStreamListener = MyStreamListener()
- self.myStream = tweepy.Stream(auth = api.auth, listener=myStreamListener)
- self.myStream.filter(follow=['1287799985040437254'], is_async=True)
+ myStreamListener = StreamListener()
+ stream = tweepy.Stream(auth = api.auth, listener=myStreamListener)
+ stream.filter(follow=['1287799985040437254'], is_async=True)
def setup(bot):
bot.add_cog(Twitter(bot)) \ No newline at end of file
diff --git a/custom_commands.json b/custom_commands.json
index 9606473..f4143fc 100755
--- a/custom_commands.json
+++ b/custom_commands.json
@@ -30,7 +30,7 @@
"!GlasgowRangers": "You Let Your Club Die!",
"!e\ud83c\udd71\ufe0fic": "HEY GUYS ITS SHIGAME45",
"!testy": "test",
- "!toxicitypass": "```TOXICITY PASS\n\nTHE HOLDER OF THIS PASS HAS PERMISSION FROM THE HEAVENS ABOVE TO DO AND SAY WHATEVER THE HELL THEY WANT\nTHEY ARE ALLOWED TO BE AS TOXIC AS THEY WILL WITHOUT REPERCUSSIONS\n\nPASS OWNER: Duck W aka Weexy aka Indy Kambeitz```",
+ "!toxicitypass": "```TOXICITY PASS\n\nTHE HOLDER OF THIS PASS HAS PERMISSION FROM THE HEAVENS ABOVE TO DO AND SAY WHATEVER THE HELL THEY WANT\nTHEY ARE ALLOWED TO BE AS TOXIC AS THEY WILL WITHOUT REPERCUSSIONS\n\nPASS OWNER: Duck W aka Weexy aka Indy Kambeitz\nPASS OWNER: Ex-Duck K aka Kai McCann aka Madelines long lost sibling```",
"!welcome": "Welcome! <:mango:715738087627685908>",
"!learntoread": "When two players are tied on the leaderboards **ONLY ONE FUCKER WILL BE VISIBLE**",
"!mobiledupe": "1) place item to dupe in the crafting grid\n2) keep pressed until the green bar thing appears\nclick any \"Impossible\" craft (red ones)\n3)press the item to dupe (that is in your hotbar now -> it should have moved there since you pressed the impossible craft)\n4)your item should be duped",