A bot for Large Fry Larrys

Overview

GroupMe Bot Driver

contributions welcome GitHub last commit

This driver is written entirely in Python, and with easy configuration in mind.

Using this driver, you'll be able to monitor multiple group chats with ease and set custom rules for each one (or the same for all, if that's what you want). For easy maintenance, each group's rules will be kept in their own files. I have also taken care to make debugging simple and logs easy to read, but more on that later.

Deploying the bot

This driver has been built to run on Heroku. If you don't have an account, register at signup.heroku.com. You can likely run this bot elsewhere, but as of yet only Heroku has been verified as working.

The steps here might look daunting if you are unfamiliar, but I tried making them as easily understood and step-by-step as possible. If there are any issues, feel free to open a ticket.

Steps for using GitHub Desktop on Windows will be added shortly, along with steps for using HerokuGit instead of GitHub.

Linux command line

  1. Create a new repository on github. See this page for help.
    • Ensure the repo is private. More on this later.
  2. Open the terminal, and enter these commands where *USERNAME* is your github username and *REPO* is your new repository name.
$ git clone --mirror https://github.com/paulpfeister/groupme-botdriver.git
$ cd groupme-botdriver.git
$ git remote set-url --push origin https://github.com/*USERNAME*/*REPO*.git
$ git push --mirror
  1. Create a new app on your Heroku dashboard
    1. Click Create new app in the dropdown menu labled New (top right corner).
    2. Create a name for your app. This won't be seen by your users.
    3. Under Deployment Method, click GitHub.
    4. Link your account and select your respository.
      • Enabling automatic deploys is recommended. Doing so will simplify the process. Otherwise, you will have to manually deploy each time you update the bot or change rules. If you enable automatic deploys, check that Wait for CI to pass... is disabled.
    5. Finally, click Open app on the top right. Take note of this url.
    6. Leave Heroku open for now.
  2. Register your bot at dev.groupme.com/bots/new
    • The name you pick here will be visible to your users. This only applies to the group selected here.
    • The link you saved before goes in Callback URL (https://my-app-name.herokuapp.com/)
    • You can ignore Avatar URL for now, unless you have a picture in mind.
    • Take note of your Bot ID and Group ID. Keep this information to yourself.
  3. Return to Heroku and configure your bot.
    1. Under the Settings tab (when within your app's dashboard), click Reveal Config Vars.
    2. Define key BOT_INFO for your group.
      • Value should equal GROUP_ID, BOT_ID, BOT_NAME so if your group id is 123, your bot id is 98765, and name is John the resulting value would be 123, 98765, John
    • If you have multiple groups, want to toggle debugging, or want to toggle concurrency, see the Advanced section.

Cheers! Your bot should now be functioning. See the customization section to make it do stuff.

If you keep the files locally, you can update your bot with two simple commands. Otherwise, you can just run step 2 again.

$ git fetch -p origin
$ git push --mirror

Advanced setup

Handling multiple groups simultaneously

See the original BOT_INFO format. To handle multiple groups, simply append the same format again after a semicolon.

For instance, if I want to handle three different groups, I will update BOT_INFO to the form GID_1, BID_1, N_1; GID_2, BID_2, N_2; GID_3, BID_3, N_3

Changing amount of concurrency

Web concurrency means the number of processes running your bot side by side. For larger apps, higher concurrency is a good thing. It is unlikely you will need concurrency with your bot, and disabling it will possibly give you a cleaner log. To change the number of concurrent processes, add a new Config Var WEB_CONCURRENCY and set the value equal to the number of desired processes. Setting it equal to 1 disables concurrency.

Toggle debugging in logs

The bot will automatically log some items all the time and others only when debugging. I tend to leave this on for more in depth logs, but if you like simpler readouts you can easily disable it. Create a new Config Var BOT_DEBUG and set the value equal to True or False for enabled and disabled. Defaults to True if no variable is found.

Monitoring logs

You can use many different outside tools to monitor the logs, and they may even give you greater personalization. To use the standard Heroku logs, called logplex, you will need to install their command line interface, called Heroku CLI.

Once HerokuCLI is installed, you can run Heroku commands straight from your normal command line. Read about monitoring logs on Heroku's help page. Typically, a simple heroku logs -a APP_NAME --tail --source app is your best bet. (Replace APP_NAME with your app name.)

Customizing log formatting

Changing the format of log entries couldn't be easier. Editing your groupme-bot.py will present you with a class called errcol under the customization section. Here, you can read each tag's description and change how it is presented in the log.

Customization

The bot is easily customizable. You are given the option to set either global rules, group rules, or both. When managing multiple groups, global rules will apply to all and group rules will only apply to their group. Group rules can also override global rules - your choice.

  • Global rules are defined in a file called global_rules.py
  • Group rules are defined in a file called group_GROUP_ID.py (for instance, group_253468.py)

None of these files are required, but each file you add can add functionality. In either file, you should create a function called run that takes parameters for the data packet, bot info, and the send function, as shown below.

1  |  # rules example
2  |
3  |  def run(data, bot_info, send_message):
4  |    if data['text'] == 'hi':
5  |      send_message('Hi there!', bot_info[0])
6  |      return True

In line 3, we see the method declaration. This can be anything that follows the format def run(DATA_PARAM, BOT_PARAM, MSG_PARAM):

The first argument, what we called data above, is the message data sent by GroupMe. This data contains information such as the username, text, attachments, and more. You can read about each data point on GroupMe's tutorial, but they all follow the same pattern (data['text'] will return the message text).

The second argument, what we called bot_info above, is exactly what you think - the bot's info. This will be an array, where bot_info[0] returns the Bot ID and bot_info[1] returns its name.

The third and final argument, what we called send_message, does exactly that. In order to send messages as the bot, you have to use send_message(MESSAGE, BOT_ID) such as on line 5.

You can use control statements, such as the if statement on line 4 to control how the bot interacts with users. For instance, in this example the bot will say Hi there! any time a user says hi.

In line 6, we returned True. This means no other code following that line will run, and the bot will move on to the next task. Note: When writing group rules, return True to skip global rules, and return False to run global rules anyways.

Pushing your rules to the repository

Now that you created custom rules, you need to deploy them to your bot. Assuming you kept the files from earlier, add your rules (with the proper names) to the same directory. After opening the terminal, you will need to run these commands (or use the web interface):

Ensure you are in the correct directory
$ git commit -am "Created custom rules"
$ git push
Python wrapper for Coinex APIs

coinexpy - Python wrapper for Coinex APIs Through coinexpy you can simply buy or sell crypto in your Coinex account Features place limit order place m

Iman Mousaei 16 Jan 02, 2023
Find Roblox Groups & Send To Discord

Roblox-Group-Finder A tool to help you find ownerless roblox groups :) It's really easy, all you need is a discord webhook :) It will not send locked

1 Dec 13, 2021
Python Capfire API wrapper

General CampfireAPI based on Campfire web. Install pip install Campfire-API Quickstart Use it without login: from campfire_api import CampfireAPI cf

Ghost 0 Jan 03, 2022
A discord Server Bot made with Python, This bot helps people feel better by inspiring them with motivational quotes or by responding with a great message, also the users of the server can create custom messages by telling the bot with Commands.

A discord Server Bot made with Python, This bot helps people feel better by inspiring them with motivational quotes or by responding with a great message, also the users of the server can create cust

Aran 1 Oct 13, 2021
Spore Api

SporeApi Spore Api Simple example: import asyncio from spore_api.client import SporeClient async def main() - None: async with SporeClient() a

LEv145 16 Aug 02, 2022
Discord Bot for server hosts, devs, and admins. Analyzes timings reports & uploads text files to hastebin. Developed by https://birdflop.com.

"Botflop" Click here to invite Botflop to your server. Current abilities Analyze timings reports Paste a timings report to review an in-depth descript

Purpur 76 Dec 31, 2022
A modern, easy to use, feature-rich, and async ready API wrapper improved and revived from original discord.py.

A Python API wrapper that is improved and revived from the original discord.py

Orion 19 Nov 06, 2021
A bot that downloads all the necessary files from WeLearn and lists your assignments, filter due assignments, etc.

Welearn-bot This is a bot which lets you interact with WeLearn from the command line. It can Download all files/resources from your courses and organi

Parth Bibekar 17 Oct 19, 2022
Periodically check the manuscript state in the scholar one system and send email when finding a new state.

ScholarOne-manuscript-checker Periodically check the manuscript state in the scholar one system and send email when finding a new state. Parameters ne

2 Aug 18, 2022
FUD Keylogger That Reports To Discord

This python script will capture all of the keystrokes within a given time frame and report them to a Discord Server using Webhooks. Instead of the traditional

●┼Waseem Akram••✓⁩ 16 Dec 08, 2022
AWS Quick Start Team

EKS CDK Quick Start (in Python) DEVELOPER PREVIEW NOTE: Thise project is currently available as a preview and should not be considered for production

AWS Quick Start 83 Sep 18, 2022
Aplicação dos metodos de classificação em 3 diferentes banco de dados. Usando...

Machine Learning - Métodos de classificação Base de Dados utilizadas: Dados de crédito Dados do Census Métodos de classificação aplicados: Naive Bayes

1 Jan 18, 2022
Stock trading bot made using the Robinhood API / Python library...

High-Low Stock trading bot made using the Robinhood API / Python library... Index Installation Use Development Notes Installation To Install and run t

Reed Graff 1 Jan 07, 2022
Best DDoS Attack Script Python3, Cyber Attack With 40 Methods

MXDDoS - DDoS Attack Script With 40 Methods (Code Lang - Python 3) Please Don't Attack '.gov' and '.ir' Websites :) Features And Methods 💣 Layer7 GET

7 Mar 07, 2022
:lock: Python 2.7/3.X client for HashiCorp Vault

hvac HashiCorp Vault API client for Python 3.x Tested against the latest release, HEAD ref, and 3 previous minor versions (counting back from the late

hvac 1k Dec 29, 2022
Binance leverage futures Hook

Simple binance futures Attention Just use leverage. The fee difference between futures and spot is not considered. For example, funding rate, etc. Onl

Adriance 26 Aug 27, 2022
CVE-2021-39685 Description and sample exploit for Linux USB Gadget overflow vulnerability

CVE-2021-39685 Description and sample exploit for Linux USB Gadget overflow vulnerability

8 May 25, 2022
Asyncevents: a small library to help developers perform asynchronous event handling in Python

asyncevents - Asynchronous event handling for modern Python asyncevents is a small library to help developers perform asynchronous event handling in m

Mattia 5 Aug 07, 2022
Tubee is a web application, which runs actions when your subscribed channel upload new videos

Tubee is a web application, which runs actions when your subscribed channel upload new videos, think of it as a better IFTTT but built specifically for YouTube with many enhancements.

Tomy Hsieh 11 Jan 01, 2023
As Slack no longer provides an API to invite people, this is a Selenium Python script to do so

As Slack no longer provides an API to invite people, this is a Selenium Python script to do so