Social-ethosa
A Python library that uses requests
Documentation in other languages
Changelog
Examples:
Get started
Installation: pip install --upgrade social-ethosa
Import:
from social_ethosa import *
Vkcom
vk = Vk(token="Your token is here", group_id=12345, debug=True, lang="en")
@vk.on_message_new
def getMessage(message):
text = message.text
peer_id = message.peer_id
from_id = message.from_id
attachments = message.attachments
using the file Uploader:
vk.uploader.getUploadUrl("message_photo")
upload files:
response = vk.uploader.uploadFile("path")
Some audio methods are also available in my library:
login = "89007003535"
password = "qwertyuiop"
audio = Audio(login=login, password=password, debug=1)
audios = audio.get()
Yandex api
Using Yandex api:
TOKEN = "translate token"
yt = YTranslator(token=TOKEN)
text = "Пайтон - хороший язык программирования"
response = yt.translate(text=text, lang="en")
print(response)
Trace moe
Using the TraceMoe api:
tracemoe = TraceMoe()
response = tracemoe.search("a.png", False, 1)
If the anime is found, you should get a video preview of the found moment:
video = tracemoe.getVideo(response, mute=0)
tracemoe.writeFile("file.mp4", video)
BotWrapper
In the library there is a wrapper for bots!
Initialization:
bw = BotWrapper()
Getting a random date
date = bw.randomDate(fromYear="2001", toYear="3001")
BetterBotBase
This class uses pickle to maintain the database.
Let's initialize this class.
bbs = BetterBotBase("users folder", "dat")
BetterBotBase can also be used with Vkcom:
@vk.on_message_new
def getNewMessage(message):
from_id = message.from_id
if from_id > 0:
user = bbs.autoInstall(from_id, vk)
BotWrapper can also be used to interact with BetterBotBase!
text = bw.answerPattern("Hello, <name>, your money is <money>!", user)
You can define your own templates to the database!
bbs.addPattern("countMessages", 0)
You created a template, but it was not added to the old users? not a problem!
bbs.addNewVariable("countMessages", 0)
ThisPerson api
Initialization is quite simple
person = ThisPerson()
In the class now only 3 methods to retrieve non-existent people/cats/waifu
rperson = person.getRandomPerson()
rcat = person.getRandomCat()
rwaifu = person.getRandomWaifu()
after receiving the generated photo, it should be written to a file.
person.writeFile("person.png", rperson)
person.writeFile("cat.png", rcat)
person.writeFile("waifu.png", rwaifu)
Yummyanime club
There are few methods here, as I have not found an official API. Let's get started.
ym = YummyAnime()
ym = YummyAnime(login="yourmail@gmail.com", password="iampassword")
Getting random anime
randomAnime = ym.getRandomAnime()
print(dir(randomAnime))
print(randomAnime)
You can also get a list of anime updates
updates = ym.getUpdates()
anime = updates[0].open()
print(updates)
print(anime)
And also you can view your profile
profile = ym.getProfile()
print(profile)
bloggercom api
Module to work with blogger.com
Initialization:
blogger = Blogger(apiKey="Your api key")
get blog by id:
blog = blogger.blogs.get(123123)
print(blog["name"])
print(blog.name)
print(blog)
get blog by url:
blog = blogger.blogs.getByUrl("https://meethosa.blogspot.com")
get posts by blog id
posts = blogger.posts.get(123123)
get pages by blog id
posts = blogger.pages.get(123123)
eMath
I decided that very few people will need this module, so importing it separately from the main one:
from social_ethosa.eMath import *
Point
You can create an N-dimensional point:
point = Point(0, 0, 0)
point1 = Point(4, 2, 3)
And also you can find the Euclidean distance between them:
distance = point.euclideanDistance(point1)
print(distance)
Matrix
Also this module has a Matrix class
matrix = Matrix(3, 3)
matrix1 = Matrix([[1, 2, 3],
[4, 5, 6],
[7, 8, 9]])
You can transpose the matrix
matrix1.transpose()
And multiply the matrix by the number
matrix1 *= 3
The addition of two matrices is also possible
matrix2 = Matrix([[1, 2, 3],
[4, 5, 6],
[7, 8, 9]])
matrix1 += matrix2
Matrix multiplication? No problem!
matrix = Matrix([[1, 2, 3],
[4, 5, 6]])
matrix1 = Matrix([[1, 2],
[3, 4],
[5, 6]])
matrix *= matrix1
matrix = Matrix([[1, 2],
[3, 4]])
matrix1 = Matrix([[1, 2],
[3, 4]])
matrix *= matrix1
You can also clear or fill the matrix with any numbers!
matrix = Matrix([[1, 2],
[3, 4]])
matrix.clear()
matrix.fill()
matrix.fill(7)
you can also edit individual parts of the matrix
matrix.setAt(0, 0, 8)
a = matrix.getAt(0, 0)
And also you can mirror the matrix:
matrix.flip()
ArithmeticSequence
There are many ways to initialize an arithmetic sequence.
ars = ArithmeticSequence(0, 2)
ars = ArithmeticSequence([0, 2])
ars.getElem(1)
ars.getElem(0)
ars.getElem(4)
You can also get the sum of the elements
ars = ArithmeticSequence(5, 5)
ars.getSum(0)
ars.getSum(2)
GeometricSequence
There are many ways to initialize an geometric sequence.
ars = GeometricSequence(1, 2)
ars = GeometricSequence([1, 2])
ars.getElem(1)
ars.getElem(0)
ars.getElem(4)
You can also get the sum of the elements
ars = ArithmeticSequence(1, 2)
ars.getSum(0)
ars.getSum(2)
ars.getSum(1)
utils
This module can make your life much easier.
def smthDef(arg1, arg2, **kwargs):
print(getValue(kwargs, "argument", None))
downloadFileFromUrl("url", "path to file")
updateLibrary("0.2.42")
lst = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]
print(splitList(lst, 2))
lst = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]
print(splitList(lst, 3))
timer = Timer()
@timer.after(1000)
def hi():
print("hello world")
@timer.afterEvery(100, 1000)
def hello(): print("hello")
timer.cancel()
This module, like eMath, must be imported separately
from social_ethosa.extra import *
EList:
lst1 = EList()
lst2 = EList("string")
lst3 = EList(1, 2, 3)
lst4 = EList([1, 2, 3])
all the methods of normal lists are present in this, however there are a few features here
lst1 += 1
lst1 += [1, 2]
lst1 += EList(3, 4)
lst1.clear()
lst1 += [1, 2, 3]
lst1.split(1)
lst1.clear()
lst1 += [1, 2, 3]
lst1[2]
lst1[3]
lst1[3] = 4
lst1
lst1.len() == len(lst1)
lst1.sum() == sum(lst1)
lst1.standartItem(0)
lst1[8] = 1
lst1
There are also non-standard methods, for example:
lst1.binarySearch(1)
lst1.interpolationSearch(1)
lst1.sortA(EList.GNOME_SORT)
LogManager
LogManager("filename.txt", "text for log")
with LogManager("filename.txt") as log:
log.write("text for log")
MarkovChains
mchains = MarkovChains()
mchains.addChain("name", "hello")
mchains.addChain("hello", "name")
mchains.generateSequence(5, auth="name")
mchains = MarkovChains()
mchains.execute("name => hello => c <=> ban => name => c")
mchains.generateSequence(5)
AMarkov
Also you can easily use Markov algorithm
m = AMarkov()
m.addRule("1", "0|")
m.addRule("|0", "||0")
m.addRule("0", "")
m.compile("101")
EQueue
There is an queue here
queue = EQueue()
for i in range(10):
queue.add(i)
queue.len()
test = ", ".join("%s" % queue.getRandom() for i in range(queue.len()))
queue.len()
test