Yusuf 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- yusuf-0.1.0/PKG-INFO +6 -0
- yusuf-0.1.0/Yusuf/__init__.py +112 -0
- yusuf-0.1.0/pyproject.toml +9 -0
yusuf-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"""Seni çileden çıkaracak ve laf sokacak harika bir troll bot kütüphanesi."""
|
|
2
|
+
__version__ = "0.1.0"
|
|
3
|
+
|
|
4
|
+
# Altına senin yazdığın kodlar aynen devam edecek (class Index vb.)...
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
import random
|
|
8
|
+
import json
|
|
9
|
+
|
|
10
|
+
class Index:
|
|
11
|
+
liste = {}
|
|
12
|
+
|
|
13
|
+
class Sinif:
|
|
14
|
+
@staticmethod
|
|
15
|
+
def ayir(x, y, **kwargs):
|
|
16
|
+
ek_degeri = kwargs.get("ek", "")
|
|
17
|
+
if ek_degeri:
|
|
18
|
+
sinif_ismi = f"{ek_degeri}/{y}"
|
|
19
|
+
else:
|
|
20
|
+
sinif_ismi = y
|
|
21
|
+
|
|
22
|
+
def ad_metodu(self=None):
|
|
23
|
+
return x
|
|
24
|
+
|
|
25
|
+
DinamikSinif = type(sinif_ismi, (object,), {
|
|
26
|
+
"ad": ad_metodu,
|
|
27
|
+
"kategori": sinif_ismi,
|
|
28
|
+
"ham_kategori": y,
|
|
29
|
+
"Index": Index
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
return DinamikSinif
|
|
33
|
+
|
|
34
|
+
@staticmethod
|
|
35
|
+
def karsilastir(kontrol_edilen, mevcut_kategori):
|
|
36
|
+
return kontrol_edilen == mevcut_kategori
|
|
37
|
+
|
|
38
|
+
@staticmethod
|
|
39
|
+
def katNe(aranan_ad, kontrol_verisi, **kwargs):
|
|
40
|
+
uydur = kwargs.get("uydur", True)
|
|
41
|
+
|
|
42
|
+
if isinstance(kontrol_verisi, dict):
|
|
43
|
+
siniflar = list(kontrol_verisi.values())
|
|
44
|
+
else:
|
|
45
|
+
siniflar = list(kontrol_verisi)
|
|
46
|
+
|
|
47
|
+
bulunan_ham_kategori = None
|
|
48
|
+
|
|
49
|
+
# 1. Adım: Kelimeyi hafızada ara
|
|
50
|
+
for sinif in siniflar:
|
|
51
|
+
if hasattr(sinif, 'ad') and sinif().ad() == aranan_ad:
|
|
52
|
+
bulunan_ham_kategori = sinif.ham_kategori
|
|
53
|
+
break
|
|
54
|
+
|
|
55
|
+
# 2. Adım: Kelime bulunamadıysa JSON'a kaydet ve uydurma mantığını çalıştır
|
|
56
|
+
if bulunan_ham_kategori is None:
|
|
57
|
+
try:
|
|
58
|
+
with open("bilinmeyenler.json", "r", encoding="utf-8") as f:
|
|
59
|
+
data = json.load(f)
|
|
60
|
+
except:
|
|
61
|
+
data = []
|
|
62
|
+
|
|
63
|
+
# Yeni bilinmeyen kelimeyi JSON listesine ekle
|
|
64
|
+
if aranan_ad not in data:
|
|
65
|
+
data.append(aranan_ad)
|
|
66
|
+
with open("bilinmeyenler.json", "w", encoding="utf-8") as f:
|
|
67
|
+
json.dump(data, f, ensure_ascii=False, indent=4)
|
|
68
|
+
|
|
69
|
+
if uydur:
|
|
70
|
+
# EĞER JSON DOLUYSA: Kayıtlı bilinmeyen kelimelerden rastgele birini seç
|
|
71
|
+
if data:
|
|
72
|
+
return random.choice(data)
|
|
73
|
+
|
|
74
|
+
# EĞER JSON BOŞSA (İlk çalıştırmaysa): Mevcut listedeki adlardan seç
|
|
75
|
+
uydurma_havuzu = [sinif().ad() for sinif in siniflar if hasattr(sinif, 'ad')]
|
|
76
|
+
return random.choice(uydurma_havuzu) if uydurma_havuzu else "anlamadım"
|
|
77
|
+
else:
|
|
78
|
+
return "anlamadım"
|
|
79
|
+
|
|
80
|
+
# 3. Adım: Kelime varsa kategori eşleşmesi yap
|
|
81
|
+
ayni_kategoridekiler = []
|
|
82
|
+
for sinif in siniflar:
|
|
83
|
+
if hasattr(sinif, 'ham_kategori') and sinif.ham_kategori == bulunan_ham_kategori:
|
|
84
|
+
if sinif().ad() != aranan_ad:
|
|
85
|
+
ayni_kategoridekiler.append(sinif().ad())
|
|
86
|
+
|
|
87
|
+
if ayni_kategoridekiler:
|
|
88
|
+
return random.choice(ayni_kategoridekiler)
|
|
89
|
+
else:
|
|
90
|
+
if uydur:
|
|
91
|
+
# Kategori tek tabancaysa yine JSON havuzuna, o da yoksa ana havuza bak
|
|
92
|
+
if data:
|
|
93
|
+
return random.choice(data)
|
|
94
|
+
uydurma_havuzu = [sinif().ad() for sinif in siniflar if hasattr(sinif, 'ad')]
|
|
95
|
+
return random.choice(uydurma_havuzu) if uydurma_havuzu else "anlamadım"
|
|
96
|
+
return "anlamadım"
|
|
97
|
+
|
|
98
|
+
@staticmethod
|
|
99
|
+
def ogren(hedef_liste):
|
|
100
|
+
try:
|
|
101
|
+
with open("bilinmeyenler.json", "r", encoding="utf-8") as f:
|
|
102
|
+
kayitli_kelimeler = json.load(f)
|
|
103
|
+
except:
|
|
104
|
+
kayitli_kelimeler = []
|
|
105
|
+
|
|
106
|
+
mevcut_adlar = [sinif().ad() for sinif in hedef_liste if hasattr(sinif, 'ad')]
|
|
107
|
+
|
|
108
|
+
for kelime in kayitli_kelimeler:
|
|
109
|
+
if kelime not in mevcut_adlar:
|
|
110
|
+
yeni_sinif = Index.Sinif.ayir(kelime, "uydurma_kelime")
|
|
111
|
+
hedef_liste.append(yeni_sinif)
|
|
112
|
+
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["flit_core >=3.2,<4"]
|
|
3
|
+
build-backend = "flit_core.buildapi"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "Yusuf" # İnternette aranacak paket adı (Eğer 'yusuf' ismi kapalıysa yusuf-bot yapabilirsin)
|
|
7
|
+
authors = [{name = "Yusuf"}]
|
|
8
|
+
dynamic = ["version", "description"]
|
|
9
|
+
dependencies = [] # Dışarıdan ekstra bir kütüphane istemediği için boş bıraktık
|