summaryrefslogtreecommitdiff
path: root/indoteknik_custom/models/website_telegram.py
diff options
context:
space:
mode:
authorit-fixcomart <it@fixcomart.co.id>2024-12-10 13:21:14 +0700
committerit-fixcomart <it@fixcomart.co.id>2024-12-10 13:21:14 +0700
commit1bf746c93dc5010e30490d0a5ed6a2a174726be0 (patch)
tree27be1d61e8d5985e4d202a2723a063445f782348 /indoteknik_custom/models/website_telegram.py
parentbab6a911535b771e988093725e0ba378c77297c6 (diff)
<iman> update code telegram print so when amount > 200jt
Diffstat (limited to 'indoteknik_custom/models/website_telegram.py')
-rw-r--r--indoteknik_custom/models/website_telegram.py43
1 files changed, 25 insertions, 18 deletions
diff --git a/indoteknik_custom/models/website_telegram.py b/indoteknik_custom/models/website_telegram.py
index 58816fe2..92707ea2 100644
--- a/indoteknik_custom/models/website_telegram.py
+++ b/indoteknik_custom/models/website_telegram.py
@@ -35,7 +35,7 @@ class WebsiteTelegram(models.Model):
'1BVtsOJABu30MWCBFwYvvaYbFoIWi43r5a7TUZ2IWwrnSlXIwEhJS5k2y4UKjoDeMPKwhgUWn9lMk02zQjM0ZDzq61YyhkRBvZuu3hCxMsrtP92bkuZtL2g3g1VgI8s7rMhOD_WaGrZbuj-TmbTwIEbN5i1J4raDW2kYzmlLRCbT74xxrGjpzWCnVv7CSS9L2juXuut0lLMgli3_JZbqDO1IyBYh4ZFQYbMf7zv6moDR4MQp1qfnFArsikQcfxjlNXKFcSoyA_GjiIFfCuymwQVtdERXOAH03M_lm8fYbjvgxEkJvxR6hdCnYMcKpIujEEo9SmMmK7Vnl29g1TCPO5tlrDNXq3Ng='),
27799517, 'df8ee44b0ed11108245037d47b511201') as client:
result = await client(functions.channels.CreateChannelRequest(
- title='Permintaan retur ' + self.tittle,
+ title=self.tittle + ' Telah Diprint',
about=self.about,
broadcast=False,
megagroup=True,
@@ -45,30 +45,30 @@ class WebsiteTelegram(models.Model):
peer=InputPeerChannel(channel_id=channel.channel_id, access_hash=result.chats[0].access_hash),
))
self.invite_link = channel_link.link
- # username_to_add = ['@imsep81', '6285764475716', '@stephanchrst']
- username_to_add = ['@radiant81']
+ # username_to_add = ['@radiant81', '6285764475716', '@stephanchrst']
+ username_to_add = ['6282339129611']
for name in username_to_add:
user_to_add = await client.get_entity(name)
result_add_user = await client(functions.channels.InviteToChannelRequest(
channel=channel,
users=[user_to_add.id],
))
- message = 'https://erp.indoteknik.com/web#id=' + self.id_data + '&action=209&model=stock.picking&view_type=form&cids=1&menu_id=101'
+ message = 'https://erp.indoteknik.com/web#id=' + self.id_data + '&action=209&model=sale.order&view_type=form&cids=1&menu_id=101'
result_massage = await client(SendMessageRequest(channel, message))
# Send the poll to the channel using PeerChannel with the channel's ID
- result_polling = await client(SendMediaRequest(
- peer=InputPeerChannel(channel_id=channel.channel_id, access_hash=result.chats[0].access_hash),
- media=InputMediaPoll(poll=Poll(
- question=TextWithEntities(text="ASK RETURN?", entities=[]),
- answers=[
- PollAnswer(text=TextWithEntities(text="Accept", entities=[]), option=b'\x01'),
- PollAnswer(text=TextWithEntities(text="Reject", entities=[]), option=b'\x02'),
- ],
- id=2
- )),
- message='Ask Return Polling'
- ))
+ # result_polling = await client(SendMediaRequest(
+ # peer=InputPeerChannel(channel_id=channel.channel_id, access_hash=result.chats[0].access_hash),
+ # media=InputMediaPoll(poll=Poll(
+ # question=TextWithEntities(text="ASK RETURN?", entities=[]),
+ # answers=[
+ # PollAnswer(text=TextWithEntities(text="Accept", entities=[]), option=b'\x01'),
+ # PollAnswer(text=TextWithEntities(text="Reject", entities=[]), option=b'\x02'),
+ # ],
+ # id=2
+ # )),
+ # message='Ask Return Polling'
+ # ))
def receive_messages(self):
return asyncio.run(self._async_receive_messages())
@@ -101,12 +101,19 @@ class WebsiteTelegram(models.Model):
return accept_found
def send_to_telegram(self, message):
- apiURL = f'https://api.telegram.org/bot{self.bot_name}/sendMessage'
+ # apiURL = f'https://api.telegram.org/bot{self.bot_name}/sendMessage'
try:
- requests.post(apiURL, json={'chat_id': self.chatID, 'text': message})
+ # requests.post(apiURL, json={'chat_id': self.chatID, 'text': message})
+ asyncio.run(self._async_send_to_telegram(message))
except Exception as e:
print(e)
+ async def _async_send_to_telegram(self, message):
+ async with TelegramClient(StringSession(
+ '1BVtsOJABu30MWCBFwYvvaYbFoIWi43r5a7TUZ2IWwrnSlXIwEhJS5k2y4UKjoDeMPKwhgUWn9lMk02zQjM0ZDzq61YyhkRBvZuu3hCxMsrtP92bkuZtL2g3g1VgI8s7rMhOD_WaGrZbuj-TmbTwIEbN5i1J4raDW2kYzmlLRCbT74xxrGjpzWCnVv7CSS9L2juXuut0lLMgli3_JZbqDO1IyBYh4ZFQYbMf7zv6moDR4MQp1qfnFArsikQcfxjlNXKFcSoyA_GjiIFfCuymwQVtdERXOAH03M_lm8fYbjvgxEkJvxR6hdCnYMcKpIujEEo9SmMmK7Vnl29g1TCPO5tlrDNXq3Ng='),
+ 27799517, 'df8ee44b0ed11108245037d47b511201') as client:
+ channel = await client.get_entity(self.invite_link)
+ result_massage = await client(SendMessageRequest(channel, message))
def test_send(self):
try:
self.env.cr.savepoint()