Version 2.1.0
* Preparing for Docker * New videos and jokes and maymays
This commit is contained in:
parent
292095505d
commit
5fcde23dae
3 changed files with 66 additions and 26 deletions
5
Dockerfile
Normal file
5
Dockerfile
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
FROM python:latest
|
||||||
|
COPY . /etc/botyam
|
||||||
|
WORKDIR /etc/botyam
|
||||||
|
RUN pip install -r requirements.txt
|
||||||
|
CMD ["python3", "./main.py"]
|
||||||
49
main.py
49
main.py
|
|
@ -1,6 +1,11 @@
|
||||||
import tweepy
|
import tweepy
|
||||||
import os
|
import os
|
||||||
import syslog
|
import syslog
|
||||||
|
import random
|
||||||
|
|
||||||
|
def init_api():
|
||||||
|
# Syslog report
|
||||||
|
syslog.syslog(syslog.LOG_INFO, "Loading API...")
|
||||||
|
|
||||||
# Secrets
|
# Secrets
|
||||||
consumer_key = os.getenv("CONSUMER_KEY")
|
consumer_key = os.getenv("CONSUMER_KEY")
|
||||||
|
|
@ -9,17 +14,18 @@ access_token = os.getenv("ACCESS_TOKEN")
|
||||||
access_token_secret = os.getenv("ACCESS_TOKEN_SECRET")
|
access_token_secret = os.getenv("ACCESS_TOKEN_SECRET")
|
||||||
bearer = os.getenv("BEARER")
|
bearer = os.getenv("BEARER")
|
||||||
|
|
||||||
# Syslog report
|
return tweepy.Client(
|
||||||
syslog.syslog(syslog.LOG_INFO, "Loading objects...")
|
|
||||||
|
|
||||||
# Twitter API
|
|
||||||
api = tweepy.Client(
|
|
||||||
bearer_token=bearer,
|
bearer_token=bearer,
|
||||||
consumer_key=consumer_key,
|
consumer_key=consumer_key,
|
||||||
consumer_secret=consumer_secret,
|
consumer_secret=consumer_secret,
|
||||||
access_token=access_token,
|
access_token=access_token,
|
||||||
access_token_secret=access_token_secret)
|
access_token_secret=access_token_secret)
|
||||||
|
|
||||||
|
def init_streamobject():
|
||||||
|
syslog.syslog(syslog.LOG_INFO, "Loading Stream object...")
|
||||||
|
bearer = os.getenv("BEARER")
|
||||||
|
return BotYamPoster(bearer)
|
||||||
|
|
||||||
def post_reply(api, tweet, words, reply_text):
|
def post_reply(api, tweet, words, reply_text):
|
||||||
# Search for word in word bank
|
# Search for word in word bank
|
||||||
if any(word in tweet.data['text'] for word in words):
|
if any(word in tweet.data['text'] for word in words):
|
||||||
|
|
@ -28,15 +34,17 @@ def post_reply(api, tweet, words, reply_text):
|
||||||
text=reply_text,
|
text=reply_text,
|
||||||
in_reply_to_tweet_id=tweet["id"]
|
in_reply_to_tweet_id=tweet["id"]
|
||||||
)
|
)
|
||||||
response_data = "RESPONDING: {}".format(res.data['text'])
|
response_data = f"RESPONDING: {res.data['text']}"
|
||||||
syslog.syslog(syslog.LOG_INFO, response_data)
|
syslog.syslog(syslog.LOG_INFO, response_data)
|
||||||
|
|
||||||
# Poster class
|
# Poster class
|
||||||
class BotYamPoster(tweepy.StreamingClient):
|
class BotYamPoster(tweepy.StreamingClient):
|
||||||
|
|
||||||
# Define a callback function to handle tweets
|
# Define a callback function to handle tweets
|
||||||
def on_tweet(self, tweet):
|
def on_tweet(self, tweet):
|
||||||
|
api = init_api()
|
||||||
# Debug
|
# Debug
|
||||||
tweet_data = "NEW TWEET from @{}: {}".format(api.get_user(id=tweet.data['author_id']).data['username'], tweet.data['text'])
|
tweet_data = f"NEW TWEET from @{api.get_user(id=tweet.data['author_id']).data['username']}: {tweet.data['text']}"
|
||||||
syslog.syslog(syslog.LOG_INFO, tweet_data)
|
syslog.syslog(syslog.LOG_INFO, tweet_data)
|
||||||
|
|
||||||
# Spare me if starts with RT
|
# Spare me if starts with RT
|
||||||
|
|
@ -47,33 +55,48 @@ class BotYamPoster(tweepy.StreamingClient):
|
||||||
# Words bank
|
# Words bank
|
||||||
bat_yam_words = ['בת ים', 'בת ימ', 'בת-ים', 'בת-ימ']
|
bat_yam_words = ['בת ים', 'בת ימ', 'בת-ים', 'בת-ימ']
|
||||||
gebels_words = ['גבלס', 'נאצי', 'היטלר', 'קורונה', 'מסמכים', 'ההסמכה']
|
gebels_words = ['גבלס', 'נאצי', 'היטלר', 'קורונה', 'מסמכים', 'ההסמכה']
|
||||||
police_words = ['שוטר', 'מלשין', 'מלשינ', 'נלשן', 'מלשנ', 'להלשין', 'משטרה', 'משטרות', 'סירנה', 'שיטור', 'בוגדים', 'בוגד', 'בגידה', 'שמאל', '0מול', 'סמול', '👮♀️', '🚨', '🚔', '🚓', '👮♂️', 'קטטה', 'מתקוטט', 'משטרע', 'מאפיה', 'טרור', 'סירנות', '1312', '13.12', '1 3 1 2', '13 12', '1 312', '131 2', '13-12', '1-312', '131-2', '1-3-1-2', '1 3 12', '1 3 12', '13 1 2', '1-3-12', '1-3-12', '13-1-2', 'acab', 'ac ab', 'ACAB', 'AC AB', 'אגאב', 'קצין', 'קצינ', 'קצונה', 'צהוב', 'כחול']
|
police_words = ['שוטר', 'מלשין', 'מלשינ', 'נלשן', 'מלשנ', 'להלשין', 'משטרה', 'משטרות', 'סירנה', 'שיטור', 'בוגדים', 'בוגד', 'בגידה', '👮♀️', '🚨', '🚔', '🚓', '👮♂️', 'קטטה', 'מתקוטט', 'משטרע', 'מאפיה', 'טרור', 'סירנות', '1312', '13.12', '1 3 1 2', '13 12', '1 312', '131 2', '13-12', '1-312', '131-2', '1-3-1-2', '1 3 12', '1 3 12', '13 1 2', '1-3-12', '1-3-12', '13-1-2', 'acab', 'ac ab', 'ACAB', 'AC AB', 'אגאב', 'קצין', 'קצינ', 'קצונה', 'צהוב', 'כחול']
|
||||||
misadot_words = ['מסעדה', 'מסעדות']
|
misadot_words = ['מסעדה', 'מסעדות']
|
||||||
|
smol_words = ['שמאל', '0מול', 'סמול']
|
||||||
|
reply_words = ['@FromBotYam']
|
||||||
|
|
||||||
# Reply bank
|
# Reply bank
|
||||||
reply_text_batyam = "https://twitter.com/FromBotYam/status/1611546128524185601/video/1"
|
reply_text_batyam = "https://twitter.com/FromBotYam/status/1611546128524185601/video/1"
|
||||||
reply_text_police = "https://twitter.com/FromBotYam/status/1611542331781529601/video/1"
|
reply_text_police = "https://twitter.com/FromBotYam/status/1611542331781529601/video/1"
|
||||||
reply_text_gebels = "https://twitter.com/FromBotYam/status/1611548817853227009/video/1"
|
reply_text_gebels = "https://twitter.com/FromBotYam/status/1611548817853227009/video/1"
|
||||||
reply_text_misadot = [reply_text_gebels, "https://twitter.com/FromBotYam/status/1612853363066175490/video/1"]
|
reply_text_misadot = [reply_text_gebels, "https://twitter.com/FromBotYam/status/1612853363066175490/video/1", "https://twitter.com/FromBotYam/status/1613254658860150789"]
|
||||||
|
reply_text_smol = "https://twitter.com/FromBotYam/status/1613249771275182089/video/1"
|
||||||
|
reply_videons_reply = ["https://twitter.com/FromBotYam/status/1611495568148238336", "https://twitter.com/FromBotYam/status/1612852295980683264"]
|
||||||
|
reply_text_reply = f"מה אתה מערב אותי יבן זונה {reply_videons_reply[random.randint(0,1)]}"
|
||||||
|
|
||||||
# Users bank
|
# Users bank
|
||||||
batyam_folks = ['134339937', '1533213104']
|
batyam_folks = ['134339937', '1533213104']
|
||||||
|
|
||||||
|
# Replies
|
||||||
|
post_reply(api, tweet, reply_words, reply_text_reply)
|
||||||
post_reply(api, tweet, gebels_words, reply_text_gebels)
|
post_reply(api, tweet, gebels_words, reply_text_gebels)
|
||||||
post_reply(api, tweet, police_words, reply_text_police)
|
post_reply(api, tweet, police_words, reply_text_police)
|
||||||
if any(botyam_og in tweet.data['author_id'] for botyam_og in batyam_folks):
|
if any(botyam_og in tweet.data['author_id'] for botyam_og in batyam_folks):
|
||||||
post_reply(api, tweet, bat_yam_words, reply_text_batyam)
|
post_reply(api, tweet, bat_yam_words, reply_text_batyam)
|
||||||
if not any(gebels_word in tweet.data['text'] for gebels_word in gebels_words):
|
if not any(gebels_word in tweet.data['text'] for gebels_word in gebels_words):
|
||||||
post_reply(api, tweet, misadot_words, reply_text_misadot[random.randint(0,1)])
|
post_reply(api, tweet, misadot_words, reply_text_misadot[random.randint(0,2)])
|
||||||
|
else:
|
||||||
|
post_reply(api, tweet, misadot_words, reply_text_misadot[random.randint(1,2)])
|
||||||
|
post_reply(api, tweet, smol_words, reply_text_smol)
|
||||||
|
|
||||||
# Define a callback function to handle errors
|
# Define a callback function to handle errors
|
||||||
def on_error(self, status_code):
|
def on_error(self, status_code):
|
||||||
# Print the error code
|
# Print the error code
|
||||||
syslog.syslog(syslog.LOG_ERR, status_code)
|
syslog.syslog(syslog.LOG_ERR, status_code)
|
||||||
|
|
||||||
# Set Stream rules
|
def main():
|
||||||
stream = BotYamPoster(bearer)
|
stream = init_streamobject()
|
||||||
stream.add_rules(tweepy.StreamRule("from:LucyBscalE OR from:aviv_yashar OR from:shaulig OR from:DvirAviam OR from:YoavFried1 OR from:StevenRaz5"))
|
syslog.syslog(syslog.LOG_INFO, "Adding stream rules...")
|
||||||
|
stream.add_rules(tweepy.StreamRule("from:LucyBscalE OR from:aviv_yashar OR from:shaulig OR from:DvirAviam OR from:YoavFried1 OR from:StevenRaz5 OR from:nir_hau"))
|
||||||
|
stream.add_rules(tweepy.StreamRule("@yourusername"))
|
||||||
# Start listening for tweets
|
# Start listening for tweets
|
||||||
syslog.syslog(syslog.LOG_INFO, "Starting Twitter stream!")
|
syslog.syslog(syslog.LOG_INFO, "Starting Twitter stream!")
|
||||||
stream.filter(expansions="author_id")
|
stream.filter(expansions="author_id")
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
|
|
|
||||||
12
requirements.txt
Normal file
12
requirements.txt
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
certifi==2022.12.7
|
||||||
|
charset-normalizer==2.1.1
|
||||||
|
dbus-python==1.2.16
|
||||||
|
distro-info==1.0
|
||||||
|
idna==3.4
|
||||||
|
oauthlib==3.2.2
|
||||||
|
python-apt==2.2.1
|
||||||
|
requests==2.28.1
|
||||||
|
requests-oauthlib==1.3.1
|
||||||
|
tweepy==4.12.1
|
||||||
|
unattended-upgrades==0.1
|
||||||
|
urllib3==1.26.13
|
||||||
Loading…
Reference in a new issue