├── .gitignore ├── requirements.txt ├── README.md ├── settings.example.ini ├── LICENSE.md ├── posts.txt └── frogposter.py /.gitignore: -------------------------------------------------------------------------------- 1 | /settings.ini -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | requests >= 2.23.0 2 | beautifulsoup4 >= 4.9.1 -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # FrogHub 2 | Простенький автопостер ле гушек для https://myspace.windows93.net на Python 3. 3 | 4 | ## Установка 5 | 6 | 1. Установите зависимости командой `pip3 install -r requirements.txt` 7 | 8 | 2. Создайте копию файла settings.example.ini и переименуйте её в settings.ini 9 | 10 | 3. Следуйте комментариям в файле settings.ini -------------------------------------------------------------------------------- /settings.example.ini: -------------------------------------------------------------------------------- 1 | [MySpace] 2 | ; Основной URL MySpace на всякий 3 | baseurl = https://myspace.windows93.net 4 | ; Логин 5 | email = pee@pee.com 6 | ; Пароль 7 | password = p00p00 8 | ; ID пользователя 9 | id = 9267 10 | ; Максимум постов на странице 11 | max_posts = 5 12 | ; Если постов больше, то пост под ID, указанным ниже, будет удалён 13 | delete_on_overflow = 2 14 | 15 | [General] 16 | ; Файл, в который будут сохраняться ранее отправленные картинки 17 | archive = ./last_posts.txt 18 | ; Сколько постов оставил бот 19 | last_post = 0 20 | ; Флаг, предназначенный для защиты от отправки двух и более лягушек в одну среду. Если 0, то лягушку сегодня ещё не отправляли, 21 | ; если 1, то отправили и на сегодня лягушек хватит. 22 | posted_today = 0 23 | 24 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Ivan Kuzmenko 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /posts.txt: -------------------------------------------------------------------------------- 1 | https://i.imgur.com/L4wnWn0.png 2 | https://i.imgur.com/wWWLgDM.mp4 3 | https://i.imgur.com/RWHIfYZ.jpg https://i.imgur.com/mOg3ia1.jpg 4 | https://i.imgur.com/oQrRBJU.jpg 5 | https://i.imgur.com/nllKQ1n.jpg 6 | https://i.imgur.com/AhEWETi.jpg 7 | https://i.imgur.com/oWrvCwr.jpg 8 | https://i.imgur.com/H0YHaFh.jpg 9 | https://i.imgur.com/STssJ0C.jpg 10 | https://i.imgur.com/aamTQJx.jpg 11 | https://i.imgur.com/JjR0LOJ.jpg 12 | https://i.imgur.com/8rZysoM.jpg 13 | https://i.imgur.com/G5k01FA.jpg frog detector said that this frog is indeed a frog 14 | https://i.imgur.com/01gi3bQ.jpg 15 | https://i.imgur.com/STjY9tn.jpg 16 | https://i.imgur.com/jXNGUHb.jpg 17 | https://i.imgur.com/BRJRhiq.jpg 18 | https://i.imgur.com/PY8j8X5.jpg 19 | https://66.media.tumblr.com/7574dc4dba6101d28d650bd1287803c4/tumblr_pno33fnv4P1xwc8oao1_400.gif by https://myspace.windows93.net/index.php?id=8406 20 | https://i.imgur.com/xlOtrVW.jpg 21 | https://i.imgur.com/hqakZ5c.jpg 22 | https://i.imgur.com/LYSkDLL.jpg 23 | https://i.imgur.com/TncaE5e.jpg 24 | https://i.imgur.com/W9JFesY.jpg 25 | https://i.imgur.com/0lBAfrE.jpg 26 | https://i.imgur.com/Ktjte4Y.jpg 27 | https://i.imgur.com/6exzKF2.jpg 28 | https://i.imgur.com/Neq3Frz.jpg 29 | https://i.imgur.com/kas7PJP.jpg 30 | https://i.imgur.com/5YNRZ4O.jpg happy birthday froge 31 | https://i.imgur.com/Iq6m2jo.jpg 32 | https://i.imgur.com/ZJSQBfO.jpg 33 | https://i.imgur.com/miKS3ct.jpg funni yellow dog 34 | https://i.imgur.com/9t1cjWL.jpg 35 | https://i.imgur.com/ZL6CILG.jpg 36 | -------------------------------------------------------------------------------- /frogposter.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import datetime 3 | import re 4 | import urllib.parse 5 | import configparser 6 | import requests 7 | from bs4 import BeautifulSoup 8 | 9 | config = configparser.ConfigParser() # Настройки 10 | config.read("settings.ini") 11 | 12 | baseurl = config["MySpace"]["baseurl"] 13 | 14 | # Бот 15 | s = requests.session() 16 | headers = {'content-type': 'application/x-www-form-urlencoded'} 17 | 18 | def logIn(login, password): 19 | payload_login = "username={}&password={}&login=".format(urllib.parse.quote(login), urllib.parse.quote(password)) 20 | s.request("POST", baseurl + "/login.php", data=payload_login, headers=headers) 21 | 22 | def getBlogs(userId): 23 | r = s.request("GET", baseurl + "/blog.php?id={}".format(userId)) 24 | bs = BeautifulSoup(r.text, features="html.parser") 25 | cropLen = len("/blog.php?id={}&b=".format(userId)) 26 | return [int(a.get("href")[cropLen:]) 27 | for a in bs.select('div.box.blog>a')] 28 | 29 | def postBlog(title, text): 30 | payload_blog = "user=1&title={}&corpus={}".format(urllib.parse.quote(title), urllib.parse.quote(text)) 31 | s.request("POST", baseurl + "/blogWrite.php", data=payload_blog, headers=headers) 32 | 33 | def editBlog(userId, blogId, title, text): 34 | payload_blog = "user={}&title={}&corpus={}".format(userId, urllib.parse.quote(title), urllib.parse.quote(text)) 35 | s.request("POST", baseurl + "/blogUpdate.php?id={}&b={}".format(userId, blogId), data=payload_blog, headers=headers) 36 | 37 | def removeBlog(userId, blogId): 38 | s.request("GET", baseurl + "/blogDelete.php?id={}&b={}".format(userId, blogId)) 39 | 40 | def acceptFwiendRequest(fwiendId): 41 | s.request("GET", baseurl + "/accept.php?id={}".format(fwiendId)) 42 | 43 | def getFwiendsRequests(id): 44 | r = s.request("GET", baseurl + "/requests.php?id={}".format(id)) 45 | bs = BeautifulSoup(r.text, features="html.parser") 46 | return [int(a.get("href")[len("index.php?id="):]) 47 | for a in bs.select('div.friendRequests>a')] 48 | 49 | def logOut(): 50 | s.post(baseurl + "/logout.php") 51 | 52 | def saveConfig(): 53 | with open('settings.ini', 'w') as configfile: 54 | config.write(configfile) 55 | 56 | def shutDown(): 57 | saveConfig() 58 | logOut() 59 | sys.exit(0) 60 | 61 | logIn(config["MySpace"]["email"], config["MySpace"]["password"]) 62 | 63 | for fwiend in getFwiendsRequests(config["MySpace"]["id"]): 64 | print("New fwiend request:", fwiend) 65 | acceptFwiendRequest(fwiend) 66 | 67 | # Постинг лягух ниже 68 | posted_today = int(config["General"]["posted_today"]) == 1 69 | if (datetime.datetime.today().weekday() != 2): # если не среда 70 | print("It's not wednesday, my dudes... Not yet!") 71 | if (posted_today): # если лягуху вчера запостили то можно снять флаг 72 | config["General"]["posted_today"] = str(0) 73 | shutDown() 74 | elif (posted_today): # если среда, но лягушку уже постили 75 | print("It's wednesday, my dudes, but I've send a frog or toad today!") 76 | shutDown() 77 | 78 | print("It's wednesday, my dudes! AAAAAAAAAAAAAAAAAAAAAAAAAAAAA!") 79 | 80 | if (len(getBlogs(config["MySpace"]["id"])) == int(config["MySpace"]["max_posts"])): 81 | removeBlog(config["MySpace"]["id"], config["MySpace"]["delete_on_overflow"]) 82 | 83 | content_line = "" 84 | with open("posts.txt", "r") as f: 85 | lines = f.readlines() 86 | content_line = lines.pop(int(config["General"]["last_post"])) 87 | 88 | config["General"]["last_post"] = str(int(config["General"]["last_post"]) + 1) 89 | 90 | post_title = "Wednesday post №{}".format(config["General"]["last_post"]) 91 | 92 | with open(config["General"]["archive"], "a") as f: 93 | f.write("{} ({}): {}".format(post_title, datetime.datetime.now().strftime("%H:%M %a %b %d %Y"), content_line)) 94 | 95 | postBlog(post_title, content_line) 96 | 97 | config["General"]["posted_today"] = str(1) 98 | shutDown() 99 | --------------------------------------------------------------------------------