<commit_before>import logging
from django.urls import reverse
from django.template import Template, Context

from bot.tweepy_api import get_api as tweepy_api
from bot.python_twitter_api import get_api as twitter_api
from community.helpers import site_url
from tweepy.error import TweepError

logger = logging.getLogger(__name__)

def get_incoming_friendship(community):
    try:
        screen_name=community.account.username
    except:
        return
    api = twitter_api(username=screen_name)
    try:
        return api.IncomingFriendship()
    except TweepError as e:
        logger.error(f'{e}')
    except Exception as e:
        logger.error(f'{e}')

def message_requestor(queue):
    try:
        community = queue.community
    except:
        return
    try:
        helper_username = community.helper.username
    except:
        return
    if not helper_username:
        return
    try:
        requestor_screen_name = queue.socialuser.screen_name_tag()
    except:
        return
    if not requestor_screen_name:
        return
    try:
        bot_username = community.account.username
    except:
        return
    
    helper_message = get_helper_message(
        community,
        requestor_screen_name,<commit_msg>handle case where api is None (Over capacity error)<commit_after>import logging
from django.urls import reverse
from django.template import Template, Context

from bot.tweepy_api import get_api as tweepy_api
from bot.python_twitter_api import get_api as twitter_api
from community.helpers import site_url
from tweepy.error import TweepError

logger = logging.getLogger(__name__)

def get_incoming_friendship(community):
    try:
        screen_name=community.account.username
    except:
        return
    api = twitter_api(username=screen_name)
    try:
        return api.IncomingFriendship()
    except AttributeError:
        return
    except TweepError as e:
        logger.error(f'{e}')
    except Exception as e:
        logger.error(f'{e}')

def message_requestor(queue):
    try:
        community = queue.community
    except:
        return
    try:
        helper_username = community.helper.username
    except:
        return
    if not helper_username:
        return
    try:
        requestor_screen_name = queue.socialuser.screen_name_tag()
    except:
        return
    if not requestor_screen_name:
        return
    try:
        bot_username = community.account.username
    except:
        return
    
    helper_message = get_helper_message(
        community,
        requestor_screen_name,
{'fraction_non_alphanumeric': 0.060641627543035995, 'fraction_numerical': 0.0, 'mean_word_length': 2.782544378698225, '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': '3493216', 'n_tokens_mistral': 740, 'n_tokens_neox': 732, 'n_words': 186}