The solution to simplicity.
Project description
LINELIB v2.2
The All-in-One LINE Bot Integration Solution.
Installation
Use the following, or clone this repository.
$ pip install -U linelib
🔑 Features.
✨ Optimized Source Code.
Cleaner source code is beneficial because it is easier to read, understand, and maintain. It's easier for you to add new features, fix bugs, and understand how the code works. Clean code is also more efficient, as it is optimized for performance and is less likely to contain errors or bugs. It is also more reusable, allowing you to use it in other projects without having to rewrite it.
🧩 With Extensions.
With LINELIB, you can easily and efficiently integrate various LINE services into your projects and applications, all with just a few lines of code. LINELIB simplifies the process of working with LINE services, making it more accessible and streamlined for developers of all skill levels. Whether you're looking to add messaging functionality, connect with LINE's social media platform, or utilize other LINE services, LINELIB makes it simple to do so with minimal code requirements.
LINELIB currently supports these LINE services:
- LINE Messaging API
- LINE Notify
- LINE Social Plugins
💪 More advanced.
Create text commands like a pro.
Linelib helps you to quickly and efficiently create text commands by organizing them inside cogs!
Ready to give it a shot?
Oh my goodness, you're here! I'm hyped to see that you're willing to give it a go.
Anyways, here are some helpful links that can get you around with LINELIB:
🎉 Examples.
"Don't just talk. Show me some examples!" I hear you say...
1: Quick Example
from linelib import Client
client = Client('channel secret', 'channel access token')
@client.event('ready')
async def ready():
print('I am ready!')
client.run()
2: LINE Notify Example
from linelib import Client
from linelib.notify import Notify
client = Client('channel secret', 'channel access token')
notify = Notify("access token")
@client.event('ready')
async def ready():
await notify.notify("Daily News:\nLinelib version 2 has released!!11!")
client.run()
3: Simple Command Cog
This is a simple cog with the command "hello", which requires one argument (times) in order to work.
User: hello 10
Bot: You greeted me 10 times!
from linelib import Client
from linelib.ext import commands
client = Client('channel secret', 'channel access token')
class MyCog(commands.Cog):
@commands.cog_command(name="hello")
async def greet_command(self, ctx, times: int):
# "self" is required!
await ctx.reply(f"You greeted me {times} times!")
client.load_cog(MyCog())
client.run()
4: Advanced Command Cog
This is a more advanced command cog with command rules, and rule rejection handlers.
The command (say) requires one argument "text", but you should add a "*" in the greet_command
coroutine function to tell linelib to pass the rest of the message content into the argument ("text").
User: say I love chocolate!
Bot: I love chocolate!
1 second later...
User: say I still love it.
Bot: The cooldown is 10 seconds long! Please wait.
from linelib import Client
from linelib.ext import commands, rule
client = Client('channel secret', 'channel access token')
class MyCog(commands.Cog):
@commands.cog_command(
name="say",
rule=rule.CommandRule(
rule="cooldown",
seconds=10
)
)
async def greet_command(self, ctx, *, text):
# "self" is required!
await ctx.reply(text)
@greet_command.rule_reject
async def rejected(self, ctx):
await ctx.reply('The cooldown is 10 seconds long! Please wait.')
client.load_cog(MyCog())
client.run()
5: Custom Rule (Advanced)
Custom rules must have a function named "handler". The handler must return a valid boolean (True
or False
).
True
represents that the user is able to use the command, vice versa.
from linelib.ext import rule
class MyRule(rule.CommandRule):
def handler(self, ctx):
# ... your awesome code
return True # must return True or False
MyRule(rule="based.custom") # Now, it's a valid command rule.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file linelib-2.2.6.tar.gz
.
File metadata
- Download URL: linelib-2.2.6.tar.gz
- Upload date:
- Size: 29.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 17d10dd60039998af683b37d5eb626fba16c2a448040137fe0dee0efbb6bf78c |
|
MD5 | be134074f191a831acf8152b6aabacd6 |
|
BLAKE2b-256 | 90472145b847bcfaf9de164f7ca1a264b73cf33091efb776994d7c342c3a6138 |