Check out v3 (linex) https://github.com/AWeirdScratcher/linex
The All-in-One LINE Bot Integration Solution.
Use the following, or clone this repository.
$ pip install -U linelib
π Features.
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
Create text commands like a pro.
Linelib helps you to quickly and efficiently create text commands by organizing them inside cogs!
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:
"Don't just talk. Show me some examples!" I hear you say...
from linelib import Client
client = Client('channel secret', 'channel access token')
@client.event('ready')
async def ready():
print('I am ready!')
client.run()
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()
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()
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()
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.