किसी मैसेज पर दी गई प्रतिक्रिया को मिटाना

इस गाइड में, Reaction संसाधन पर delete तरीके को इस्तेमाल करने का तरीका बताया गया है का इस्तेमाल किया जा सकता है. किसी प्रतिक्रिया को मिटाने से मैसेज नहीं मिटता.

कॉन्टेंट बनाने Reaction संसाधन इससे किसी ऐसे इमोजी का पता चलता है जिसका इस्तेमाल करके लोग किसी मैसेज पर प्रतिक्रिया दे सकते हैं. जैसे, 👍, EmailAddress, और ×.

ज़रूरी शर्तें

Python

  • Python 3.6 या इससे नया वर्शन
  • पीआईपी पैकेज मैनेजमेंट टूल
  • Python के लिए, Google की नई क्लाइंट लाइब्रेरी. उन्हें इंस्टॉल या अपडेट करने के लिए, अपने कमांड-लाइन इंटरफ़ेस में यह कमांड चलाएं:

    pip3 install --upgrade google-api-python-client google-auth-oauthlib
    
  • ऐसा Google Cloud प्रोजेक्ट जिसमें Google Chat API चालू हो और उसे कॉन्फ़िगर किया गया हो. इसका तरीका जानने के लिए, यह देखें कोई Google Chat ऐप्लिकेशन बनाएं.
  • Chat ऐप्लिकेशन के लिए अनुमति देने की सेटिंग को कॉन्फ़िगर किया गया. मिटाई जा रही है प्रतिक्रिया देने की ज़रूरत है उपयोगकर्ता की पुष्टि करना chat.messages.reactions या chat.messages अनुमति के दायरे के साथ.

प्रतिक्रिया मिटाना

किसी मैसेज से प्रतिक्रिया मिटाने के लिए, अपने अनुरोध में यह जानकारी दें:

  • अनुमति देने के लिए, chat.messages.reactions या chat.messages की जानकारी दें दायरा.
  • कॉल करें delete तरीका पूरी तरह कैसे Reaction संसाधन.
  • प्रतिक्रिया मिटाने के लिए, उसके संसाधन के नाम पर name सेट करें.

नीचे दिया गया उदाहरण किसी मैसेज से 😀 प्रतिक्रिया मिटा देता है:

Python

  1. अपनी वर्किंग डायरेक्ट्री में, chat_reaction_delete.py नाम की फ़ाइल बनाएं.
  2. chat_reaction_delete.py में यह कोड शामिल करें:

    from google_auth_oauthlib.flow import InstalledAppFlow
    from googleapiclient.discovery import build
    
    # Define your app's authorization scopes.
    # When modifying these scopes, delete the file token.json, if it exists.
    SCOPES = ["https://www.googleapis.com/auth/chat.messages.reactions"]
    
    def main():
        '''
        Authenticates with Chat API via user credentials,
        then deletes a reaction to a message.
        '''
    
        # Authenticate with Google Workspace
        # and get user authorization.
        flow = InstalledAppFlow.from_client_secrets_file(
                          'client_secrets.json', SCOPES)
        creds = flow.run_local_server()
    
        # Build a service endpoint for Chat API.
        chat = build('chat', 'v1', credentials=creds)
    
        # Use the service endpoint to call Chat API.
        result = chat.spaces().messages().reactions().delete(
    
            # The reaction to delete.
            #
            # Replace SPACE with a space name.
            # Obtain the space name from the spaces resource of Chat API,
            # or from a space's URL.
            #
            # Replace MESSAGE with a message name.
            # Obtain the message name from the response body returned
            # after creating a message asynchronously with Chat REST API.
            #
            # Replace REACTION with a reaction name.
            # Obtain the reaction name from the reaction resource of Chat API.
            name = 'spaces/SPACE/messages/MESSAGE/reactions/REACTION'
    
        ).execute()
    
    if __name__ == '__main__':
        main()
    
  3. कोड में, इन्हें बदलें:

    • SPACE: स्पेस का नाम, जिसे यहां से ऐक्सेस किया जा सकता है यह spaces.list तरीका या स्पेस के यूआरएल से मिलेगी.
    • MESSAGE: मैसेज का नाम, जिसे आप पा सकते हैं एसिंक्रोनस तरीके से मैसेज बनाने के बाद, रिस्पॉन्स वाले मुख्य हिस्से से Chat API से या पसंद के मुताबिक बनाया गया नाम बनाते समय एक मैसेज असाइन किया गया.
    • REACTION: प्रतिक्रिया का नाम, जिसे देखा जा सकता है से spaces.messages.reactions.list तरीका को Chat API में या इसके बाद जवाब के मुख्य हिस्से से Chat API की मदद से, एसिंक्रोनस तरीके से प्रतिक्रिया दे सकते हैं.
  4. अपनी वर्किंग डायरेक्ट्री में, सैंपल बनाएं और चलाएं:

    python3 chat_reaction_delete.py
    

अगर अनुरोध स्वीकार हो जाता है, तो जवाब का मुख्य हिस्सा खाली होता है. इससे पता चलता है कि प्रतिक्रिया हटाया गया.