From d581ecadc297577dc7c7394422014f36959895b6 Mon Sep 17 00:00:00 2001 From: Denis <87643305+love-apples@users.noreply.github.com> Date: Sat, 14 Sep 2024 23:27:11 +0300 Subject: [PATCH] 1 --- .DS_Store | Bin 0 -> 6148 bytes .env | 2 + Dockerfile | 13 +++ bot/__init__.py | 0 bot/__pycache__/__init__.cpython-310.pyc | Bin 0 -> 146 bytes bot/__pycache__/album_handler.cpython-310.pyc | Bin 0 -> 2509 bytes bot/__pycache__/config.cpython-310.pyc | Bin 0 -> 523 bytes bot/__pycache__/handlers.cpython-310.pyc | Bin 0 -> 3106 bytes bot/__pycache__/loader.cpython-310.pyc | Bin 0 -> 465 bytes bot/__pycache__/scheduler.cpython-310.pyc | Bin 0 -> 1924 bytes bot/__pycache__/sending.cpython-310.pyc | Bin 0 -> 3906 bytes bot/album_handler.py | 72 ++++++++++++ bot/config.py | 26 +++++ bot/cyprus_off.session | Bin 0 -> 45056 bytes bot/cyprus_off.session-journal | Bin 0 -> 29240 bytes bot/handlers.py | 74 ++++++++++++ bot/loader.py | 14 +++ bot/loader.py.save | 11 ++ bot/scheduler.py | 37 ++++++ bot/sending.py | 108 ++++++++++++++++++ bot/test.py | 11 ++ main.py | 22 ++++ requirements.txt | 11 ++ 23 files changed, 401 insertions(+) create mode 100644 .DS_Store create mode 100644 .env create mode 100644 Dockerfile create mode 100644 bot/__init__.py create mode 100644 bot/__pycache__/__init__.cpython-310.pyc create mode 100644 bot/__pycache__/album_handler.cpython-310.pyc create mode 100644 bot/__pycache__/config.cpython-310.pyc create mode 100644 bot/__pycache__/handlers.cpython-310.pyc create mode 100644 bot/__pycache__/loader.cpython-310.pyc create mode 100644 bot/__pycache__/scheduler.cpython-310.pyc create mode 100644 bot/__pycache__/sending.cpython-310.pyc create mode 100644 bot/album_handler.py create mode 100644 bot/config.py create mode 100644 bot/cyprus_off.session create mode 100644 bot/cyprus_off.session-journal create mode 100644 bot/handlers.py create mode 100644 bot/loader.py create mode 100644 bot/loader.py.save create mode 100644 bot/scheduler.py create mode 100644 bot/sending.py create mode 100644 bot/test.py create mode 100644 main.py create mode 100644 requirements.txt diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..e2dfabb391dc8a7c2f0f1fe59d1d58755e0acd94 GIT binary patch literal 6148 zcmeHK!H&}~5FNLHG`m8|0i?YkMdG?D1y!IGmu%@CIB?k@H~=ciCP1`lT$*$Xsw(9S zzrqLbCHxB~cw>8|HoHii5Mn)&{l=adJM)~_F%gN;BE3iC6HyO^(b++DiLjl^1?iX` zHVPi&Ng+>?LMCYQfL1I6mVtkp0seL!>QhD~owdH-L)iL1m8c}Tl#rx)+e_TO+$&jD zGqV?bOJ+r0)q}xz(djzZuDh=1?z*p|_i`E4alNQU@%$yXo=I6G=X#tx&$H#kzxh~} zb)1*kTm|H52A5Ya@-mgnkzAB%rD7v(@VuTk@%L7%;b6EQ3?Ck>_k-2J{Q>j`!}Z$h z-MVx4(edQ8n3nRh%8CT`E+sb%p2HU?Cg-zgUKX-^haUFcp)r^^p;PcSr?-?-L0O9z zj^1R?r76YmEW!4SKDE4mw7fk!rXxDUJWqjr#HQO39e$S0@qIi=MjvQ_Iar&jHLa;a zbWI=I>xQw3zHY28npUn91LnQ&?Ov&@ZL*dD%fO#7!23gh!WbHCG^(uwmAV1|9ds*! zu73T20e1jHgN;V?K!gqj>QG^>7{c5fgbs&2H2#f79Zo{cjB(7&!rV}Vxp;^`xswPr z+S)Q;8Q5l^tD8Qb|3|;S|8ED`mSw;)@Lw??oN+WBAtiIRUPzA5+5qJZ3Jd!+8dV4? ia~vy$kK#QPC9nmo07HX~M)W}JkAR}VR+fRk%D^v`PnQA! literal 0 HcmV?d00001 diff --git a/.env b/.env new file mode 100644 index 0000000..ceff82b --- /dev/null +++ b/.env @@ -0,0 +1,2 @@ +API_ID_1 = 24012189 +API_HASH_1 = 5a04d4beafc73f2b3a9d5a64ccb53ae5 \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..4fd654c --- /dev/null +++ b/Dockerfile @@ -0,0 +1,13 @@ +FROM python:3.11 + +WORKDIR /forwardspam_nedvizhka_Ciprus +COPY ./ ./ + +RUN rm -rf /etc/localtime +RUN ln -s /usr/share/zoneinfo/Europe/Moscow /etc/localtime +RUN echo "Europe/Moscow" > /etc/timezone + +RUN pip install --upgrade pip +RUN pip install --no-cache-dir -r requirements.txt + +CMD ["python","-u", "main.py"] \ No newline at end of file diff --git a/bot/__init__.py b/bot/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/bot/__pycache__/__init__.cpython-310.pyc b/bot/__pycache__/__init__.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..f173ed1e62b06faff7358153cdd81ec9992e5577 GIT binary patch literal 146 zcmd1j<>g`kg044D(?IlN5P=LBfgA@QE@lA|DGb33nv8xc8Hzx{2;!HivsFxJacWU< zOj2rbNlr{!eo=X1QA%+^Vs3nLWkFGCaeRJST1--YNlbivW?p7Ve7s&kAE6WNaCpH!ch&WF`AOssikmL|vD87JEMVGT&808wys$~_>D%E>n1QxaeD2bR~q200iA@&l5C^Hnc5CS}00sGjQT>YD1R zud26LT52*p&;Rw$;bzF#KWK9CsbTUC$aFYkcbR08r))5P^8v?Pq$2YM9w(WX`dMvI zbG)AhS$$B?!a?ZfwX~5n2hFTCXt{ZiwzH+dlH=>?a<(#9aeSC|vem(=;~VK(wmw+r zOm&ag;1w0h<`Exk$d;;0F1gwmdOarFij7}Y8$CAk<&s=};t#GU@0U!j$j%ccJ4XV0 zda9dALhYrJ{N<(g{Bb+rU*UHQrrAG^NmWEBp}bTO$$xw7>;ho$;$ ztRW3!8 z@{}(*P*76=5aCO)4KyRezOB7W-?ht`lA}1H&y~?g+Ay2v%22ezD9YnZMUibrQC7%F zN_;ztem{xR^A*oj+O9-VoaaRqSEC{~(DBm|^xI^4-@ zJ#yhN0LnRx&izRQG#3w@mTVt^%%3ql<_~wKe9XrD8Ne_W&%9$#vI*1O_ZYz8oieJs zU3TnM{xR>d2VDQGs!jO;haP_}p0Q&#Upe-+*;DqEKNU|sRE3b@|P~p7CyX>$nW%pz7C)D>lnU~NIKRZLFOKY$D9x@VgA=}|5rFf zCCL2~cf3=<*~2be@W(ahD3ktkI8p`2;+P$Y#h&-v(S26c4}Z*I0~+B;gF^B zX@O!gx3;KezMd_%!mxK=9rl~LgZ;Kn(1+pK43>Bbw)Zra2_!{3p z1uk>()x&GwcAkC%Jq*Tme_`2n(e}_NCn_p+QN{|IUIPZgjos$8PAIKSQ^ z6Xea@If|*K!m-PjJ@_7EuJ*+vAwnMT5DvGy?SC)BhievZjJ@(plyMN^AMI`UkllF9a zmAJ;Ksj=ChIxI)|fu?L|`lDjQ@=zBCI?i-JvO39@7qTs=!x%LV>)}Gt?%YjqTWJwX zr8Qk3wnYL1Xpw0b1kb2SuaiOY+xmAQI_$YC-L@{2 z^&D9gjSCT?>u?U)aC?4*+@gFLiY7Wg;MqoXbp+l-JOF%ecp~iZ&7kRZ`Np;X0XYR| AuK)l5 literal 0 HcmV?d00001 diff --git a/bot/__pycache__/config.cpython-310.pyc b/bot/__pycache__/config.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..5604f5a78d91dd8785ac747e88726948db39aba5 GIT binary patch literal 523 zcmY*V!D<^Z6nv7_YiDhDDTG2VIR<=4YdbA*Lr5FiLvksBG#9a;ZY=F~gS;}*I>kQZ zQs}YY&=zti^qybHH|QE#2qpP|Kyf7Zl0MLA-n@}UNVVG$xcYqaEBk^0E`4*qh-+TC zW!^hD1P&ZYpnk^^jWERs1pWjL;Va?f8=}F21&-Bn;I;3FhN3PSk3lT)a0_^yM!Z3r ze2KPrlq1?+-~)~hpwql^De$&~Y*VU~Gp;I8p4i6D{vO+V!+JLIYFQJk-1#$ih^X6lG;&#?rD>RazCQG>p-<8K)!W zMna#YlEzw;6&rqVCLvkDX>5d){|UKPld)l$(#)G_d{6M^AD~-4+QaSo>&@iQ2yK!h zVJexpQy){!7oo%HSWgU7S(Y5BDjBLWEAl7fscmeH6rV`3jocOHk%I_YD8vzo&@v84 JP!DkE_#F%%me2qI literal 0 HcmV?d00001 diff --git a/bot/__pycache__/handlers.cpython-310.pyc b/bot/__pycache__/handlers.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..faaf6f2d20eb49cf5b163fdebd095c5fa0c5640d GIT binary patch literal 3106 zcmbtW&2QYs73Yv#?w3B+@=CT`x1ob1?WV2r0VD+s!!Xb^wSig)q7*?01q8iA$t&|? zGeag(um&WpfwpjpB0)|Kf=cPhH^r$6CAO7A{{iyKYmkF4x#f~me{WWwYXuEZE@t-4 z%zMM(@BQ9;6OWG8G(7pY-z?mL^fe6*KNbd;(Bu-+G_G+LXb%1B0SlSK7|BMUhlXP) z*$m9EJ3J38neiF`CUInv=Y#H0@(Fr;ccz z;!{fV9A|S{>-0nN!fcBbR<|oUQ39#@iYKIhHRe7Bqp$eBxWcbQZ+k(9W1@W3m(p9L zHLD#*3!TN5UYK6D`&?0#?dv{I17DEdLMKRkAzN0_>_}IcyGbYX-Gx|$UQ(2$AMsAK zSd7D}eZ!SW+;wGVF)Bu&@s20B+l^&XG#35DjneR%FVuuA8ggi+O&@Xi0f`25YC!Nc zhjGo(IdcrI*+24?Y&&1gZ)f+i&1@@Q zv-7oVEBi9<=YPqzvn?8KW?y9Y^Hpf<P7cAJ? z^Wy{ZAlm2Ij-A~lHe~k)s}Bj~hXmkv1bX%%^tQ5pfd*ig{R}?MzI^%o)vL3VKnTR5 zBGO3Zh*nkDFhN+vVTkAv#1;PIH8nD5JY$h{s7L*u`1u_5)TCK|G1M z$I#>$I(_A=(O@R4u_k_n#r?of{2#{qUD*78c&{tGH+In#&ny3wdiuxOCxh7B^+69_ zdc+66!t1kt0>I55hrf6V2IA+`{Q})=+EN>+P~6J@3LU2M)~tX16NJ1>%=v zKLmeW_+k9EKkR{Dlj;!QGnjiCO;X}J0DOXhf<=0Y$?|o2N z@mJ-%d-?m6=m5uXszdfm>C!UTIwe-_Z9m&GR8kjBOe)ge(GSsb2q22A7tthPtgl!` zg<1L&sKQj_r~t}G(4qIL1n??^RrcO=f)aqRM}?!X@8i0ph=l;}YagRXd~zrSypBMh zLjj=QfPM$*;SIHhaCfmWxS{eLWo!y@gl+yl@;)f@Z#A`L1I!(8aXbH$ssU@z0*4M| zb{p)vcN}`#wjyRq(VG4Jf9;ZwSo}p592~Ccm(^qtJg4xUhaa)fUWlt_g?M^I+t;HA$d%P&TaK^_)MG7ik z#rVOb5V4SgNPS2(S?>B$P+2bw+!6$NwWvXw31W}?LM61_bho#as6xr9lhW?(X%Lz! z3(_&gD0S+S=vxPu3j=64lfrMKA_dEC=<|-}E{Ztq%AyuWm{2#m!fap1z0C4>*oou- zA(dGvX$lHtL1Yz#%OR{3YO2asE(~r@7b)jUiu#H+!bWs7^bPd3K4w_v8D!lv6|@>! J9j)4A{{=j+v`zp3 literal 0 HcmV?d00001 diff --git a/bot/__pycache__/loader.cpython-310.pyc b/bot/__pycache__/loader.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..927a97b2783bb16f3226d8ab2c7f333a871f4851 GIT binary patch literal 465 zcmYjO%SyvQ6rIVdN%}zg1>I&7sP06>QWxz;gyLohgfug0N0UsLNhx*Pt$v8VG+S{Y z_yw-K6R3J&&OP_QoHGwG9EJ$$LfWK4`~$n!y>LJrD)AQ}4t#GNr>?_D^LA$5n;-jq?|c5t zOrD|b{{2_|H-oW1X)@U~Ozxluw_qfb++)?zmsdIF!V^ucsx|eh-ZZKPXCE@DNqvV& zeITkC$yZs~c!9larK~09qV0M1n&&3DyN~QfI2tbc%I}1Ymg`X5WYaOZgC3A^8QoYF zl2 z+3{S}`5edQOK8z|(LwY)9>o3V1f!#P``uD>7Wdg^Z0ajT2XOVVa2kIR z_o6d|oW{G+Q7QTb5l`TLjPG$NI=on+5CkIR5Ic^dXYpQov%~R*aig(7UqlaxnER~D zEZ~jT^OZ7BjL;4q1{mmp>(zf`%0$pVw-zh4j{{c)wKX>gy;|K@k8CA_w%xRxjkf9p zmS3;e*8H#*jQ{;+dm}L|tI=wNmPJ7r@IqVby`-~Xu1xi#<&qt zNFVk)dQgGs^BfD=K9>Sk4B1d@Xbx}4tf8c-= zod2ih0@L_$JOEE8U}_t^2i*4v-`(grpneKY_J~S~IEa3Zp1|>I3G^Jn^Yt`2sdM~u z7q?g1wz8Wg`t?f5rkpKBKg0uYc@lpa9iNj(?>vtjpHL}L_N2*y+e_D%mMY83*Dub! zw`ts1s@zy!d2t&*TQ-0$Fip%LRP}U}^L)ql(qY!7tZn#-5qPfKF6%0bJ*q&a2$K|@ zj#6$bOnFIDVq|jUEYRC6JgeoZ87u^|Frp_ibKK-bKF7tsn{Q2VKC$Hz%^7S@X?_QT zJ|~j9pt#GsVkm|jG_waFmF8Wot_?Xy)j^num`_CEXMYE9eHw)8Cn zvfz-#wXUAZ<676)=R-(?;()7$bz_9%2+4I_3gD@CYB(a?OvQ=-PqBVBV&>ilsM+TjIs}nNzu5FYbIY0O6y#x5Q&y<1;7!v= z7Dk&=FyDqhn1d0$IYAjX&of-~bbcuZCpN8=3skFGcGI=2ByU+wpXxWpMax?6*xtD( zYgy8FEK5;6Q&i6q4T2iw!W%Tz*L>eoSIJG4bHb2T6qPVyD>P*Dv`<0ei`FG*!+-X1;rJ*x2mt((l`3w&Pt51H73jQ{`u literal 0 HcmV?d00001 diff --git a/bot/__pycache__/sending.cpython-310.pyc b/bot/__pycache__/sending.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..66edcdd7e6f3d618eb67ed3335de4d4be6899743 GIT binary patch literal 3906 zcmZ`+O^h5z6|SoOnV#O+*&nah|MA4J2_x(!m?RJ@KoZ-;5%LnnL?+FeR(q;-?LDmu%-%N;walkp`!g1!>#~==tkT`LP5axT;JL}y|(o(&y zdiA<~-p}`5$HT)e!*l&#|D3&1X6zp{SpPT}yo8qg7eq42Bj)9A?s1GoBpSjKoOniL zG)&LbeKWEewr4jAUZLT5j^0V>rs2mE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<=Qywq1grssb98+!ioovNz{W^<(0iau9Q(pW9%5P^(TR}2A2frEt#o#HTvxe%+7+is+5}+2W#JaF| z3P0$Wu%MA6`;r9?-@vguR>$7PmI|pzjgFC;okEv)MVB9AXC{}N)JpA6q2uge9Whvi zykf;ki}SAb0-Z4~JiVGT&f*vYA6TCqKHm>EVLqIrvI+Ic!o5GiH@ZkDAN8*f63LJb z7OkbsLheV+U^MDY^(^+!N~<|W>slLJJqNyeo`}vi!#a~AVncN?h^ocMnpQ865P6Lv zvt~{sFG&)wIOrYrN&!;SV3_gxCR3{|`0{16gt9W3*yOet=i}TFlYEj-aPxm!W0T>Hp}pp&t7jAS#D_}j($`Y31QvJ$D`_BhMVTu~bXj3leH&CjwGe?RNhE~) z5_Jj^AFh3owT4$m@J`AQRWaSRA@j+*zy9~Vo2VWQ98OVWWo8;)PEk1>!(j6PM{4K7 z+Id_gZuv=luK7dA=)wsA{3^*)M%;k2I8!o&EXI>zP>~E%Qtk-E zjlYDnP0@sNa*QDVmGb)eTiRU>B!2cEa*tqdt4ZydsLn2jQdqn;~U~h#i)B%^OC!2Im%I6RM;1m}HW2@hs1ENOskEsEcHQ2u2JuYH#a*s@=<^@feMmu39m@?v zrd8i1avUTxBS1HzK4_`0(AY{^Q9aFpe6$v~7I3DuqAN4$_?f_&O`6M!$1m4H4fdJU zQk1*bAfj5xt0L_^1P7k0;X*^O=M0KC&&e;3C3(2X%hZebYz8g)GKg575T=fOAiyIb zY(5I8FF%?v%;hrQ$DL*IXk3{8(O*?}=O=jyALhlJ(^^pRoC+Fwp-~ asyncio.Task[T]: + loop = asyncio.get_event_loop() + task = loop.create_task(coro) + _tasks.add(task) + task.add_done_callback(_tasks.remove) + return task + + +@dataclass +class Album: + media_group_id: str + messages: list[Message] + + +# chat_id: group_id: album +_albums: defaultdict[int, dict[str, Album]] = defaultdict(dict) + + +@app1.on_message(filters.media_group) +async def on_media_group(client: Client, message: Message): + try: + chat_id = message.chat.id + media_group_id = message.media_group_id + if media_group_id is None: + return + + if media_group_id not in _albums[chat_id]: + album = Album(messages=[message], media_group_id=media_group_id) + _albums[chat_id][media_group_id] = album + + async def task(): + await asyncio.sleep(1) + _albums[chat_id].pop(media_group_id, None) + try: + album.messages.sort(key=lambda m: m.id) + await on_album(client, album) + except Exception: + traceback.print_exc() + + background(task()) + else: + album = _albums[chat_id][media_group_id] + album.messages.append(message) + finally: + message.continue_propagation() + + +async def on_album(client: Client, album: Album): + """ + Обрабатывает новые альбомы + """ + if album.messages[0].chat.id == config.rent_channel_id: + await forward_post(client, album.messages[0], config.groups_for_rent) + if album.messages[0].chat.id == config.sell_channel_id: + await forward_post(client, album.messages[0], config.groups_for_sell) diff --git a/bot/config.py b/bot/config.py new file mode 100644 index 0000000..102d10a --- /dev/null +++ b/bot/config.py @@ -0,0 +1,26 @@ +import os +from dotenv import load_dotenv + +load_dotenv() + + +API_ID_1 = os.getenv("API_ID_1") +API_HASH_1 = os.getenv("API_HASH_1") + +admins: list[int] = [5899041406, 800530092, 1046931046] + +# Интвервал спама постов (в секундах) +spam_interval = 200 + + +# айди канала/группы берем из веб версии тг +# или с помощью @username_to_id_bot + +# Канал по аренде +rent_channel_id = -1002054380269 +# Канал по продаже +sell_channel_id = -1002123908331 + +# Группы для перессылки +groups_for_rent = ["-1002227589874_13"] +groups_for_sell = ["-1002227589874_13"] \ No newline at end of file diff --git a/bot/cyprus_off.session b/bot/cyprus_off.session new file mode 100644 index 0000000000000000000000000000000000000000..529f14260f96b0691d25d71736c1338134a4ceda GIT binary patch literal 45056 zcmeI)du&rx90%}ww?4LZ4-oM>=iFg)wlxE@AdE=>yY+4~Y#p?BymYDUdbc&Ow)EaI z20>ZfUjiXfGeVFc#6W`4s4-%EMM;PVC>TxrL(zZ+9GHkkP$m#h?_+B_XXH=H_onN; zJCENv=W~B;a+a>XWvyXZB;C-jCW>*%zcwJr{zNPkkVStqqLejxd8fb=!Ru~m;k{(CwiZGU zXR|+Qw3mlpF)JLJZ{a;I!D8ZORI5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;|fB*y_009U<00KEIfc<|C-&`yW0uX=z1Rwwb2tWV= z5P$##AfO3Y=$S3O%+Lo82tWV=5P$##AOHafKmY;|fB*z?M4&X^XjH%XPkmPR|CgB3 zOF6PYECT`%fB*y_009U<00Izz00ba#XA9h&Uu{hLB0%i_@9cEI>LCCD2tWV=5P$## zAOHafKp;m2Qv3h3Z~q_P|Kt1ra`cX4SrC8#1Rwwb2tWV=5P$##AOHbPAoclw?EjGt Z5P$##AOHafKmY;|fB*y_0D;^V_y; literal 0 HcmV?d00001 diff --git a/bot/cyprus_off.session-journal b/bot/cyprus_off.session-journal new file mode 100644 index 0000000000000000000000000000000000000000..fd949cecdc1e5f3122b9953035f7220c6514a724 GIT binary patch literal 29240 zcmeI)ze>YE90%}=F;*)Q2L%zFIy)5qgua2#;8H=_Nl;ok_zXURtM4HA1fnD^CrpH(?P{0D3Y1PBlyK!5-N z0t5&UAV8odP~`yU*H?qluzT6>&*uP*Ne(a$`M5U2kN^P!1PBlyK!5-N0t5&Uh*}^| zvusicFjo(dZj`%9@|RF{jQ{}x1PBlyK!5-N0t5&Uh(Tcg_WkR*XoQvRR%`j>@#gO0 z^Xzpr>LD^#HDeh~bc}kpKY#1PBlyK!5-N0t5&wE-=jjnsR`} z4b3D#fB*pk1PBlyK!5-N0 bool: + """Удаление сущесвтующей задачи по функции и времени""" + for t, r_t, task_instance in self.tasks: + if t == task and r_t == run_time: + task_instance.cancel() + self.tasks.remove((t, r_t, task_instance)) + return True + return False diff --git a/bot/sending.py b/bot/sending.py new file mode 100644 index 0000000..df6d0e4 --- /dev/null +++ b/bot/sending.py @@ -0,0 +1,108 @@ +import asyncio +import re +from datetime import datetime + +from pyrogram import Client +from pyrogram.types import Message, InputMedia, InputMediaPhoto + +from bot import config +from bot.loader import app1 + +from random import randint + + +NUMBER_POSTS = 20 + + +def get_number_posts(): + global NUMBER_POSTS + return NUMBER_POSTS + + +def set_number_posts(x: int): + global NUMBER_POSTS + NUMBER_POSTS = x + + +async def sending(): + """ + Функция для пересылки по расписанию. + """ + await forwards_to_chats(config.rent_channel_id, config.sell_channel_id, config.groups_for_rent, get_number_posts()) + # await forwards_to_chats(config.sell_channel_id, config.groups_for_sell, get_number_posts()) + + +# contains date: client: media groups +class DailyAlbums: + todays_albums = set() + + @classmethod + def add_album(cls, client: Client, media_group_id: int): + album_key = (client.api_id, datetime.now().strftime('%d.%m.%Y'), media_group_id) + cls.todays_albums.add(album_key) + + @classmethod + def contains_album(cls, client: Client, media_group_id: int) -> bool: + album_key = (client.api_id, datetime.now().strftime('%d.%m.%Y'), media_group_id) + return album_key in cls.todays_albums + + +async def fetch_posts(chat_id: int, daily_albums: DailyAlbums, limit: int): + """ + Получает посты из чата, проверяя, что они ещё не находятся в daily_albums. + """ + posts = [] + async for post in app1.get_chat_history(chat_id=chat_id, limit=200): + if post.media_group_id and post.caption and not daily_albums.contains_album(app1, post.media_group_id): + posts.append(post) + daily_albums.add_album(app1, post.media_group_id) + if len(posts) >= limit: + break + await asyncio.sleep(0.1) + return posts + + +async def forwards_to_chats(rent_channel_id: int, sell_channel_id: int, groups: list[str], limit: int): + """ + Пересылает посты из rent_channel_id и sell_channel_id в группы. + """ + if not groups: + return + + daily_albums = DailyAlbums() + messages = await fetch_posts(rent_channel_id, daily_albums, limit) + messages2 = await fetch_posts(sell_channel_id, daily_albums, limit) + + all_messages = messages + messages2 + for i in range(min(limit, len(all_messages))): + await forward_post(app1, all_messages[i], groups) + await asyncio.sleep(config.spam_interval) + + +def is_valid_time_format(time_str): + """Проверяют строку на формат HH:MM""" + time_pattern = re.compile(r'^[0-2][0-9]:[0-5][0-9]$') + return bool(time_pattern.match(time_str)) + + +def check_stop_sign(message: Message): + return "⛔️" in str(message.caption) or "⛔️" in str(message.text) + + +async def forward_post(client: Client, message: Message, groups: list[int, str]): + # === СТОП ЗНАК === + if check_stop_sign(message) or not (message.caption or message.text): + return + # =============================== + for spam_group in groups: + group_id, reply_id = (spam_group, None) if '_' not in str(spam_group) else list( + map(int, str(spam_group).split('_'))) + try: + if message.media_group_id: + await client.copy_media_group(chat_id=group_id, from_chat_id=message.chat.id, message_id=message.id, + reply_to_message_id=reply_id) + else: + await message.copy(group_id, reply_to_message_id=reply_id) + except Exception as e: + print(f"Ошибка: {e}\n\nГруппа: {group_id}\n\n-----------------------\n\n") + await asyncio.sleep(2) diff --git a/bot/test.py b/bot/test.py new file mode 100644 index 0000000..e704b13 --- /dev/null +++ b/bot/test.py @@ -0,0 +1,11 @@ +from pyrogram import Client + +api_id = 29370778 +api_hash = '9beeb54652c5ce4f323d67f57dc233be' + +with Client("my_account", api_id, api_hash) as app: + # Идентификатор чата, из которого вы хотите получить сообщения + chat_id = "your_chat_id" + # Количество сообщений, которые вы хотите получить (максимальное значение - 100) + me = app.get_me() + print(me) diff --git a/main.py b/main.py new file mode 100644 index 0000000..31696fb --- /dev/null +++ b/main.py @@ -0,0 +1,22 @@ +import asyncio + +from pyrogram import compose, idle + +from bot import config +from bot.loader import app1 + +from bot import handlers +from bot import album_handler + +def main(): + print("Bot started.") + # compose([app1]) + + print('test') + + app1.run() + + +if __name__ == '__main__': + # main() + main() \ No newline at end of file diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..dbc7d52 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,11 @@ +croniter==2.0.1 +pyaes==1.6.1 +https://github.com/KurimuzonAkuma/pyrogram/archive/dev.zip +PySocks==1.7.1 +python-dateutil==2.8.2 +python-dotenv==1.0.1 +pytz==2024.1 +six==1.16.0 +TgCrypto==1.2.5 +tzdata==2023.4 +tzlocal==5.2