original_docstring: Send the message text to recipient with id recipient.
docstring: Send the message text to recipient with id recipient.
docstring_tokens: Send the message text to recipient with id recipient .
code: def send_message(token, recipient, text):
      """Send the message text to recipient with id recipient."""
      if b"meme" in text.lower():
          subreddit_name = "memes"
      elif b"shower" in text.lower():
          subreddit_name = "Showerthoughts"
      elif b"hmb" in text.lower():
          subreddit_name = "holdmybeer"
      elif b"lotr" in text.lower():
          subreddit_name = "lotrmemes"
      elif b"workspaces" in text.lower():
          subreddit_name = "Workspaces"
      elif b"joke" in text.lower():
          subreddit_name = "Jokes"
      else:
          subreddit_name = "GetMotivated"
  
      myUser = get_or_create(db.session, Users, name=recipient)
  
      if (subreddit_name == "Showerthoughts") or (
          subreddit_name == "holdmybeer"
      ):
          # for subreddits without flairs
          for submission in reddit.subreddit(subreddit_name).hot(limit=None):
              if submission.is_self == True:
                  query_result = Posts.query.filter(
                      Posts.name == submission.id
                  ).first()
                  if query_result is None:
                      myPost = Posts(submission.id, submission.title)
                      myUser.posts.append(myPost)
                      db.session.commit()
                      payload = submission.title
                      break
                  elif myUser not in query_result.users:
                      myUser.posts.append(query_result)
                      db.session.commit()
                      payload = submission.title
                      break
                  else:
                      continue
          r = requests.post(
              "https://graph.facebook.com/v2.6/me/messages",
              params={"access_token": token},
              data=json.dumps(
                  {
                      "recipient": {"id": recipient},
                      "message": {
                          "text": payload,
                          "quick_replies": quick_replies_list,
                      }
                      # "message": {"text": text.decode('unicode_escape')}
                  }
              ),
              headers={"Content-type": "application/json"},
          )
      elif (
          (subreddit_name == "lotrmemes")
          or (subreddit_name == "Workspaces")
          or (subreddit_name == "Jokes")
      ):
          # for subreddits with certain flairs approved
          approved_flairs = [
              "HRAAAAH :scarybilbo::scarybilbo::scarybilbo::scarybilbo:",
              "CAST IT INTO THE FIRE :castintofire:",
              ":borthink:",
              "One does not simply walk in :boromir:" "No :No:",
              ":rohan: Rohan :rohan:",
              "The Hobbit",
              ":shocked:",
              "Keep your secrets :secrets:",
              "Crossover",
              "Repost :proudfoot:",
              "Shitpost",
              "Lord of the Rings",
              ":fingerguns:",
              "Original Content",
              None,
          ]
  
          for submission in reddit.subreddit(subreddit_name).hot(limit=None):
              if (submission.is_self == True) and (
                  submission.link_flair_text in approved_flairs
              ):
                  query_result = Posts.query.filter(
                      Posts.name == submission.id
                  ).first()
                  if query_result is None:
                      myPost = Posts(submission.id, submission.title)
                      myUser.posts.append(myPost)
                      db.session.commit()
                      payload = submission.title
                      payload_text = submission.selftext
                      break
                  elif myUser not in query_result.users:
                      myUser.posts.append(query_result)
                      db.session.commit()
                      payload = submission.title
                      payload_text = submission.selftext
                      break
                  else:
                      continue
  
          r = requests.post(
              "https://graph.facebook.com/v2.6/me/messages",
              params={"access_token": token},
              data=json.dumps(
                  {
                      "recipient": {"id": recipient},
                      "message": {
                          "text": payload_text,
                          "quick_replies": quick_replies_list,
                      }
                      # "message": {"text": text.decode('unicode_escape')}
                  }
              ),
              headers={"Content-type": "application/json"},
          )
      else:
          payload = "http://imgur.com/WeyNGtQ.jpg"
          for submission in reddit.subreddit(subreddit_name).hot(limit=None):
              if (submission.link_flair_css_class == "image") or (
                  (submission.is_self != True)
                  and ((".jpg" in submission.url) or (".png" in submission.url))
              ):
                  query_result = Posts.query.filter(
                      Posts.name == submission.id
                  ).first()
                  if query_result is None:
                      myPost = Posts(submission.id, submission.url)
                      myUser.posts.append(myPost)
                      db.session.commit()
                      payload = submission.url
                      break
                  elif myUser not in query_result.users:
                      myUser.posts.append(query_result)
                      db.session.commit()
                      payload = submission.url
                      break
                  else:
                      continue
          r = requests.post(
              "https://graph.facebook.com/v2.6/me/messages",
              params={"access_token": token},
              data=json.dumps(
                  {
                      "recipient": {"id": recipient},
                      "message": {
                          "attachment": {
                              "type": "image",
                              "payload": {"url": payload},
                          },
                          "quick_replies": quick_replies_list,
                      }
                      # "message": {"text": text.decode('unicode_escape')}
                  }
              ),
              headers={"Content-type": "application/json"},
          )
      if r.status_code != requests.codes.ok:
          print(r.text)
code_tokens: def send_message ( token , recipient , text ) : if b"meme" in text . lower ( ) : subreddit_name = "memes" elif b"shower" in text . lower ( ) : subreddit_name = "Showerthoughts" elif b"hmb" in text . lower ( ) : subreddit_name = "holdmybeer" elif b"lotr" in text . lower ( ) : subreddit_name = "lotrmemes" elif b"workspaces" in text . lower ( ) : subreddit_name = "Workspaces" elif b"joke" in text . lower ( ) : subreddit_name = "Jokes" else : subreddit_name = "GetMotivated" myUser = get_or_create ( db . session , Users , name = recipient ) if ( subreddit_name == "Showerthoughts" ) or ( subreddit_name == "holdmybeer" ) : for submission in reddit . subreddit ( subreddit_name ) . hot ( limit = None ) : if submission . is_self == True : query_result = Posts . query . filter ( Posts . name == submission . id ) . first ( ) if query_result is None : myPost = Posts ( submission . id , submission . title ) myUser . posts . append ( myPost ) db . session . commit ( ) payload = submission . title break elif myUser not in query_result . users : myUser . posts . append ( query_result ) db . session . commit ( ) payload = submission . title break else : continue r = requests . post ( "https://graph.facebook.com/v2.6/me/messages" , params = { "access_token" : token } , data = json . dumps ( { "recipient" : { "id" : recipient } , "message" : { "text" : payload , "quick_replies" : quick_replies_list , } } ) , headers = { "Content-type" : "application/json" } , ) elif ( ( subreddit_name == "lotrmemes" ) or ( subreddit_name == "Workspaces" ) or ( subreddit_name == "Jokes" ) ) : approved_flairs = [ "HRAAAAH :scarybilbo::scarybilbo::scarybilbo::scarybilbo:" , "CAST IT INTO THE FIRE :castintofire:" , ":borthink:" , "One does not simply walk in :boromir:" "No :No:" , ":rohan: Rohan :rohan:" , "The Hobbit" , ":shocked:" , "Keep your secrets :secrets:" , "Crossover" , "Repost :proudfoot:" , "Shitpost" , "Lord of the Rings" , ":fingerguns:" , "Original Content" , None , ] for submission in reddit . subreddit ( subreddit_name ) . hot ( limit = None ) : if ( submission . is_self == True ) and ( submission . link_flair_text in approved_flairs ) : query_result = Posts . query . filter ( Posts . name == submission . id ) . first ( ) if query_result is None : myPost = Posts ( submission . id , submission . title ) myUser . posts . append ( myPost ) db . session . commit ( ) payload = submission . title payload_text = submission . selftext break elif myUser not in query_result . users : myUser . posts . append ( query_result ) db . session . commit ( ) payload = submission . title payload_text = submission . selftext break else : continue r = requests . post ( "https://graph.facebook.com/v2.6/me/messages" , params = { "access_token" : token } , data = json . dumps ( { "recipient" : { "id" : recipient } , "message" : { "text" : payload_text , "quick_replies" : quick_replies_list , } } ) , headers = { "Content-type" : "application/json" } , ) else : payload = "http://imgur.com/WeyNGtQ.jpg" for submission in reddit . subreddit ( subreddit_name ) . hot ( limit = None ) : if ( submission . link_flair_css_class == "image" ) or ( ( submission . is_self != True ) and ( ( ".jpg" in submission . url ) or ( ".png" in submission . url ) ) ) : query_result = Posts . query . filter ( Posts . name == submission . id ) . first ( ) if query_result is None : myPost = Posts ( submission . id , submission . url ) myUser . posts . append ( myPost ) db . session . commit ( ) payload = submission . url break elif myUser not in query_result . users : myUser . posts . append ( query_result ) db . session . commit ( ) payload = submission . url break else : continue r = requests . post ( "https://graph.facebook.com/v2.6/me/messages" , params = { "access_token" : token } , data = json . dumps ( { "recipient" : { "id" : recipient } , "message" : { "attachment" : { "type" : "image" , "payload" : { "url" : payload } , } , "quick_replies" : quick_replies_list , } } ) , headers = { "Content-type" : "application/json" } , ) if r . status_code != requests . codes . ok : print ( r . text )
short_docstring: Send the message text to recipient with id recipient.
short_docstring_tokens: Send the message text to recipient with id recipient .
comment: """Send the message text to recipient with id recipient."""$SEP$# for subreddits without flairs$SEP$# "message": {"text": text.decode('unicode_escape')}$SEP$# for subreddits with certain flairs approved$SEP$# "message": {"text": text.decode('unicode_escape')}$SEP$# "message": {"text": text.decode('unicode_escape')}