<commit_before>
import discord
from discord.ext import commands

import asyncio
import functools
import html
import sys
import traceback

import tweepy
import urllib3

from modules import logging
from utilities import checks

def setup(bot):
	bot.add_cog(Twitter(bot))

class TwitterStreamListener(tweepy.StreamListener):
	
	def __init__(self, bot, blacklisted_handles = []):
		super().__init__()
		self.bot = bot
		self.blacklisted_handles = blacklisted_handles
		self.stream = None
		self.feeds = {}
		self.unique_feeds = set()
		self.reconnect_ready = asyncio.Event()
		self.reconnect_ready.set()
		self.reconnecting = False
	
	def __del__(self):
		if self.stream:
			self.stream.disconnect()
	
	async def start_feeds(self, *, feeds = None):
		if self.reconnecting:
			return await self.reconnect_ready.wait()
		self.reconnecting = True
		await self.reconnect_ready.wait()
		self.reconnect_ready.clear()
		if feeds:
			self.feeds = feeds
			self.unique_feeds = set(id for feeds in self.feeds.values() for id in feeds)
		if self.stream:
			self.stream.disconnect()
		self.stream = tweepy.Stream(auth = self.bot.twitter_api.auth, listener = self)
		if self.feeds:
			self.stream.filter(follow = self.unique_feeds, is_async = True)
		self.bot.loop.call_later(120, self.reconnect_ready.set)
		self.reconnecting = False
	
	async def add_feed(self, channel, handle):
		id = self.bot.twitter_api.get_user(handle).id_str
		self.feeds[channel.id] = self.feeds.get(channel.id, []) + [id]
		if id not in self.unique_feeds:
			self.unique_feeds.add(id)
			await self.start_feeds()
	<commit_msg>[Discord] Rename variable in Twitter Stream Listener add feed method<commit_after>
import discord
from discord.ext import commands

import asyncio
import functools
import html
import sys
import traceback

import tweepy
import urllib3

from modules import logging
from utilities import checks

def setup(bot):
	bot.add_cog(Twitter(bot))

class TwitterStreamListener(tweepy.StreamListener):
	
	def __init__(self, bot, blacklisted_handles = []):
		super().__init__()
		self.bot = bot
		self.blacklisted_handles = blacklisted_handles
		self.stream = None
		self.feeds = {}
		self.unique_feeds = set()
		self.reconnect_ready = asyncio.Event()
		self.reconnect_ready.set()
		self.reconnecting = False
	
	def __del__(self):
		if self.stream:
			self.stream.disconnect()
	
	async def start_feeds(self, *, feeds = None):
		if self.reconnecting:
			return await self.reconnect_ready.wait()
		self.reconnecting = True
		await self.reconnect_ready.wait()
		self.reconnect_ready.clear()
		if feeds:
			self.feeds = feeds
			self.unique_feeds = set(id for feeds in self.feeds.values() for id in feeds)
		if self.stream:
			self.stream.disconnect()
		self.stream = tweepy.Stream(auth = self.bot.twitter_api.auth, listener = self)
		if self.feeds:
			self.stream.filter(follow = self.unique_feeds, is_async = True)
		self.bot.loop.call_later(120, self.reconnect_ready.set)
		self.reconnecting = False
	
	async def add_feed(self, channel, handle):
		user_id = self.bot.twitter_api.get_user(handle).id_str
		self.feeds[channel.id] = self.feeds.get(channel.id, []) + [user_id]
		if user_id not in self.unique_feeds:
			self.unique_feeds.add(user_id)
			await self.start_feeds()
	
{'fraction_non_alphanumeric': 0.10600924499229585, 'fraction_numerical': 0.002465331278890601, 'mean_word_length': 4.374172185430464, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '319211', 'n_tokens_mistral': 1235, 'n_tokens_neox': 1118, 'n_words': 255}