rulog


Namerulog JSON
Version 1.0.0 PyPI version JSON
download
home_pagehttps://github.com/Mahdy-Ahmadi/rulog
SummaryRubika: A Python library for interacting with the Rubika Login APi.
upload_time2025-11-03 22:09:51
maintainerMahdi Ahmadi
docs_urlNone
authorMahdi Ahmadi
requires_python>=3.6
licenseMIT
keywords rubika bot api library chat messaging rubpy pyrubi rubigram rubika_bot rubika_api fast_rub
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
# Rubika Login Example

This is a simple example showing how to use the `rulog` Python library to:

1. Send a verification code to a phone number.
2. Login to Rubika using the received code.
3. Register the device.

---

## Installation

Make sure you have installed the `rulog` library:

```bash
pip install rulog
```

---

## Example Code

```python
from rulog import Client

# Create a Client instance
Client = Client()

# ===== Send code =====
def send_code(phone):
    try:
        # Try sending via Android platform with send_type=True
        response = Client.sendCode("android", phone, send_type=True)
        return response['data']['phone_code_hash']
    except Exception as e:
        print("❌ Android send failed. Trying Web...")
        try:
            response = Client.sendCode("web", phone)
            return response['data']['phone_code_hash']
        except Exception as e:
            print("❌ Sending code failed:", e)
            return None

# ===== Login =====
def login(phone, hash_code, code):
    try:
        response = Client.signIn("android", phone, hash_code, code)
        print("✅ Login successful.")
        return response
    except Exception as e:
        print("❌ Login failed:", e)
        return None

# ===== Register device =====
def register(auth, key):
    try:
        result = Client.register(platform="android", auths=auth, keys=key)
        if result:
            print("✅ Registration successful.")
            return True
        else:
            print("❌ Registration failed.")
            return False
    except Exception as e:
        print("❌ Registration error:", e)
        return False

# ===== Main execution =====
if __name__ == "__main__":
    phone = input("📱 Enter your phone number (e.g., 9891...): ").strip()

    hash_code = send_code(phone)
    if not hash_code:
        print("🚫 Code sending failed. Exiting.")
        exit()

    code = input("🔢 Enter the received code: ").strip()
    login_response = login(phone, hash_code, code)

    if login_response:
        register(login_response['Auth'], login_response['Key'])
```

---

### How it works

1. **Send code**: Sends a verification code to the phone using Android first, then Web if failed.
2. **Login**: Signs in using the phone number, hash code, and received code.
3. **Register**: Registers the device using the authentication keys received after login.

---

### Notes

- Ensure your phone number format is correct.
- The script handles simple retries for sending codes.
- The library `rulog` must be installed.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/Mahdy-Ahmadi/rulog",
    "name": "rulog",
    "maintainer": "Mahdi Ahmadi",
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": "mahdiahmadi.1208@gmail.com",
    "keywords": "rubika bot api library chat messaging rubpy pyrubi rubigram rubika_bot rubika_api fast_rub",
    "author": "Mahdi Ahmadi",
    "author_email": "mahdiahmadi.1208@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/1e/0e/0352bcfc061fc0200b71aa4bc26297f3cc5ba17d3da59a9809744cbce83b/rulog-1.0.0.tar.gz",
    "platform": null,
    "description": "\r\n# Rubika Login Example\r\n\r\nThis is a simple example showing how to use the `rulog` Python library to:\r\n\r\n1. Send a verification code to a phone number.\r\n2. Login to Rubika using the received code.\r\n3. Register the device.\r\n\r\n---\r\n\r\n## Installation\r\n\r\nMake sure you have installed the `rulog` library:\r\n\r\n```bash\r\npip install rulog\r\n```\r\n\r\n---\r\n\r\n## Example Code\r\n\r\n```python\r\nfrom rulog import Client\r\n\r\n# Create a Client instance\r\nClient = Client()\r\n\r\n# ===== Send code =====\r\ndef send_code(phone):\r\n    try:\r\n        # Try sending via Android platform with send_type=True\r\n        response = Client.sendCode(\"android\", phone, send_type=True)\r\n        return response['data']['phone_code_hash']\r\n    except Exception as e:\r\n        print(\"\u274c Android send failed. Trying Web...\")\r\n        try:\r\n            response = Client.sendCode(\"web\", phone)\r\n            return response['data']['phone_code_hash']\r\n        except Exception as e:\r\n            print(\"\u274c Sending code failed:\", e)\r\n            return None\r\n\r\n# ===== Login =====\r\ndef login(phone, hash_code, code):\r\n    try:\r\n        response = Client.signIn(\"android\", phone, hash_code, code)\r\n        print(\"\u2705 Login successful.\")\r\n        return response\r\n    except Exception as e:\r\n        print(\"\u274c Login failed:\", e)\r\n        return None\r\n\r\n# ===== Register device =====\r\ndef register(auth, key):\r\n    try:\r\n        result = Client.register(platform=\"android\", auths=auth, keys=key)\r\n        if result:\r\n            print(\"\u2705 Registration successful.\")\r\n            return True\r\n        else:\r\n            print(\"\u274c Registration failed.\")\r\n            return False\r\n    except Exception as e:\r\n        print(\"\u274c Registration error:\", e)\r\n        return False\r\n\r\n# ===== Main execution =====\r\nif __name__ == \"__main__\":\r\n    phone = input(\"\ud83d\udcf1 Enter your phone number (e.g., 9891...): \").strip()\r\n\r\n    hash_code = send_code(phone)\r\n    if not hash_code:\r\n        print(\"\ud83d\udeab Code sending failed. Exiting.\")\r\n        exit()\r\n\r\n    code = input(\"\ud83d\udd22 Enter the received code: \").strip()\r\n    login_response = login(phone, hash_code, code)\r\n\r\n    if login_response:\r\n        register(login_response['Auth'], login_response['Key'])\r\n```\r\n\r\n---\r\n\r\n### How it works\r\n\r\n1. **Send code**: Sends a verification code to the phone using Android first, then Web if failed.\r\n2. **Login**: Signs in using the phone number, hash code, and received code.\r\n3. **Register**: Registers the device using the authentication keys received after login.\r\n\r\n---\r\n\r\n### Notes\r\n\r\n- Ensure your phone number format is correct.\r\n- The script handles simple retries for sending codes.\r\n- The library `rulog` must be installed.\r\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Rubika: A Python library for interacting with the Rubika Login APi. ",
    "version": "1.0.0",
    "project_urls": {
        "Bug Tracker": "https://t.me/Bprogrammer",
        "Documentation": "https://github.com/Mahdy-Ahmadi/rulog/",
        "Homepage": "https://github.com/Mahdy-Ahmadi/rulog",
        "Source Code": "https://github.com/Mahdy-Ahmadi/rulog/tree/main/rulog"
    },
    "split_keywords": [
        "rubika",
        "bot",
        "api",
        "library",
        "chat",
        "messaging",
        "rubpy",
        "pyrubi",
        "rubigram",
        "rubika_bot",
        "rubika_api",
        "fast_rub"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "8b6d66dfa7baac4f63ef88963cdf4ee0df366675bb5432d8ebad8383c54f9e04",
                "md5": "8f6899a1683222e2b43277a9ffeb771b",
                "sha256": "d31952e746d7f32da06b0c6c8af8557bd74c5e46cc26ebff7bf315a0e563a0b9"
            },
            "downloads": -1,
            "filename": "rulog-1.0.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "8f6899a1683222e2b43277a9ffeb771b",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 11492,
            "upload_time": "2025-11-03T22:09:50",
            "upload_time_iso_8601": "2025-11-03T22:09:50.541016Z",
            "url": "https://files.pythonhosted.org/packages/8b/6d/66dfa7baac4f63ef88963cdf4ee0df366675bb5432d8ebad8383c54f9e04/rulog-1.0.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "1e0e0352bcfc061fc0200b71aa4bc26297f3cc5ba17d3da59a9809744cbce83b",
                "md5": "5ce6f16d8078e9530ac71737934e72ca",
                "sha256": "f00a228e86151777b0f86a620cc564e40c40d4047e11bff8abd7731b64aa7d9c"
            },
            "downloads": -1,
            "filename": "rulog-1.0.0.tar.gz",
            "has_sig": false,
            "md5_digest": "5ce6f16d8078e9530ac71737934e72ca",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 11078,
            "upload_time": "2025-11-03T22:09:51",
            "upload_time_iso_8601": "2025-11-03T22:09:51.943902Z",
            "url": "https://files.pythonhosted.org/packages/1e/0e/0352bcfc061fc0200b71aa4bc26297f3cc5ba17d3da59a9809744cbce83b/rulog-1.0.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-11-03 22:09:51",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Mahdy-Ahmadi",
    "github_project": "rulog",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "rulog"
}
        
Elapsed time: 2.11265s