IRC bot functionalities - python

I'm learning Python and would like to start a small project. It seems that making IRC bots is a popular project amongst beginners so I thought I would implement one. Obviously, there are core functionalities like being able to connect to a server and join a channel but what are some good functionalities that are usually included in the bots? Thanks for your ideas.

Unless it's solely for the educational experience, you should really just use a framework for the core functionality.
That said, here's some of the things the bot in my home IRC channel does:
Choose one item from a list of options
Display a random entry from the Linux fortunes file
Display a random set of words from the Emacs spook file
Check every line from a user and display a quote from The Big Lebowski if it's sufficiently similar (this is probably a bit my-channel specific :) )
Check if a link has been mentioned before and say who/when (we all read the same RSS feeds and tend to duplicate links a lot)
Conduct a poll
Pull a given quote from our internal QDB
Check if a given link has been posted to Reddit, and give the corresponding Reddit thread link if so. If a Reddit link is posted, give the direct link instead
Track the last time a given nick was in the channel, and the last time they spoke
Queue a message for an offline nick that's automatically sent in-channel when they join
Use Google Translate to translate a given phrase
Post a given line to our channel's Twitter feed
Choose a random user and kick them (not the best idea depending on how unruly your channel is)
Pull the summary of a given term from Wikipedia and display it along with a link to the full article
Display information about any posted Youtube link (video title, length, submitter, votes, comments, etc.)

I'm also in the process of writing a bot in node.js. Here are some of my goals/functions:
map '#' command so the bot detects the last URI in message history and uses the w3 html validation service
setup a trivia game by invoking !ask, asks a question with 3 hints, have the ability to load custom questions based on category
get the weather with weather [zip/name]
hook up jseval command to evaluate javascript, same for python and perl and haskell
seen command that reports the last time the bot has "seen" a person online
translate command to translate X language string to Y language string
map dict to a dictionary service
map wik to wiki service

Again, this is an utterly personal suggestion, but I would really like to see eggdrop rewritten in Python.
Such a project could use Twisted to provide the base IRC interaction, but would then need to support add-on scripts.
This would be great for allowing easy IRC bot functionality to be built upon using python, instead of TCL, scripts.

That is very subjective and totally depends upon where the bot will be used. I'm sure others will have nice suggestions. But whatever you do, please do not query users arbitrarily. And do not spam the main chat periodically.

Make a google search to get a library that implements IRC protocol for you. That way you only need to add the features, those are already something enough to bother you.
Common functions:
Conduct a search from a wiki or google
Notify people on project/issue updates
Leave a message
Toy for spamming the channel
Pick a topic
Categorize messages
Search from channel logs

Related

Difference beetween using pyTelegramBotAPI and Telegram Bot API

I'm new to python and telegram bot programming, and I have been programming a telegram bot using pyTelegramBotAPI because the tutorials I followed used it, but I can't find no information on the internet about a definition/description about pyTelegramBotAPI and why should I use it instead of Telegram Bot API.
Can someone help me with these questions? I literally couldn't find these information on the internet. Thanks
pyTelegramBotAPI is a python implementation of the Telegram Bot API.
You're not choosing to use pyTelegramBotAPI instead of the Telegram Bot API - rather you're choosing to use pyTelegramBotAPI for the Telegram Bot API. This is one of numerous Python implementations and Python is just one of many languages that implementations are written in. If you really want, you can operate a Telegram Bot using shell commands.
In general terms, an implementation of a HTTP-based API written in a particular language simplifies building your program by allowing you to specify your ID's and credentials, and then simply calling functions to get things done, instead of having to engineer every call and include the paramaters manually or repetitively. It also takes care of constructing the requests and passing the paramaters in a compatible format to the server, while it may also provide some additional parsing to the paramaters provided to the abstracted functions.
Reasons you may wish to use pyTelegramBotAPI:
You like the features and functionality of pyTelegramBotAPI. I.e. You're looking for a framework for a project like one of these
You want a Python implementation of the Telegram Bot API without having to build it from scratch yourself.
You want a fairly comprehensive and extensible implementation of the Telegram Bot API (true at the time of writing this)
The Documentation explains what you need to be aware of, and how certain aspects translate to the API. I.e, there's a paragraph explaining the convention of method names has been modified to more idiomatic Python;
Methods
All API methods are located in the TeleBot class. They are renamed to
follow common Python naming conventions. E.g. getMe is renamed to
get_me and sendMessage to send_message.
There's also a note about the renaming of from to from_user
Reasons you may not want to use pyTelegramBotAPI
As mentioned above, pyTelegramBotAPI is maintained and updated regularly at the time of writing this. However, there's never a guarantee that code written by someone else will always be maintained in either it's original form or forked off and taken in a new direction.
You may choose against using something like this if:
Python is unavailable in your environment
You require an extremely simple and lightweight use of a bot and could maintain it quicker by referring directly to the official Telegram API reference.
You are looking to integrate to another project using a different language.
You aren't confident in extending the the code to suit your requirements.

Microsoft Team: How to automate triage task

Like we have slash commands in slack, which helps us to perform get or post
similar to do that do we have anything in Microsoft team and if yes are there any documentations.
I have built some slash commands using pythong in slack but i am not finding anything for teams.
In essence, Teams doesn't provide a 100% direct match to "/slash" commands, but there are equivalents, and they pretty much all involve the use of a Bot. In practice, it really just means going from "/" to "#", as you #mention the bot to invoke it, and it can proceed as needed from there.
That said, there are a few places where you might want to surface this. For instance, the "normal" place is in a chat inside a channel. To make this work, you -can- get away without a Bot, but a Bot is the easiest. If you want to do something outside a channel, like just invoking the bot directly, there are two options - interact with the bot in a 1-1 style (in which case the bot appears in the "chat" left menu, as if it were another user). In this case, incidentally, you don't "#mention" the bot because it's the only other person in the chat. The other option is the command text block right at the top of the screen in Teams. In this case, you can have the bot open UI to send it parameters in a guided form, even.
So, in short, there are similar options to "slash" commands in Teams, but for the most part they involve Bots, so you should look into that more. In particular, look at the Teams development docs for Bots, Message Extensions, and Task Modules.
I suggest you also have a look at Create a bot with the Bot Framework SDK for Python.
You could Add custom bots to Microsoft Teams with outgoing webhooks. A webhook is essentially a POST request sent to a callback URL.

How to provide selection options as response in ChatterBot

I am creating a chat bot using python chatter bot library. I am able to train the chat bot in the English language. Next thing I want to accomplish is to build a chat bot to provide selection options to the user for filtering the data.
Example:
Request from user is Book a movie ticket.
I want to display the response as 3 buttons
In which time slot you want to book a movie ticket ?
a. Morning
b. Afternoon
c. Evening.
Is there any feature in Python ChatterBot to send back selection options as response to the user.
You can't get that type of response using GuntherCox's chatterbot Library considering the last stable version.
Read the following documentation to know more: Documentation Link
Else you can raise a issue and also here is their code base for your consideration to look deep down into it: Github Link
If you want intent and entity based chatbot you can look into Snips-nlu and Rasa.
https://github.com/snipsco/snips-nlu
https://github.com/RasaHQ/rasa
So far what I have seen is that chatterbot can only provide static responses. Snips has module for generating json dataset from yaml file where you can define intents, entities, multiple slots etc.
https://snips-nlu.readthedocs.io/en/latest/dataset.html
Rasa can provide what you are looking for. Provide response options based question. Provides easy training, HTTP API, python SDK etc.
https://rasa.com/docs/rasa/user-guide/rasa-tutorial/
Finally, this is a tool for generating training data for snips, rasa and others.
https://rasa.com/docs/rasa/user-guide/rasa-tutorial/

Python - reply to all top-level comments in a particular thread

I'm looking to write a simple Python 3 bot for reddit which will reply to all top-level comments in a thread with a particular title, in a particular subreddit.
For example:
Bot scans /r/testsubreddit for the most recent post with the title 'bot trigger'
Bot replies to all top-level comments in that thread with a random string from a predefined list
What's the best way to go around doing this?
Thanks.
I think it's a valid question. You asked "How do I go about doing this?", not "Build this for me", which is certainly a valid question for a programming Q&A website.
I see two possible routes you could go:
Using a library of your choice (I would use requests) to make some network calls to the Reddit API. There's a lot to digest on that page, but to get started with OAuth, which you need in order to make a bot that's more than just read-only, check out this guide.
Using an existing framework, such as PRAW. I love using PRAW, although again, if you've never done anything like this before, it's kind of tricky to figure out. Follow along with some of the examples under Quick Start -> Common Tasks to get your feet wet. I think you'll find it relatively straight forward after first writing some basic scripts to get submissions, get comments from submissions, and automate comment replies.
After you've gotten oriented, your basic algorithm is simple:
Get your auth headers (or Reddit instance if you're using PRAW)
Get the submission you want to target
Get all of the top-level comments on that submission
Loop through them and reply however you want
If you get stuck, you can ask PRAW questions at http://reddit.com/r/redditdev, or come talk to me at my sub, http://reddit.com/r/redditscripting.
Once you have some initial code going, your fellow programmers will respond a little more warmly to your requests for help :-)
Happy coding!

Adding account and more user-friendly integration into Twitch bot

Lately, I've worked on a chat bot of my own for twitch.tv, connecting using the IRC channel and using a python script as well as logs from HexChat, my IRC client, to build my bot, which currently can give(upon query) the uptime of the channel, and statistics on emotes in the channel.
However, I have seen Moobot and Nightbot, 2 of the most popular chat bots on twitch, and was wondering how I could:
1) Turn this python script into something a streamer can authorize to be on their channel,
2) Hook up a GUI to this, or a series of text fields for the user to input their settings for the bot while it runs on their channel.
I have looked at previous questions on StackOverflow, looked on Google, and asked in the #twitch-api IRC channel on freenode, however none of these provided the answer, and the only bots I have seen that have this channel-bot integration and authorization are Moobot and Nightbot. Upon clicking "connect to twitch" on moobot's homepage, I can authorize it to use my account much like an oauth request, however I do not know how to set this up. I hope this will help others like me wanting to add some extra usability to their WIP Twitch Chat bot. Thanks!
Moobot: http://twitch.moobot.tv/
Nightbot: https://www.nightbot.tv/
Most of the "big" server-hosted bots consist of 4 major parts:
A database (SQL or NoSQL) holding all the settings etc.
A REST (or similar) API that is used to communicate between the individual parts
A web application for the frontend
A standalone bot for the backend
Keep in mind that this is alot of work to set up. I am currently working on a full rewrite of my bot, which I would share if it wasnt in a pre-alpha state.
Keep in mind that setting up these individual parts might require an experienced web developer. Here is some tips however:
Using python, Django is a great decision for a web application + API backend
As far as I know, there is no decent IRC library for python supporting IRC v3 so you might have to implement your own. Sample implementation of the message parser
Apart from that, see the Twitch.tv API documentation - this includes the Authentification workflow.
If you are looking for a locally-hosted bot, that's a completely different thing to deal with. There is a fair amount of those, some of which are open source too. I dont know any low-level ones, but maybe looking at Botnak, made by a friend of mine, answers some questions.

Categories

Resources