THE FORUM IS IN READ-ONLY MODE

This forum is in read-only mode. The new forum is live at https://discourse.openbullet.dev and registrations are open!

[Plugin] Updater for OB



  • Edit: We can technically say this is the first built-in Updater for OpenBullet ! 🙂

    It downloads the latest OB release from https://github.com/openbullet/openbullet/releases/latest/download/OpenBullet.zip and unzips /w 7z.exe

    Installation:
    Unzip the archive into Plugins folder.

    alt text

    Plugins.zip

    VirusTotal

    Latest compiled dll: https://mega.nz/file/T11TRYYC#3cbSYWkbqwZs3wD-JTAzV2ZITic8egbduDo6Y5O6F-4



  • This is the code for who wants to compile byself

    using PluginFramework;
    using PluginFramework.Attributes;
    using RuriLib;
    using RuriLib.Interfaces;
    using System;
    using System.Diagnostics;
    using System.IO;
    using System.Net;
    
    namespace OBUpdaterPlugin
    {
        public class Class1 : IPlugin
        {
            public string Name => "OB Updater (Unofficial)";
    
            [Button("Check for updates")]
            public void CheckUpdate(IApplication app)
            {
                WebClient webClient = new WebClient();
                string html = webClient.DownloadString("https://github.com/openbullet/openbullet/releases");
                string ltobVer = FindTextBetween(html, "css-truncate\" title=\"", "\">");
                CreateVerText();
                string obVer = File.ReadAllText(@"version.txt");
                if(obVer.Length==0)
                    app.Logger.Log($"Your OB version: Unknown | Latest OB version: {ltobVer}", LogLevel.Info, true);
                else
                    app.Logger.Log($"Your OB version: {obVer} | Latest OB version: {ltobVer}", LogLevel.Info, true);
            }
            public void CreateVerText()
            {
                string path = @"version.txt";
    
                if (!File.Exists(path))
                {
                    File.Create(path).Dispose();
                }
            }
            public string FindTextBetween(string text, string left, string right)
            {
                // TODO: Validate input arguments
    
                int beginIndex = text.IndexOf(left); // find occurence of left delimiter
                if (beginIndex == -1)
                    return string.Empty; // or throw exception?
    
                beginIndex += left.Length;
    
                int endIndex = text.IndexOf(right, beginIndex); // find occurence of right delimiter
                if (endIndex == -1)
                    return string.Empty; // or throw exception?
    
                return text.Substring(beginIndex, endIndex - beginIndex).Trim();
            }
    
            [Button("Update your OpenBullet (requires restart)")]
            public void OBUpdater(IApplication app)
            {
                WebClient webClient = new WebClient();
                webClient.DownloadFile("https://github.com/openbullet/openbullet/releases/latest/download/OpenBullet.zip", @"Update.zip");
                CreateVerText();
                WebClient webClient2 = new WebClient();
                string html = webClient2.DownloadString("https://github.com/openbullet/openbullet/releases");
                string ltobVer = FindTextBetween(html, "css-truncate\" title=\"", "\">");
                File.WriteAllText("version.txt", ltobVer);
                string path = AppDomain.CurrentDomain.BaseDirectory;
                var process = Process.Start(@"Plugins\7z.exe", "x -aoa Update.zip");
                process.WaitForExit();
                Process.Start("CMD.exe", "/C ROBOCOPY " + "\"" + Environment.CurrentDirectory + "\\Release" + "\"" + " " + "\"" + Environment.CurrentDirectory + "\"" + " /E /IS /MOVE");
                Environment.Exit(0);
            }
        }
    }
    


  • Quick fix:
    Now Release directory contents move to main openbullet directory.
    Latest compiled dll: https://mega.nz/file/T11TRYYC#3cbSYWkbqwZs3wD-JTAzV2ZITic8egbduDo6Y5O6F-4



  • Glad to see someone contributing. Selam 🙂



  • i have run the plugin and it's working as expected, thanks @ShiyaVivala for your effort and awesome contribution.



  • @ShiyaVivala it keeps old DB and settings or just make a fresh OpenBullet ?


  • Admin

    Pretty sure settings and DB are kept but probably the Environment.ini gets overwritten



  • alr thanks OP for contribution



  • @Ruri I have a modified enviroment .ini & it wasn't overwritten, so OB updater pretty cool.


Log in to reply