[PYTHON] A simple workaround for bots to try to post tweets with the same content

Yes. It's important, so I tried to avoid posting the same content, which tends to be a bot operation, so that I would say it only once.

http://qiita.com/clarinet758/items/3e245a4388ef8a752ca3

op.py


while i < 4:
#Go from newest to oldest up to the last 4 posts.
    tl = tll[i].text
    otu=re.compile(u'Thank you for your hard work')
    oha=re.compile(u'Utilization time')

#Check if a specific word is included
    if re.search(u'@xxx Good night', tl):
        jk = tll[i].created_at
        t = open('kanri.txt', 'w')
        t.write(str(jk))
        t.close()

        tane = '@xxx Thank you for your hard work. Bed in%s time%I set it in about s minutes.' % (str(jk.hour+9), str(jk.minute))
        m=i-1
#From the moment a specific word is found, go to the new one and look for the word that the bot is using in the reply
#If there is a specific word, it is a simple judgment, but it ends as it has been operated.
#If you do not hit after seeing the latest arrival, tweet as inactive.
        while m>=0:
            if re.search(otu, tll[m].text):
                break
            else: m-=1
#       if m<=0:
        if m<0:
            oat.client.request('https://api.twitter.com/1.1/statuses/update.json', 'POST', urlencode({'status': tane}))
        i+=5

I'll tweak variable names and things that are too dirty after tomorrow. I wonder if it is necessary to save the log if it goes back only about one digit for personal use. However, if there are many follw destinations, there is a high risk that the simple judgment word will be confused in TL, so it depends on the situation. Hmmm, I think it's easy to check only specific words at that time without saving the log.

Corrected the condition from m <= 0 to m <0 at the last judgment. If <=, when hitting with the latest remark and exiting with break, m is 0, so duplicate remarks could not be stopped.

Recommended Posts

A simple workaround for bots to try to post tweets with the same content
(For beginners) Try creating a simple web API with Django
Rails users try to create a simple blog engine with Django
Change the bash prompt to a simple color for easy viewing
Try to generate a death metal jacket image with DCGAN + scrape the metal database site for that
Tokyo Corona: Try to make a simple prediction from open data with the exponential function curve_fit
[Introduction to Udemy Python3 + Application] 47. Process the dictionary with a for statement
Try to solve the traveling salesman problem with a genetic algorithm (Theory)
A guidebook for doing IoT with MicroPython easily to the last minute
Try to solve the traveling salesman problem with a genetic algorithm (Python code)
Try to solve the traveling salesman problem with a genetic algorithm (execution result)
Experiment to collect tweets for a long period of time (aggregation & content confirmation)
Calculate the optimal solution to set a world record for decathlon with scipy.optimize
Turn multiple lists with a for statement at the same time in Python
How to get a list of files in the same directory with python
[Introduction to Python] How to get the index of data with a for statement
Try to solve the fizzbuzz problem with Keras
Try to solve the man-machine chart with Python
Try to draw a life curve with python
How to try the friends-of-friends algorithm with pyfof
Try to make a "cryptanalysis" cipher with Python
A program that searches for the same image
Save the object to a file with pickle
Try to make a dihedral group with Python
Try posting to Qiita for the first time
Try to create a battle record table with matplotlib from the data of "Schedule-kun"
Try to create a waveform (audio spectrum) that moves according to the sound with python
Try to solve the programming challenge book with python3
Try to make a command standby tool with python
How to create a submenu with the [Blender] plugin
Try to dynamically create a Checkbutton with Python's Tkinter
Try to visualize the room with Raspberry Pi, part 1
Try to solve the internship assignment problem with Python
Molecular dynamics simulation to try for the time being
[GCP] Try a sample to authenticate users with Firebase
Try to get the contents of Word with Golang
[Neo4J] ④ Try to handle the graph structure with Cypher
A sample to try Factorization Machines quickly with fastFM
Transit to the update screen with the Django a tag
How to post a ticket from the Shogun API
I tried a simple RPA for login with selenium
Try to specify the axis with PyTorch's Softmax function
What is a dog? Django--Getting Started with Form for the First Time POST Transmission Volume
Experiment to collect tweets for a long time (Program preparation (3))
Try to build a deep learning / neural network with scratch
Try to play with the uprobe that supports Systemtap directly
Try to display various information useful for debugging with python
Finding a solution to the N-Queen problem with a genetic algorithm (2)
Probably the easiest way to create a pdf with Python3
Try a similar search for Image Search using the Python SDK [Search]
Experiment to make a self-catering PDF for Kindle with Python
The first step to creating a serverless application with Zappa
A simple way to avoid multiple for loops in Python
How to make a simple Flappy Bird game with pygame
Experiment to collect tweets for a long time (program preparation (2))
Try to bring up a subwindow with PyQt5 and Python
Create a Twitter BOT with the GoogleAppEngine SDK for Python
Post a message to Google Hangouts Chat with a thread (Python)
Try to automate the operation of network devices with Python
Experiment to collect tweets for a long time (Program preparation (5))
A story about how to deal with the CORS problem