Différences entre les versions de « Louka Langenbick »

De {}
Aller à la navigation Aller à la recherche
 
(Une version intermédiaire par le même utilisateur non affichée)
Ligne 1 : Ligne 1 :
  
 
----
 
----
−
===Un bot===
 
−
<source lang="python">
 
−
# -*- coding : utf-8 -*-
 
−
 
−
 
−
 
−
#un bot qui récupère des tweets qui se finissent par "comment", "comment ?", "comment !" et qui leur répond par un "taire". L'absurdité de se bot est de dire tout simplement ce qu'il fait.
 
−
 
−
import twitter
 
−
 
−
def getApi(consumer_key, consumer_secret, access_token_key, access_token_secret):
 
−
    return twitter.Api(consumer_key='XXX',
 
−
                    consumer_secret='XXX',
 
−
                    access_token_key='XXX',
 
−
                    access_token_secret='XXX')   
 
−
 
−
#API Key
 
−
#lmP6vqj585dtz6ltGuUA2041h
 
−
#API Secret Key
 
−
#2epBQa364HR5OOOW0cUAiXkenlxy3zPnfOsZUa4iXIJkQBDQwS
 
−
#Bearer Token
 
−
#AAAAAAAAAAAAAAAAAAAAAHWhOwEAAAAAiuvE39ayCMA5wqX5QvSuuLEQZmo%3DsjJHvGrSgU4P7rJkL5qewfZQvkNGzeLTkq8Gwuab9lO5YOmn3t
 
−
 
−
 
−
from config import getApi
 
−
import os
 
−
import time
 
−
print()
 
−
 
−
# Search : 180/15m // Tweet : 300/3H
 
−
 
−
api = getApi(os.environ['consumer_key'], os.environ['consumer_secret'], os.environ['access_token_key'], os.environ['access_token_secret'])
 
−
tweets = 0
 
−
searchs = 0
 
−
limitTweets = 100
 
−
limitSearchs = 80
 
−
 
−
def endsWith(sentence, keyword):
 
−
    return sentence.endswith(keyword)
 
−
 
−
def postStatus(update, inReplyTo, media):
 
−
    global tweets
 
−
    tweets += 1
 
−
    api.PostUpdate(update, media=media, in_reply_to_status_id=inReplyTo)
 
−
 
−
def search(research, howMany):
 
−
    global searchs
 
−
    searchs += 1
 
−
    searchResults = api.GetSearch(raw_query="q="+research+"&result_type=recent&count="+howMany)
 
−
    for search in searchResults:
 
−
        if(endsWith(search.text, "comment") or endsWith(search.text, "comment ?") or endsWith(search.text, "comment !")):
 
−
            postStatus("@" + search.user.screen_name + " taire", search.id, "monkey.jpg")
 
−
 
−
def start():
 
−
    global searchs
 
−
    global tweets
 
−
    global limitTweets
 
−
    global limitSearchs
 
−
    while(True):
 
−
        search("comment", "100")
 
−
        if(searchs >= limitSearchs):
 
−
            print("Limite atteinte des searchs")
 
−
            time.sleep(60*60*15)
 
−
            searchs = 0
 
−
        elif(tweets >= limitTweets):
 
−
            print("Limite atteinte des tweets")
 
−
            time.sleep(60*60*3)
 
−
            tweets = 0
 
−
        print(f"On a tweeté {str(tweets)} fois !")
 
−
        time.sleep(5)
 
−
 
−
start()
 
−
 
−
 
−
 
−
 
−
 
−
 
−
 
−
 
−
 
−
 
−
 
−
 
−
===Un troll===
 
−
<source lang="python">
 
−
# -*- coding : utf-8 -*-
 
−
 
−
#un script qui transforme les caractères de l'interlocuteur en majuscules.
 
−
 
−
import time
 
−
import string
 
−
import sys
 
−
 
−
print('Slt toi!')
 
−
time.sleep(1)
 
−
print('Comment vas-tu?')
 
−
time.sleep(2)
 
−
réponse00 = input()
 
−
print("En vrai je m'en balek j'ai pas d'âme... Toz.")
 
−
time.sleep(1)
 
−
print("T'as le seum?")
 
−
time.sleep(2)
 
−
 
−
réponse01 = input()
 
−
 
−
if réponse01 == "oui" or réponse01 == "Oui":
 
−
    print("Ha... Miskine!")
 
−
    sys.exit()
 
−
   
 
−
else:
 
−
    print(réponse01.upper())
 
−
 
−
continuer = True
 
−
 
−
while continuer == True :
 
−
    print("Wesh, pq t'écris en majuscule... Avoue t'as le seum??")
 
−
    time.sleep(1)
 
−
    réponse02=input()
 
−
    print(réponse02.upper())
 
−
    if réponse02 == "oui" or réponse02 == "Oui":
 
−
        print("Tu vois que t'as le seum! Miskine ...")
 
−
        time.sleep(2)
 
−
        print("Déso mais pas désolé!")
 
−
        break
 
−
 
−
----
 
−
Année bissextile, code source:
 
−
 
−
<source lang="python">
 
−
 
−
# -*- coding: utf-8 -*-
 
−
print (" Saisissez une année:")
 
−
 
−
annee = input()
 
−
annee = int(annee)
 
−
 
−
for compteur in range(1, annee + 1):
 
−
    print( " Année : " + str(compteur) )
 
−
 
−
if annee % 400 == 0 or (annee %4==0 and annee %100 != 0):
 
−
print("l'annee saisie est bissextile")
 
−
else:
 
−
print("l'annee saisie n'est pas bissextile.")
 
−
 
−
===Une pageweb===
 
−
<source lang="html">
 
−
 
−
<!doctype html>
 
−
<html>
 
−
  <head>
 
−
    <meta charset="utf-8">
 
−
 
−
 
−
  </head>
 
−
 
−
  <body>
 
−
 
−
    <h1>Ma petite page web</h1>
 
−
 
−
    <!-- ceci est un commentaire -->
 
−
    <section>
 
−
      <pre>Invader
 
−
      ____  Turned invader              Normal invader
 
−
    /___/\_                                __
 
−
    _\  \/_/\__                          _|  |_
 
−
  __\      \/_/\                      _|      |_
 
−
  \  __    __ \ \                    |  _    _  |
 
−
__\  \_\  \_\ \ \  __              | |_|  |_| |
 
−
/_/\\  __  __  \ \_/_/\          _  |  _    _  |  _
 
−
\_\/_\__\/\__\/\__\/_\_\/          |_|_|_| |__| |_|_|_|
 
−
  \_\/_/\      /_\_\/              |_|_        _|_|
 
−
      \_\/      \_\/                  |_|      |_|</pre>
 
−
       
 
−
       
 
−
     
 
−
       
 
−
       
 
−
        <pre>
 
−
        quoi J' dit la MESSAGE
 
−
       
 
−
        calisse Je le Chien
 
−
       
 
−
        veux J' le savon pistou
 
−
       
 
−
        quoi J' dit le chemin ,
 
−
       
 
−
        la s pistou tombe !
 
−
       
 
−
        moi Je danser le mauX pistou
 
−
       
 
−
        le deboires pistou taaJAIjAaSK$ !
 
−
       
 
−
        Jul aime le GQSK !
 
−
       
 
−
        fuit Je le deboires
 
−
       
 
−
        le MESSAGE couvert fuit
 
−
       
 
−
        Jul tombe la soir pistou
 
−
       
 
−
       
 
−
        </pre>
 
−
 
−
      </section>
 
−
 
−
 
−
 
−
  </body>
 
−
</html>
 

Version actuelle datée du 7 novembre 2021 à 18:40