https://github.com/aweirddev/linex
✨ The fast and easy-to-use LINE bot SDK.
https://github.com/aweirddev/linex
line line-bot line-sdk python
Last synced: about 1 month ago
JSON representation
✨ The fast and easy-to-use LINE bot SDK.
- Host: GitHub
- URL: https://github.com/aweirddev/linex
- Owner: AWeirdDev
- License: mit
- Created: 2023-08-15T04:07:15.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-10-28T03:26:04.000Z (over 1 year ago)
- Last Synced: 2025-03-12T16:05:14.640Z (about 2 months ago)
- Topics: line, line-bot, line-sdk, python
- Language: Python
- Homepage: https://pypi.org/project/linex
- Size: 107 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
The fast and easy-to-use LINE bot SDK. Focus on the content, we do the rest.
[](https://github.com/ramptix)
## Features
It's (or it has):
- Based on [FastAPI](https://fastapi.tiangolo.com)
- Feature-rich
- Async-ready
- Around 60% coverage of the LINE API [(Contribute)](https://github.com/AWeirdScratcher/linex/fork)
- Better type hints than [linelib](https://github.com/AWeirdScratcher/linelib) (my previous work)(Not affiliated with The X Corp.)
## Feel The Simplicity
Code snippets explain more than words. Take a look:
```python
from linex import Client, TextMessageContextclient = Client("channel secret", "channel access token")
@client.event
async def on_ready():
print(f"Logged in as {client.user.name}")@client.event
async def on_text(ctx: TextMessageContext):
await ctx.reply("Hello, World!")client.run()
```That's it. Say no more to additional setups — they're so annoying!
## Documentation
Currently, there is no documentation for LineX — yet I'm working on it. In the meantime, type hints and code editors are the best documentation sources.
## Extensions
### Notify Support
LineX also supports LINE notify, including push message sending and OAuth2.
Here's a simple notify bot:
```python
from linex.ext import Notifynotify = Notify("access token")
notify.notify_sync(
"Hello, World!"
)
```### Locale
Have users that use different languages? Try out the `Locale` extension.
First, define a file structure like so:
```haskell
i18n/
├─ _meta.json
├─ food.json
```Inside of `_meta.json`, define the available locales:
```json
{
"locales": ["en-US", "zh-Hant"]
}
```The locales above are just examples.
Then, create any JSON file with a specific topic (category) under the directory that stores locale strings.
In this case, `food.json` would look like:
```json
{
"pizza": {
"en-US": "pizza",
"zh-Hant": "披薩"
},
"describe": {
"en-US": "{food} tastes good!",
"zh-Hant": "{food} 很好吃!"
}
}
```The first key (`pizza`) and the second one (`describe`) stores locale strings with keys defined in the `locales` field in `_meta.json`.
Additionally, if you add texts surrounded by `{}`, it would be considered as an argument that's ready to be passed in. In the above example, `"{food} tastes good!"`, implies that the `{food}` field would be replaced with a food name later in the Python code.
Finally, define our LINE bot:
```python
from linex import Client
from linex.ext import Localeclient = Client("channel secret", "channel access token")
locale = Locale(
"i18n", # the locale strings directory
sorted_by="categories" # files split by categories
)@client.event
async def on_text(ctx):
loc = await locale(ctx) # get locale for this user
await ctx.reply(
loc(
"food/describe", # use / to get
food=loc("food/pizza") # the argument (pizza)
)
)client.run()
```***
(c) 2023 AWeirdScratcher (AWeirdDev)