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
Estimate the total emissions for popular CryptoArt platforms.

cryptoart-footprint Estimate the total CO2 footprint for popular CryptoArt platforms. The goal is to accurately quantify the ecological damage of Ethe

Kyle McDonald 182 Oct 12, 2022
Reads and prints information from the website MalAPI.io

MalAPIReader Reads and prints information from the website MalAPI.io optional arguments:

Squiblydoo 16 Nov 10, 2022
Discord bot that shows valorant your daily store by using the Ingame API

Valorant store checker - Discord Bot Discord bot that shows valorant your daily store by using the Ingame API. written using Python and the Pycord lib

STACIA 226 Jan 02, 2023
WhatsApp Web API client with multi-device support

Tauros WhatsApp Web client for multi-device in python Free software: MIT Documentation: https://tauros.readthedocs.io Features TODO Credits This packa

Manjit Pardeshi 0 Jan 20, 2022
Leveraged grid-trading bot using CCXT/CCXT Pro library in FTX exchange.

Leveraged-grid-trading-bot The code is designed to perform infinity grid trading strategy in FTX exchange. The basic trader named Gridtrader.py contro

Hao-Liang Wen 25 Oct 07, 2021
`python-jamf` is a library for connecting to a Jamf Server that maps directly to the Jamf Pro Classic API.

`python-jamf` is a library for connecting to a Jamf Server that maps directly to the Jamf Pro Classic API. It is the basis for the `jctl` tool to automate patch management & packages and many other i

University of Utah, Marriott Library, Apple Support 38 Dec 13, 2022
Social Framework

Social Int Framework Social Int Framework its a Selenium script that scrape the IG photos and do a Reverse search on google and yandex for finding ano

29 Dec 06, 2022
Python interface to the LinkedIn API

Python LinkedIn Python interface to the LinkedIn API This library provides a pure Python interface to the LinkedIn Profile, Group, Company, Jobs, Sear

ozgur 844 Dec 27, 2022
股票量化

StockQuant Gary-Hertel 请勿提交issue!可以加入交流群与其他朋友一起自学交流,加微信mzjimmy 一、配置文件的设置 启动框架需要先导入必要的模块,并且载入一次配置文件! 配置文件是一个json格式的文件config.json,在docs文件夹中有模板

218 Dec 25, 2022
A modular Telegram Python bot running on python3 with a sqlalchemy database.

Nao Tomori Robot Found Me On Telegram As Nao Tomori 🌼 A modular Telegram Python bot running on python3 with a sqlalchemy database. How to setup/deplo

Stinkyproject 1 Nov 24, 2021
Braje: a python based credit hacker tool. Hack unlimited RAJE LIKER app Credit

#ReCoded Evan Al Mahmud Irfan ✨ ථ BRAJE 1.0 AUTO LIKER, AUTO COMMENT AND AUTO FOLLOWER APP CREDIT HACKER TOOL About Braje: Braje is a python based cre

Evan Al Mahmud Irfan ථ 2 Dec 23, 2021
A telegram bot for generate fake details. Written in python using telethon

FakeDataGenerator A telegram bot for generate fake details. Written in python using telethon. Mandatory variables API_HASH Get it from my telegram.org

Oxidised-Man 6 Dec 19, 2021
An opensource chat service that cares about your privacy.

An opensource chat service that cares about your privacy. Instructions to set up a local testing environment: 1) Clone this repository and navigate to

Aiman Al Masoud 2 Dec 03, 2022
Tools to download and aggregate feeds of vaccination clinic location information in the United States.

vaccine-feed-ingest Pipeline for ingesting nationwide feeds of vaccine facilities. Contributing How to Configure your environment (instructions on the

Call the Shots 26 Aug 05, 2022
Unofficial Discord Rich Presence for HackTheBox platform

HTBRichPresence Unofficial Discord Rich Presence for HackTheBox platform The project is under lazy development. How to run Install requirements: // I'

Antonio 4 Apr 19, 2022
A powerful bot to copy your google drive data to your team drive

⚛️ Clonebot - Heroku version ⚡ CloneBot is a telegram bot that allows you to copy folder/team drive to team drives. One of the main advantage of this

MsGsuite 269 Dec 23, 2022
A Telegram bot to send messages in Telegram groups or Channels using bots anonymously.

Group-chatting-bot A bot to send messeges to group using bot telegram bot ❤️ Support Made with Python3

Pyrogramers 16 Nov 06, 2022
A Python 2.7/3.x module for Amcrest Cameras using the SDK HTTP API.

A Python 2.7/3.x module for Amcrest Cameras using the SDK HTTP API. Amcrest and Dahua devices share similar firmwares. Dahua Cameras and NVRs also work with this module.

Marcelo Moreira de Mello 176 Dec 21, 2022
API to retrieve the number of grades on the OGE website (Website listing the grades of students) to know if a new grade is available. If a new grade has been entered, the program sends a notification e-mail with the subject.

OGE-ESIREM-API Introduction API to retrieve the number of grades on the OGE website (Website listing the grades of students) to know if a new grade is

Benjamin Milhet 5 Apr 27, 2022
A Discord token grabber written in Python3, with awesome obfuscation and anti-debug protection.

☣️ Plague ☣️ Plague is a Discord token grabber written in Python3, obfuscated with Kramer, protected from traffic analysers with Scarecrow and using t

Billy 125 Dec 20, 2022