A bot that downloads all the necessary files from WeLearn and lists your assignments, filter due assignments, etc.

Overview

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 organize them in designated folders.
  • Show your assignments, filter due assignments.
  • Add your assignments to Google Calendar.

Go to our project wiki to learn more about configuring and using the script. Developers may be interested in the article on using the Moodle Web Service module, which shows you how to use the accompanying moodlews.service module to write your own script for interacting with WeLearn, or indeed any other Moodle service.

Demo

asciicast

Installation

This script runs on python3. To install it on your system, run

pip install --upgrade welearn-bot-iiserkol

The --upgrade flag ensures that you get the latest version.

If you are on Windows and are new to python, please go through this quick guide.

Running from source

Clone this repo or download the source code, and navigate to that directory. To install dependencies, run

pip install -r requirements.txt

You can now navigate to the src directory and run python welearn_bot [options ...].

Configuration

On *nix systems (linux, macos), create a ~/.welearnrc file; on Windows, create a welearn.ini in your C:/Users/USERNAME/ folder. Inside, fill in your details in the following format.

[auth]
username = AzureDiamond
password = hunter2

[courses]
MA1101
PH2202
CH3303
LS4404
ES5505

You may omit any or all of your [auth] credentials, in which case you will be prompted each time you run the program.

There are many more configuration options to explore, such as the [files] and [gcal] sections - for a detailed breakdown, please consult our wiki page on writing your configuration file.

Google calendar integration

Integration with Google Calendar is completely optional. This feature allows you to save your assignment dates directly to Google Calendar, when you use the --gcalendar option. You can also choose which calendar within your Google Calendar account to push events to.

You will have to authenticate using OAuth2.0 and add some lines to your configuration file. Please follow the steps in the Google Calendar integration article. At the end, your configuration file will have a section of the following form.

[gcal]
client_id = xxxxxxxxxxxxxxx.apps.googleusercontent.com
client_secret = xxxxxxxxxxxxxxxxx
calendar_id = [email protected]

Usage

Run welearn_bot -h to get the following help message.

usage: welearn_bot [-h] [-v] [-d] [-c] [-i [IGNORETYPES ...]] [-f] [-p PATHPREFIX] action [courses ...]

A command line client for interacting with WeLearn.

positional arguments:
  action                choose from
                            files       - downloads files/resources
                            assignments - lists assignments, downloads attachments
                            urls        - lists urls
                            courses     - lists enrolled courses
                            whoami      - shows the user's name and exits
                        Abbreviations such as any one of 'f', 'a', 'u', 'c', 'w' are supported.
  courses               IDs of the courses to download files from. The word ALL selects everything
                        from the [courses] section in .welearnrc or welearn.ini

optional arguments:
  -h, --help            show this help message and exit
  -v, --version         show program's version number and exit
  -d, --dueassignments  show only due assignments with the 'assignments' action
  -c, --gcalendar       add due assignments to Google Calendar with the 'assignments' action
  -i [IGNORETYPES ...], --ignoretypes [IGNORETYPES ...]
                        ignores the specified extensions when downloading, overrides .welearnrc
  -f, --forcedownload   force download files even if already downloaded/ignored
  -p PATHPREFIX, --pathprefix PATHPREFIX
                        save the downloads to a custom path, overrides .welearnrc

See our article on using command line options for a detailed breakdown.

Examples

Testing your setup

If your .welearnrc or welearn.ini file is set up correctly, the following command should simply display your name.

welearn_bot whoami

To get a list of courses you are enrolled in, run

welearn_bot courses

Basic commands

To pull all files from the courses MA1101 and CH3303, run

welearn_bot files MA1101 CH3303

You can use the shorthand f for files, so the following is an equivalent command.

welearn_bot f MA1101 CH3303

To show assignments and download their attachments from the course MA1101, run

welearn_bot assignments MA1101

To list due assignments (due date in the future) from all courses, run

welearn_bot -d assignments ALL

Make sure that the -d flag comes first!

To list all urls from the CH3303 course, run

welearn_bot urls CH3303

Calendar integration

To list due assignments from all courses, and add them to your calendar, run

welearn_bot -dc assignments ALL

Ignoring filetypes

To download all resources from the course CH3303, ignoring pdf files, run

welearn_bot -i pdf -- files CH3303

Note the use of -- which is essential for separating the IGNORETYPES from the courses. The following format may be preferred.

welearn_bot files CH3303 -i pdf

To override the .welearnrc ignore settings and allow all extensions, but still respect past downloads, run

welearn_bot -i -- files CH3303

Force downloads and pathprefix

To force download all resources from the course PH2202, even if already downloaded and present or set to be ignored, and put all the course directories in the ~/notes folder, run

welearn_bot files PH2202 -fp ~/notes 
Comments
  • security issue: the program is vulnreable as password is saved in plain text on the machine.

    security issue: the program is vulnreable as password is saved in plain text on the machine.

    Anyone with access to my machine can read the password as it is saved in plain text. There should be an option for the program to prompt for the password if the user does not save his/her password in welearnrc

    opened by nick-nds 2
  • Enhancement: Add ability to mention a custom path where the can be downloaded.

    Enhancement: Add ability to mention a custom path where the can be downloaded.

    Why?

    Given that this is to be used as a script. One should be able to run it from anywhere and store the files in a predefined path. As of now, it downloads them in the directory from where the script is run.

    Possible features:

    • A prefix setting in preference section in .welearnrc
    • A -p flag while running the script to save to a custom path. This should overwrite the prefix if already set in .welearnrc

    PS: I was about to implement this but @sahasatvik is working on switching to using moodle API. This would change the details of the implementation. I would start after all such major changes are done.

    opened by MASTERAMARJEET 2
  • Fetch students' assignment submissions (TAs)

    Fetch students' assignment submissions (TAs)

    Feature for TAs

    This PR adds the capability for TAs to fetch assignment submissions from welearn.

    Notable features

    • The assignments for each subject are downloaded into it's own submissions folder.
    • Each student has it's own folder for each assignment.
    • If the assignment are in archived form (compressed), they are automatically uncompressed.

    Config changes

    The users will have to add a [submissions] section to their config with the appropriate information (as shown below)

    [submissions]
    CS1103 = ALL
    CS1101 = 21MS020, ... , 21MS120
    CS1102 = 21MS120,  21MS121,  21MS122,  21MS123,  21MS124,  21MS125,  21MS126
    CS1101 = 20MS011,  19MS112, 21MS020, ... , 21MS120
    

    Note that you have to add key value pairs of courseid and the roll numbers for which to fetch the submissions The roll numbers can be entered in the following form:

    • ALL to fetch all submissions
    • a range of roll numbers
    • a explicit list of roll numbes
    • a mix of range and explicit roll numbers

    CLI arguments

    • An additional action, s (submissions) has been exposed to the users for using this feature
    • The users can also specify list of roll numbers from the cli using -r (--rolls) option
    • CLI arguments override the config settings

    Misc

    A new cache for course information is also added. The users can update the cache using the -u flag

    enhancement 
    opened by MASTERAMARJEET 0
  • Refactor welearnbot.py

    Refactor welearnbot.py

    Refactoring welearnbot.py

    This refactor separates the logic being handled into functions using the functional programming approach. This will give the script a pipeline like behaviour while keeping it extendable.

    The following refactors were done.

    • move the parser setup to a separate function
    • move constants(like config location, etc.) into separate files so that they are accessible everywhere
    • create (resolver) functions for getting information from config , input, server, etc
    • isolate code for handling each action into handler functions (handle_action)
    opened by MASTERAMARJEET 0
  • Google calendar integration

    Google calendar integration

    Feature

    This introduces the --gcalendar flag with the assignments action, which will add due assignments to the user's Google Calendar of choice. You can run

    welearn_bot -dc assignments ALL
    

    to add all due assignments to your Google Calendar, after appropriate configuration.

    The duration of the created event extends one hour before the deadline, up to the deadline. This choice was made so that the user gets some level of notification before the deadline, and because logically the event ought to end when the deadline is reached.

    The user can also choose a "sub calendar" within their Google Calendar account to push events. This gives an additional layer of control, whereby calendarwide preferences such as event colour, notification settings, visibility/sharing, etc can be configured directly from Google Calendar.

    Thanks to @AK6263 for contributing the base code for connecting the the Google Calendar API and pushing events.

    Caveats

    Using this feature requires a fairly complicated process of authentication, which includes the creation of tokens from the Google Developer Console. Complete details are present in the updated README.md. In addition, the program triggers an OAuth login page which opens in the browser if the refresh token expires, which happens roughly every 7 days.

    Since this particular feature cannot be automated to the same level as the other actions, Google Calendar integration has been kept as unintrusive and optional as possible.

    Changes

    • The --gcalendar flag has been added, along with functionality for using the Google Calendar API via OAuth 2.0.
    • The [gcal] section has been added to the config file, which must have the client_id and client_secret keys for authenticating with the Google Calendar API.
    • The optional calendar_id key specifies the particular calendar within Google Calendar to which events are to be added.
    enhancement 
    opened by sahasatvik 0
  • Moodle Webservice module

    Moodle Webservice module

    The core server functions, such as authentication and fetching of JSON records, have been encapsulated into a moodlews.service module. This is to streamline the flow of the code, and emphasize that WeLearn is one of many Moodle services that our script can potentially work with.

    A typical usecase is as follows.

    from moodlews.service import MoodleClient
    from moodlews.service import ServerFunctions as sf
    
    # Create the client and authenticate
    moodle = MoodleClient("https://welearn.iiserkol.ac.in/")
    token = moodle.authenticate("username", "password")
    
    # Empty token if login failed
    if not token:
        ....
    
    # Fetch site info records
    site_info = moodle.server(sf.SITE_INFO)
    userid = site_info["userid"]
    
    # Fetch user enrolled courses
    user_courses = moodle.server(sf.USER_COURSES, userid=userid)
    ....
    

    Changes

    • Altered directory structure, with a src folder.
    • Creation of a moodlews.service module, with the MoodleClient and ServerFunctions classes.
    • Implementation of the same into welearn_bot
    opened by sahasatvik 0
  • Command line arguments - modes/actions instead of flags

    Command line arguments - modes/actions instead of flags

    Why?

    The welearn-bot client can only perform one action per run, such as fetching files, listing assignments, etc. Thus, it doesn't make sense to allocate fetching files as a default, and leave the others as command line options, of which at most one can be used at a a time. Instead, we can specify a single mode/action to perform, such as files or assignments, which helps make the desired outcome more explicit.

    Summary of actions

    Following are the implemented actions.

    • files: all resources and files from the specified courses will be downloaded.
    • assignments: all assignments from the specified courses will be listed, and the attachments will be downloaded.
    • urls: all urls from the specified courses will be listed.
    • courses: all enrolled courses will be listed
    • whoami: this is a command to retrieve the user's name from the server (mostly used to check that the program has been configured properly)
    usage: welearn_bot [-h] [-d] [-i [IGNORETYPES ...]] [-f] [-p PATHPREFIX] action [courses ...]
    
    A command line client for interacting with WeLearn.
    
    positional arguments:
      action                choose from
                                files       - downloads files/resources
                                assignments - lists assignments, downloads attachments
                                urls        - lists urls
                                courses     - lists enrolled courses
                                whoami      - shows the user's name and exits
                            Abbreviations such as any one of 'f', 'a', 'u', 'c', 'w' are supported.
      courses               IDs of the courses to download files from. The word ALL selects everything from the [courses] section in .welearnrc or welearn.ini
    
    optional arguments:
      -h, --help            show this help message and exit
      -d, --dueassignments  show only due assignments with the 'assignments' action
      -i [IGNORETYPES ...], --ignoretypes [IGNORETYPES ...]
                            ignores the specified extensions when downloading, overrides .welearnrc
      -f, --forcedownload   force download files even if already downloaded/ignored
      -p PATHPREFIX, --pathprefix PATHPREFIX
                            save the downloads to a custom path, overrides .welearnrc
    

    Some common operations are

    ./welearn_bot.py files MA1101        # Get files from MA1101
    ./welearn_bot.py -d assignments ALL  # Show all due assignments
    ./welearn_bot.py -d a ALL            # Same as above
    

    Please see the updated README.md for a full list of examples.

    enhancement 
    opened by sahasatvik 0
  • Switching to the Moodle Web Service API

    Switching to the Moodle Web Service API

    Why?

    The Moodle webservice API is much faster than scraping webpages one by one and parsing HTML. Furthermore, the API returns a complete list of files which solves the problem of nested resources.

    Why not?

    There are a few details about assigments (submission status) which have not yet been implemented.

    Changes

    • Restructured all code to work with the webservice API, which gives a significant speed boost
    • Restructured the .welearnrc format
    • Changed the level of detail of assignment statuses
    • The bot now downloads assignment attachments
    opened by sahasatvik 0
  • How about a more structured format for welearnrc?

    How about a more structured format for welearnrc?

    Why?

    When we think of rc files, bashrc or vimrc, etc comes to our mind. They all have some variable-value kind of setup so that the meaning of each setting can be better conveyed to the user. I tried to achieve the same.

    How?

    Python has a built-in configparser module that can parse .ini config files. So I chose to use .ini formatting for the .welearnrc file. This can then be easily parsed using the aforementioned module.

    Changes:

    • Updated README.md to convey to the users to use the new format.
    • Implemented .welearnrc parsing using the configparser module.

    NOTE: Merging this into main will break the code until the user updated the .weleanrc file to use the new format.

    opened by MASTERAMARJEET 0
  • Fixing attribute error

    Fixing attribute error

    Traceback (most recent call last): File "/home/parth/.local/bin/welearn_bot", line 8, in sys.exit(main()) File "/home/parth/.local/lib/python3.8/site-packages/welearnbot/welearnbot.py", line 58, in main handler.handle_files( File "/home/parth/.local/lib/python3.8/site-packages/welearnbot/action_handlers.py", line 185, in handle_files modules = item.get("modules", []) AttributeError: 'str' object has no attribute 'get'

    opened by ParthBibekar 1
  • The files that were uploaded on the welearn in the discussion forum is not getting downloaded when running the command 'welearn_bot files ALL'

    The files that were uploaded on the welearn in the discussion forum is not getting downloaded when running the command 'welearn_bot files ALL'

    Is your feature request related to a problem? Please describe. A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

    Describe the solution you'd like A clear and concise description of what you want to happen.

    Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.

    Additional context Add any other context or screenshots about the feature request here.

    enhancement wontfix 
    opened by SaqlainAfroz 0
Releases(v1.3.0)
  • v1.3.0(Aug 26, 2022)

    Feature: Support for TAs have been added.

    • An additional action, s (submissions) has been exposed to the users for using this feature
    • New flags -u and -r (--rolls) have been added.

    To make sure that you have this patch installed, run

    pip install --upgrade welearn-bot-iiserkol
    
    Source code(tar.gz)
    Source code(zip)
  • v1.2.5(Mar 7, 2022)

    Feature: use -v or --verbose to list missing/ignored files while downloading (these are suppressed by default).

    Dev: major code refactor.

    To make sure that you have this patch installed, run

    pip install --upgrade welearn-bot-iiserkol
    
    Source code(tar.gz)
    Source code(zip)
  • v1.2.4(Jan 29, 2022)

    Fix: files in cache (downloaded previously) but not on disk are listed as 'missing'.

    Feature: use --missingdownload or -m to (re)download these missing files.

    To make sure that you have this patch installed, run

    pip install --upgrade welearn-bot-iiserkol
    
    Source code(tar.gz)
    Source code(zip)
  • v1.2.3(May 4, 2021)

    Fix: fetching assignment submissions no longer crashes on the first try.

    To make sure that you have this patch installed, run

    pip install --upgrade welearn-bot-iiserkol
    
    Source code(tar.gz)
    Source code(zip)
  • v1.2.2(Apr 14, 2021)

    Fix: download and ignore messages are now more consistent, with the currently downloading file name displayed in advance.
    Info: you can now run welearn_bot --version or welearn_bot -v to display the installed version.
    The project structure has also been reshuffled so that welearn_bot is no longer a script, but is instead called from the welearnbot.welearnbot module.

    To make sure that you have this patch installed, run

    pip install --upgrade welearn-bot-iiserkol
    
    Source code(tar.gz)
    Source code(zip)
  • v1.2.1(Apr 12, 2021)

    Fix: the script can now detect and download content from folders within course pages. To make sure that you have this patch installed, run

    pip install --upgrade welearn-bot-iiserkol
    

    Support for this script on Windows is still being tested. If you are running Windows and you do not have python on your system, consider going through this quick guide. Otherwise, you are advised to download the source files, present in the src directory, and execute welearn_bot using whatever python environment you have present.

    Source code(tar.gz)
    Source code(zip)
  • v1.2.0(Apr 12, 2021)

    This release features big changes!

    • We now have Google Calendar integration! You can now add all your assignments to your calendar with a single command. See our wiki article for more info.
    • The core functionality of the script has been packaged into the moodlews.service module, which you can import and use to write your own scripts for interfacing with WeLearn, or any other Moodle service. Read out article on using the Moodle Web Service module for details.
    Source code(tar.gz)
    Source code(zip)
  • v1.0.1(Apr 10, 2021)

    You can now omit your [auth] credentials, in which case you will be prompted each time you run the program. You may also choose not to have a config file at all.

    Source code(tar.gz)
    Source code(zip)
  • v1.0.0(Apr 10, 2021)

    First major release of welearn_bot.py. Install it with

    pip install welearn-bot-iiserkol
    

    Highlights include

    • Actions to retrieve files, assignments, urls and courses.
    • A configuration file (.welearnrc or welearn.ini) to store user authentication data along with preferences.
    • Use of the Moodle Web Services API for speedy retrieval of information.
    Source code(tar.gz)
    Source code(zip)
  • v1.0.0a1(Apr 10, 2021)

Owner
Parth Bibekar
Undergraduate at IISER Kolkata
Parth Bibekar
Fast and multi-threaded script to automatically claim targeted username including 14 day bypass

Instagram Username Auto Claimer Fast and multi-threaded script to automatically claim targeted username. Click here to report bugs. Usage Download ZIP

265 Dec 28, 2022
JAWS Pankration 2021 - DDD on AWS Lambda sample

JAWS Pankration 2021 - DDD on AWS Lambda sample What is this project? This project contains sample code for AWS Lambda with domain models. I presented

Atsushi Fukui 21 Mar 30, 2022
A tool for extracting plain text from Wikipedia dumps

WikiExtractor WikiExtractor.py is a Python script that extracts and cleans text from a Wikipedia database dump. The tool is written in Python and requ

Giuseppe Attardi 3.2k Dec 31, 2022
SkyzoMusicBot - Bot Music Telegram By Skyzo

SKYZO MUSIC BOT Telegram Music Bot And Stream Feature New Version Ready to use m

Skyzo 19 Apr 08, 2022
Discord bot to administer IITD Study Servers (unofficial)

IITD-Bot Discord bot to administer IITD'20 Acad Server Commands hello to check if bot is online ?help to display this message ?set kerberos to set y

Aditya Singh 47 Dec 19, 2022
OpenSource bot for control groups ...

⭕️ کمک به افراد برای اداره هرچه فان تره گروه 📟 همه گروه های بزرگ نیاز به یه بات خفن دارن تا از گروه مراقبت کنه این بات کارش همینه سعی کرده فیچر خیلی

Mehran Alam Beigi 2 Nov 26, 2021
This is a Python bot, which automates logging in, purchasing and planting the seeds. Open source bot and completely free.

🌻 Sunflower Land Bot 🌻 ⚠️ Warning I am not responsible for any penalties incurred by those who use the bot, use it at your own risk. This BOT is com

Newerton 18 Aug 31, 2022
A Pythonic wrapper for the Wikipedia API

Wikipedia Wikipedia is a Python library that makes it easy to access and parse data from Wikipedia. Search Wikipedia, get article summaries, get data

Jonathan Goldsmith 2.5k Dec 28, 2022
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
Python wrapper for the Sportradar APIs ⚽️🏈

Sportradar APIs This is a Python wrapper for the sports APIs provided by Sportradar. You'll need to sign up for an API key to use the service. Sportra

John W. Miller 39 Jan 01, 2023
An all-in-one financial analytics and smart portfolio creator as a Discord bot!

An all-in-one financial analytics bot to help you gain quantitative financial insights. Finn is a Discord Bot that lets you explore the stock market like you've never before!

6 Jan 12, 2022
Send pm to Admin - Telegram

Send pm to Admin - Telegram

Ahoora 3 Nov 17, 2022
Telegram Music Bot for YouTube/SoundCloud/Mixcloud

Telegram Music Bot Telegram Music Bot for YouTube/SoundCloud/Mixcloud This bot downloads and sends the audio when someone send a YouTube/SoundCloud/Mi

Calls Music 76 Jan 02, 2023
A modern, easy to use, feature-rich, and async ready API wrapper for Discord written in Python.

A modern, easy to use, feature-rich, and async ready API wrapper for Discord written in Python. Key Features Modern Pythonic API using async and await

Senpai Development 4 Nov 05, 2021
A telegram bot writen in python for mirroring files on the internet to Google Drive

owner of this repo :- AYUSH contact me :- AYUSH Slam Mirror Bot This is a telegram bot writen in python for mirroring files on the internet to our bel

Thanusara Pasindu 1 Nov 21, 2021
Grape - A webbrowser with its own Search Engine

Grape 🔎 A Web Browser made entirely in python. Search Engine 🔎 Installation: F

Grape 2 Sep 06, 2022
Lending-Club-Loans - Using TensorFlow to create an ANN model to predict whether people would charge off or pay back their loans.

Lending Club Loans: Brief Introduction LendingClub is a US peer-to-peer lending company, headquartered in San Francisco, California.[3] It was the fir

Ali Akram 1 Jan 03, 2022
Python wrapper for GitHub API v3

Squeezeit - Python CSS and Javascript minifier Copyright (C) 2011 Sam Rudge This program is free software: you can redistribute it and/or modify it un

David Medina 207 Oct 24, 2022
An unoffcial python API client for primeuploads.com

primeuploads-py An unoffcial python API wrapper for primeuploads.com Installation pip3 install primeuploads-py Usage example from prime import PrimeUp

W4RR10R 41 Dec 05, 2022
Скрипт, позволяющий импортировать плейлисты из Spotify, а также обычные треклисты в VK музыку.

vk-music-import Программа для переноса плейлистов из Spotify и текстовых треклистов в VK Музыку. Преимущества: Позволяет быстро импортировать плейлист

Mew Forest 32 Nov 23, 2022