Package: cifrepltalk
IntroductionDocumentation can be foundhereCIFReplTalkis arepl.ittalk bot framework intended for making high-quality asyncio-based bots, This project was inspired byIreTheBOT, arepl.ittalk bot made byIreTheKIDwhich now uses theCIFReplTalkframework.Getting StartedThis section is dedicated to getting started with theCIFReplTalkbot framework.InstallationTo install the framework you can either follow the tutorial on thehomepageto install the full cif framework or if you would prefer to only install theCIFReplTalkframework by itself read on.GitTo installCIFReplTalkvia the git CLI use the command that follows.git clone https://github.com/@CIFProject/repltalkThencdinto your newrepltalkdirectory and runpip install -r requirements.txtto install the necessary dependencies and finallypython setup.py installto install thecifrepltalkpackage for use in your python projects.Repl.itIt is recommended to use the repl locatedhereto grab your copy ofCIFReplTalkfrom thecifrepltalkand paste it into acifrepltalkin your own project.A Simple BotNow, let us make a simplerepl.ittalk bot that responds to a few commands.import cifrepltalk # import the cifrepltalk package
from datetime import datetime # for time stuff

client = cifrepltalk.Bot(prefix='$[<your prefix here>]') # create an instance of the 'Bot' class

signer = cifrepltalk.Signer('<your bot account's repl.it username>', '<your bot account password>')
token = signer.sign('<your repl.it username>') # get the token

async def hello(ctx, *args):
    return 'hello!'

async def echo(ctx, *args):
    return ' '.join(list(args))

async def date(ctx, *args):
    return str(datetime.now())

client.login(token)
client.handler.assign('hello' hello)
client.handler.assign('echo', echo)
client.handler.assign('date', date)
client.run('<a post id here>')Let us name this file asexamplebot.py, don't name itcifrepltalkor it will conflict with the library.Here is what this code does:1.The first line imports thecifrepltalkmodule for use in the script.2.The second line importsdatetimefrom the python starndard librarydatetimefor thetime command.3.Next, we create an instance of theBotclass with our chosen prefix and store it in a variable calledclient.4.Then, we need to create an instance of theSignerclass with our bot'srepl.itaccount username and password and store it in thesignervariable.5.Now we get the token from oursignerobject by supplying ourrepl.itusername and store it intoken.6.In these nest few lines we define anasyncfunction calledhellowith therequiredarguments ofctxand the positional arguments gatherer*args, with a return value of'hello!'.7.Next, we make anotherasyncfunction calledechowith the samerequiredarguments but, this time it returns all of the arguments as ajointstring.8.For this function we make anotherasyncfunction with the same args and a return value ofdatetime.now()to get the current time.9.In this line we login with the token stored intoken.10.Next we useclient.handler.assign()to assign'hello'to the functionhello.11.Then we repeat the same step but for'echo'andecho.12.Again the same step but for'date'anddate.13.Finally, we run the bot on a post by id. (Note:By default CIFReplTalk only runs on a single post, this can be changed. SeeCustom Handlers)Now we have made the bot we have torunit.cmd:python3 examplebot.pypowershellpy -3 examplebot.pybash and others:python3 examplebot.pyNow play around with the bot.